Open Sensorless BLDC controller

walls99

100 W
Joined
Mar 11, 2009
Messages
114
Location
UK
updated 1st post summary:

For the past 5 years, I have been developing sensorless BLDC controllers (HW and SW) based on the PIC18F4431 Microcontroller from Microchip.The initial motivation was to design a high efficiency BLDC controller for solar RC car races, basically a 1kg RC car powered by a 20dm² solar panel. I had to design my own controller because most commercially available solutions were optimised for cost and not flexible or open enough to implement the required power management for a solar vehicle. When you only have 20W of power, any improvement in efficiency counts!

So my 1st generation controller integrates sensorless BLDC control, MPPT for a solar energy source and power management for a supercapacitor or battery buffer. I started the SW development on a stripboard prototype and then, once the basis of my design got stable enough, I designed a small form factor PCB:

solarBMC_ss.jpg


By 2010, I had a fairly robust controller but I was well behind with the design of the rest of the car, so while looking for a partner to build a race and found a RC plane builder who was interested in my controller to build a RC solar plane. I found this new challenge immediately more motivating and moved on from the car to the plane :). The "plane" which is actually a flying wing design successfully flew in 2011 and the developer is still optimizing the mechanical side of it to reduce weight and improve its range. This controller is confirmed to be 10-15% more efficient than controllers commercially available...

So, when the 2011 winter arrived I found myself without any project and I decided to upgrade the motor on my Goped ESR scooter to brushless to complement my DIY A123 battery pack with custom BMS. As I was browsing the ES forum for motor advise, I found that BLDC controller were a significant factor limiting to use of the brussless motor on DIY EVs! It seems there are very few options that are flexible, low cost and robust enough for the E.V enthusiasts. Also I was disappointed to see that most controller projects that started with the good intention to go open source, didn't for some reason...

Sensorless BLDC control is not complicated but it takes time to get it working well. I think I have a solution that works and so I decided to share it so other DIY-er can design their own controller with limited effort on the SW side. See below for more details on the 1st generation controller.

I'm now working on a 2nd generation controller which is designed specifically for EVs using brushless RC motor with:
- High power continuous handling capability ~2kW
- Low inductance motor support ~50uH (and probably less)
- High torque Sensorless start and drive
- Phase current control
- Regenerative braking

HB_BLMC.jpg


You can follow the development of the 2st generation controller on this same thread


================================================================================================================================
1st generation controller:

Here is a picture of one of the controllers:
Solar_BLMC_s.jpg


Here is the schematic:
View attachment 1

My 1st generation controller is based around a PIC18F4431 Microcontroller and LT1158 drivers. Provided you are ok with using the same microcontroller and similar drivers (with an enable and PWM input), this design can be scaled up to support relatively high level of power with little effort.
The source code is being release under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License (http://creativecommons.org/licenses/by-nc-sa/3.0/).

Here is the source:


Notes:
- I can provide some support on HW and advice on code changes to people designing controller based on my solution, in particular to setup the demag and advance timing.
- This code is ready to be compiled and run. It takes a RC servo style signal as an input, both car and airplane styles are supported. Soft LVC is also supported
- The PWM is set at 20kHz but can easily be changed. The ADCs are fully setup to sample at 800Hz and there is enough processing power to do stuff at that rate.
- The bridge if fully synchronous for efficiency reason. So it could support regenerative braking with the appropriate software. Regen not being worth it on a ~1kg RC car, the software only support braking by shorting the 3phases. This should not be used on a large size EV, as it would quickly burn the motor!
- I will most likely design a high power controller to go brushless on my scooter and I'll try to publish most of my work but that might not happen until next winter now.
- Although limited, there should be enough comments in the code to explain how thinks are working. I will try to answer as many question as possible but I have limited time available and I don't intend to teach the principle of sensorless BLDC control, there is a lot literature out there for that.
- This code is stripped out of all the code related to solar power and battery buffer management which is not really relevant to large size EV (yet). Some references to it however remain in the code, please ignore it.

Laurent
 
First, let me say, you're a hero for releasing your HW and SW design under creative commons. In a world of lawyer's choking out EV development, this is how man helps to better the world.


Can you tell us what the starting torque is like on your sensorless design? For some bikes that pedal first, it makes roughly no difference, but many of us have struggled with controllers guessing rotor position incorrectly at low RPMs and causing controller failures and/or poor starting performance. Are you using the voltage comparator method for sensing rotor position or a flux vector method?

If I were to fund the PCB run, would you like to do a run of boards with no power fets, only some big high current FET drivers?

This is always exciting for me. :)
 
liveforphysics said:
Can you tell us what the starting torque is like on your sensorless design? For some bikes that pedal first, it makes roughly no difference, but many of us have struggled with controllers guessing rotor position incorrectly at low RPMs and causing controller failures and/or poor starting performance.
The starting torque is dependant on the battery voltage and the motor impedance, my controller only allows to set a limit on the PWM range during startup. See below

Code:
#define THR_MIN_NOLOCK  0x10       ;Min throttle command to start the motor
#define THR_MAX_NOLOCK  0x40       ;Max throttle limit until the motor sync is locked
Starting performance is allays going to be challenging with a sensorless controller, I can't comment on how my approach stacks up against other techniques but with access to the source, you can tailor the startup parameters to your motor and that should be an advantage over the closed controllers that need to work with a wide range of motors.

liveforphysics said:
Are you using the voltage comparator method for sensing rotor position or a flux vector method?
I'm using the 6 step method with comparators and filters to detect the zero crossing. It's much simpler than the vector method and can be made to work well.

liveforphysics said:
If I were to fund the PCB run, would you like to do a run of boards with no power fets, only some big high current FET drivers?
The idea behind releasing the source is that you guys can design you own controllers, I don't have the time to drive a project at the moment but I'll be happy to help/advice you if you re-use my design.
 
I have corrected a few bugs and enhanced some on the synchronization loops to be more stable, please find the updated source code below:

View attachment Open_BLMC_1_1.zip
Change log:
  • Fixed throttle range in non car mode, 1.1ms = 0 and 1.9ms = 100%, new sync algo in ZC locked state,
    Made brake mode optional, new sync algo for RC locked state, new filter for RC input.
 
walls99 said:
- I will most likely design a high power controller to go brushless on my scooter and I'll try to publish most of my work but that might not happen until next winter now.

Some progress on this project, I now have a working prototype able to:
- sensorless start and drive an Aerodrive SK3 6374
- control the torque by precisely controlling the phase current, cycle per cycle at 20KHz
- sink 60A "continuously" into the motor with the rotor blocked for 30sec without damaging to the controller (The motor does get quite hot!).

Next I need to:
- increase the PIC clock speed to 40MHz because I ran out of MIPS, luckily I was only using it at 20MHz.
- implement temperature monitoring and management for the motor and the mosfets
- use batteries to test operations at the design target of 100A 30V
- implement regenerative braking
- Test on my Goped...

Schematic here...

IMG_0121-1.jpg
 
Hi,

Very nice work!

couple of questions:

what is the max voltage the voltage divider can measure for the BEMF?

do you measure Phase amps with this controller?

i see you do not measure Phase current. do you estimate phase current with this formula: PhaseA=BattA*(1/dutycycle) (with dutycycle beteween 0-1)?
 
nieles said:
what is the max voltage the voltage divider can measure for the BEMF?
The BEMF is not measured directly, I use a 5V voltage comparator with a 24k/3.9k divider as shown on the schematic, so 35.8V max.

nieles said:
do you measure Phase amps with this controller?
i see you do not measure Phase current. do you estimate phase current with this formula: PhaseA=BattA*(1/dutycycle) (with dutycycle beteween 0-1)?

I do, it's not clear on the schematics but the current sensor is on the ground path between the FETs and the decoupling capacitors, so it measures the phase current during the ON time of the duty cycle.
 
lol just re-read my post. a bit contradicting :roll:

walls99 said:
I do, it's not clear on the schematics but the current sensor is on the ground path between the FETs and the decoupling capacitors, so it measures the phase current during the ON time of the duty cycle.

Smart! how well does this work? i have never seen this done before.

very interested in more progress on this

you might want to start a thread in the e-bike technical section. you will get far more interest/replies i think. diy controllers are a "hot" topic the last few weeks/months
 
Actually, the best thing would be to move this whole thread to the Motor Technology section where most controller stuff is. I can do that if you wish.
 
nieles said:
Smart! how well does this work? i have never seen this done before.
It works ok, the PIC automatically sample the current at the end of the ON duty cycle which provide as good result as any other current measurement. There are some limitations though, the sensor has a propagation delay of a few μs which means the measurements are a little off for short ON time but that doesn't matter since this isn't a useful mode of operation. Also it's more difficult to reduce the stray inductance because you can't have to much capacitance on the path before the current sensor.

See below the output of the sensor at 50A:

IMG_0123.jpg
 
Sweet!!!
 
I've just searched out this thread and it's great :D

I've purchased almost identical kit to you (sk6374 and pic18f4431) to get working on my Ebike. I had decided to go down the sensor route though with an Austria Micro Systems As5040(or lower spec 8bit output) which can provide the commutation signals direct. I am however an extremely slow (and intermittent) learner ;oD and just want to get my bike on the road :D

I have full pcb's facilities at work and an engineering shop and would happily help/get involved to get my bike on the road and help others.
 
barryfzr said:
I had decided to go down the sensor route though with an Austria Micro Systems As5040(or lower spec 8bit output) which can provide the commutation signals direct.
I was also planning to use position sensor to have full start-up torque but I found that position sensing by current measurement works very well with this type of motor. The permeance varies significantly from one electric position to the other and the permeance is minimum for the electrical position that is aligned with the mechanical position. Also with this type of low inductance motor, the 6 positions scanning is fast enough not to reduce the starting torque (~500us in my case). This approach gives me ~90% of the full potential star-up torque at 5ms sampling rate and it's good for speed up to 100RPM where the BEMF is strong enough to detect Zero Crossing...

See below the position sensing cycle, the current is maximum when the permeance is lowest:

IMG_0182.jpg
 
walls99, that's super cool! I think yours is the first controller I have seen that implements closed loop control for slow speed commutation. Do you have any references to your 6-position scanning method? Also, have you seen http://scolton.blogspot.com/? He has some interesting ideas on PMAC motor control.

Thanks for sharing your hard work.

-Matt
 
matt_in_mtl said:
I think yours is the first controller I have seen that implements closed loop control for slow speed commutation. Do you have any references to your 6-position scanning method?
I'm sure it's used somewhere else but I don't have any reference. As I have done before, I'll post the full source code when my work is done :)

The principle is simple, I'm using the standard 6 steps of the trapezoidal control for BLDC Motors, energizing each step for a fixed time (~50us in my case) and measuring the current delta for each step. The step with the highest current delta is is the most likley to be aligned with the mechanical position of the rotor. From there, I energize the mechanical position + 2 steps or 120 degrees advance in constant current/torque mode, wait for 5ms and repeat the 6 steps scan + 5ms drive until the motor speed is fast enough to cover the 2 steps advance in less than 5ms. At this point I switch to the BEMF sensing method.

[youtube]Q18h4-jLneI[/youtube]
 
Implementing regenerative braking was easier than anticipated, I gave a negative command to the PI current control loop and it just worked :D

The only work required was around detecting and handling the end of the useful regen region to avoid shorting the motor to brake at low speed which would heat the winding.

Here is a video of it working, accelerating to 3700RPM with 80A phase current then regen braking with 40A phase current:

[youtube]M-ou0m_uRJY[/youtube]
 
Very boring videos... we want smoke, sparks, flames, small thermonuclear explosions, megadeath and hyperdestruction :twisted:
 
A little more torque or a little less balance to the rotation, and you'll have that, when that clamp lets go. :p

Now, what we really need is a motor brake mode that *actively* brakes the wheel once the normal regenerative braking current drops below useful levels. Similar to the "lock" mode some ebike controllers have, where they actively oppose the direction of motion the wheel is being rolled in, when the bike is parked.
 
amberwolf said:
A little more torque or a little less balance to the rotation, and you'll have that, when that clamp lets go. :p
+1 You might seriously consider a more secure clamping method at both ends. :shock:

BUT, Laurent, this is awesome looking, plus, Open Source... Wow, you're going to be a hero on ES 8) if we can carry this forward for RC & other related motors... :mrgreen:

ES Thanks! Many many Thanks... :twisted:
 
Back
Top