Open Sensorless BLDC controller

Electric Motors and Controllers

Open Sensorless BLDC controller

Postby walls99 » Sun May 01, 2011 9:49 am

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:

Image

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

Image

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:
Image

Here is the schematic:
Solar_BLMC_12.png
(78.05 KiB) Downloaded 7 times


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:
Open_BLMC.zip
(73.08 KiB) Downloaded 673 times


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
Last edited by walls99 on Thu Jun 07, 2012 12:47 pm, edited 4 times in total.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby liveforphysics » Sun May 01, 2011 3:34 pm

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. :)
For ebike parts, don't be a douche, buy from http://www.ebikes.ca or http://www.MethTek.com

Justin saved the forum at great personal expense! The man is a legend and a hero!
User avatar
liveforphysics
100 GW
100 GW
 
Posts: 11008
Joined: Wed Oct 29, 2008 1:48 am
Location: Santa Cruz, CA, USA

Re: Open BLDC controller

Postby Alan B » Sun May 01, 2011 3:43 pm

Laurent, Welcome to ES and fantastic work on your open controller. We need more open controller designs for lots of reasons. I look forward to learning more about your project.
-- Alan W6AKB Cromotored FS GreyBorg, Novara MTB 9C, eBikeE Bent BMC, myEbikeWeb and Thanks to Justin at ebikes.ca for rescuing this forum!
User avatar
Alan B
1.21 GW
1.21 GW
 
Posts: 3906
Joined: Sat Sep 11, 2010 7:43 am
Location: San Francisco Bay Area, USA

Re: Open BLDC controller

Postby walls99 » Mon May 02, 2011 6:04 am

liveforphysics wrote: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: Select all
#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 wrote: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 wrote: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.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby walls99 » Wed Jul 06, 2011 2:01 pm

I have corrected a few bugs and enhanced some on the synchronization loops to be more stable, please find the updated source code below:

Open_BLMC_1_1.zip
(75.36 KiB) Downloaded 403 times

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.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby walls99 » Wed Feb 01, 2012 9:14 pm

walls99 wrote:- 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...

Image
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby nieles » Thu Feb 02, 2012 4:32 am

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
1 kW
1 kW
 
Posts: 475
Joined: Mon Jul 14, 2008 5:39 pm
Location: The Netherlands

Re: Open BLDC controller

Postby walls99 » Thu Feb 02, 2012 12:54 pm

nieles wrote: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 wrote: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.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby nieles » Thu Feb 02, 2012 1:33 pm

lol just re-read my post. a bit contradicting :roll:

walls99 wrote: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
nieles
1 kW
1 kW
 
Posts: 475
Joined: Mon Jul 14, 2008 5:39 pm
Location: The Netherlands

Re: Open BLDC controller

Postby amberwolf » Thu Feb 02, 2012 2:46 pm

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.
House Fire Updates Thread


Got a question that isn't personal or private? Post it in the forums, don't PM it. ;)

Wiki your techy info so it doesn't get old, lost and icky:
http://endless-sphere.com/w


Full-Suspension Semi Recumbent Cargo Bike - NuVinci MidDrive
Semi-Recumbent Recycled-Parts Cargo eBike: "CrazyBike2"
DayGlo Avenger, MkII
User avatar
amberwolf
100 GW
100 GW
 
Posts: 13819
Joined: Mon Aug 17, 2009 6:43 am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group

Re: Open BLDC controller

Postby walls99 » Thu Feb 02, 2012 3:27 pm

amberwolf wrote: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.

Sure
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby amberwolf » Thu Feb 02, 2012 3:58 pm

Done. :)
House Fire Updates Thread


Got a question that isn't personal or private? Post it in the forums, don't PM it. ;)

Wiki your techy info so it doesn't get old, lost and icky:
http://endless-sphere.com/w


Full-Suspension Semi Recumbent Cargo Bike - NuVinci MidDrive
Semi-Recumbent Recycled-Parts Cargo eBike: "CrazyBike2"
DayGlo Avenger, MkII
User avatar
amberwolf
100 GW
100 GW
 
Posts: 13819
Joined: Mon Aug 17, 2009 6:43 am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group

Re: Open BLDC controller

Postby walls99 » Thu Feb 02, 2012 6:49 pm

nieles wrote: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:

Image
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby Arlo1 » Sun Feb 05, 2012 7:19 pm

Sweet!!!
Thanks Justin of http://www.ebikes.ca/
Also a thanks to Methy at http://www.methtek.com/ :)
And Dave who has some good deals on STUFF Incl. Mosfets, Current sensors and Nomex paper.
RC lipo and most other types of Lithium batteries you MUST know your individual cell voltages while charging and discharging.
Batteries of all kinds need respect they can burn your house down, so don't sleep with them under your bed or any other were you cant afford smoke or fire!
Never above 4.2v never below 2.7v EVER!!!
User avatar
Arlo1
100 GW
100 GW
 
Posts: 5297
Joined: Sun Apr 26, 2009 10:36 pm
Location: Nanaimo BC Canada

Re: Open BLDC controller

Postby barryfzr » Sun Feb 12, 2012 6:08 pm

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
100 mW
100 mW
 
Posts: 37
Joined: Thu Oct 14, 2010 8:14 pm

Positioning by current sensing

Postby walls99 » Mon Feb 13, 2012 6:58 pm

barryfzr wrote: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:

Image
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Turnigy Aerodrive SK3 6374-192kv Phase Inductance

Postby walls99 » Sat Feb 25, 2012 9:42 am

Using the current measurement for each electrical step, you can also calculate the phase inductance:

Turnigy Aerodrive SK3 6374-192kv Phase Inductance:

Image
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby matt_in_mtl » Wed Feb 29, 2012 6:55 pm

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
1 W
1 W
 
Posts: 51
Joined: Wed Aug 13, 2008 1:06 pm

Re: Open BLDC controller

Postby walls99 » Sat Mar 03, 2012 10:58 am

matt_in_mtl wrote: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.

User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby matt_in_mtl » Tue Mar 06, 2012 1:06 pm

walls99,
thanks for the reply. That method makes good sense.

-Matt
matt_in_mtl
1 W
1 W
 
Posts: 51
Joined: Wed Aug 13, 2008 1:06 pm

Re: Open BLDC controller

Postby walls99 » Sun Apr 29, 2012 2:50 pm

This is my DIY inertia wheel load on a SK3 6374-192kv, accelerating to 4500RPM with 80A phase current, 1370W peak power, sensorless start-up, sensorless 6 step method and adaptive advance.



Image
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Sensorless Regenerative Braking

Postby walls99 » Mon May 07, 2012 3:17 pm

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:

User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby texaspyro » Tue May 08, 2012 12:33 am

Very boring videos... we want smoke, sparks, flames, small thermonuclear explosions, megadeath and hyperdestruction :twisted:
texaspyro
1 MW
1 MW
 
Posts: 1539
Joined: Wed May 12, 2010 6:53 pm

Re: Open BLDC controller

Postby amberwolf » Tue May 08, 2012 12:52 am

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.
House Fire Updates Thread


Got a question that isn't personal or private? Post it in the forums, don't PM it. ;)

Wiki your techy info so it doesn't get old, lost and icky:
http://endless-sphere.com/w


Full-Suspension Semi Recumbent Cargo Bike - NuVinci MidDrive
Semi-Recumbent Recycled-Parts Cargo eBike: "CrazyBike2"
DayGlo Avenger, MkII
User avatar
amberwolf
100 GW
100 GW
 
Posts: 13819
Joined: Mon Aug 17, 2009 6:43 am
Location: Phoenix, AZ, USA, Earth, Sol, Local Bubble, Orion Arm, Milky Way, Local Group

Re: Open BLDC controller

Postby deVries » Tue May 08, 2012 6:32 am

amberwolf wrote: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:
deVries
1 MW
1 MW
 
Posts: 1652
Joined: Thu Jul 10, 2008 11:29 pm
Location: Solar Powered 3000w Austin Texas

Next

Return to Motor Technology

Who is online

Users browsing this forum: major, saltyyadad, Zeropointbug and 7 guests