Open Sensorless BLDC controller

Electric Motors and Controllers

Re: Open BLDC controller

Postby Teh Stork » Wed May 09, 2012 2:01 am

Love your work!

I'm working on a controller with three current sensors, it's mainly since you can't sample current with two current sensors at 100% pwm that I use it (And for running FOC) - but one current sensor and controll like you show seems like a cheap and efficient way of controll. I'm thinking about trying to mate such a motor to a CVT with a slip clutch so that there is no load at bottom of load range. I've got some experience with moped CVT's, but I'm thinking about controlling one with a microcontroller and some PID loops. Some time in the future :)
Teh Stork
1 kW
1 kW
 
Posts: 306
Joined: Wed May 25, 2011 8:02 am

Re: Open BLDC controller

Postby bearing » Wed May 09, 2012 10:54 am

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


Very nice work. It looks like it starts well, and transitions to EMF sensing without a glitch.
bearing
1 kW
1 kW
 
Posts: 449
Joined: Wed Dec 24, 2008 2:14 am

Re: Open BLDC controller

Postby casainho » Wed May 09, 2012 4:53 pm

Oh men, I am trying to do the same but seems I lack a lot of technical information about BLDC motors.

walls99, please see what I did already on EBike Smart Controller: viewtopic.php?f=3&t=38337

Thank you for sharing!!
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Sensorless Regenerative Braking

Postby casainho » Sat May 12, 2012 1:37 am

Hello walls99.

I were quick reading your assembly code. I would like to ask you:
1. Why did you code in assembly and not in C? C would be easier to understand (at least for me) but I must say your comments on the code are great - thanks.
2. Why aren't you testing your controller with a ebicycle hub motor?

Could you please give a look to the schematic KU63 controller I am using and provide your opinion about it? Could you please tell me what strategy I could use to startup the motor in sensorless (my motor don't have hall sensors).

Thank you for sharing.
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Sensorless Regenerative Braking

Postby walls99 » Sun May 13, 2012 1:35 pm

casainho wrote:1. Why did you code in assembly and not in C? C would be easier to understand (at least for me) but I must say your comments on the code are great - thanks.

Sometime I ask myself the same question when I try to re-read my own code :). The practical answer is that C would be better for many good reason but not fast enough on the PIC 18F. Also, I'm doing this project for fun and I like the challenge!

casainho wrote:2. Why aren't you testing your controller with a ebicycle hub motor?

I've designed my controller to handle low-ish inductance RC motors in high load condition without burning like most commercially available controller do, to use on my ESR Goped. I don't have a hub motor but I wouldn't expect any surprise.

casainho wrote:Could you please give a look to the schematic KU63 controller I am using and provide your opinion about it?

I did, it's very similar in principle to my controller. It's simple and low cost, so definitely a good starting point.

casainho wrote:Could you please tell me what strategy I could use to startup the motor in sensorless (my motor don't have hall sensors).

Check above Positioning by current sensing
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Sensorless Regenerative Braking

Postby casainho » Sun May 13, 2012 2:20 pm

My mistake. Message to delete.
Last edited by casainho on Sun May 13, 2012 8:17 pm, edited 1 time in total.
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Open BLDC controller

Postby Teh Stork » Sun May 13, 2012 2:54 pm

casainho, go read up on some application notes. There are dozens out there with sensorless startup routines! Atmel is a great place to start ;)
Teh Stork
1 kW
1 kW
 
Posts: 306
Joined: Wed May 25, 2011 8:02 am

Re: Sensorless Regenerative Braking

Postby casainho » Sun May 13, 2012 9:33 pm

walls99 wrote:
casainho wrote:1. Why did you code in assembly and not in C? C would be easier to understand (at least for me) but I must say your comments on the code are great - thanks.

Sometime I ask myself the same question when I try to re-read my own code :). The practical answer is that C would be better for many good reason but not fast enough on the PIC 18F. Also, I'm doing this project for fun and I like the challenge!

Seems you are using your PIC at 40MHz (10MHz each CPU clock cycle). I am using a cheap ($10) 32 bits ARM7 board running at 48MHz, so, 4.8 times more processing power as your board (or even more since your PIC version is 8 bits).

KU63 controller drived my Cute-85 motor with PWM signal of 15.6KHz. The lowest velocity have a 31.6ms period of each phase commutation. The highest velocity, 2.24ms.
I hope my board at 48MHz will work ok. Even I think my e-bicycle motor have a lower rotation than yours motor.

I really think we need a kind of Arduino on e-bicycle controllers, I mean, an OpenSource and well documented controller. Also with commercial success.

I would like to get help, developers and testers joining my effort.

walls99 wrote:
casainho wrote:Could you please give a look to the schematic KU63 controller I am using and provide your opinion about it?

I did, it's very similar in principle to my controller. It's simple and low cost, so definitely a good starting point.

Good to know that is simple and low cost, that is what we need :-) -- it works perfectly on my bicycles.

And the KU63 BEMF circuit seems similar to yours, however KU63 BEMF circuit have a signal (PWM), CPU-34 on the schematic, from the controller that interacts with BEMF circuit. This PWM signal is only used at startup/low speed.

Could you please explain your BEMF circuit, logic behind it? How do you use the output of this circuit in the firmware?

walls99 wrote:
casainho wrote:Could you please tell me what strategy I could use to startup the motor in sensorless (my motor don't have hall sensors).

Check above Positioning by current sensing

Thank you for your explanation! The oscilloscope pictures and your explanation are great - thank you for sharing.

I will energize the motor, using the 6 steps, with 50us each step and look at the current with oscilloscope. I hope to see the same as you. I will report later.
After I will implement your strategy of searching the rotor position and energize the "next" (+120º) phase.

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

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.
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Sensorless Regenerative Braking

Postby Lebowski » Mon May 14, 2012 1:50 am

casainho wrote:I really think we need a kind of Arduino on e-bicycle controllers, I mean, an OpenSource and well documented controller. Also with commercial success.


I don't think this is possible. Once you get to a stage where you're project
is worthwile the big China companies will start producing it leaving you as
a developer out of the loop. Why would they give you money when all they
need is freely available on the internet ?
User avatar
Lebowski
100 kW
100 kW
 
Posts: 1472
Joined: Tue Jun 28, 2011 1:38 am
Location: beautiful Zurich, Switzerland

Re: Sensorless Regenerative Braking

Postby casainho » Mon May 14, 2012 2:20 am

Lebowski wrote:
casainho wrote:I really think we need a kind of Arduino on e-bicycle controllers, I mean, an OpenSource and well documented controller. Also with commercial success.


I don't think this is possible. Once you get to a stage where you're project
is worthwile the big China companies will start producing it leaving you as
a developer out of the loop. Why would they give you money when all they
need is freely available on the internet ?

Maybe you have reason. I don't care about money on this project, I am not working professional on it. I am only a user and a maker, I am trying to develop and implement what I need since no one is selling it. But I think this project would have for sure success with a business plan. If someone produces and sells what I am looking (and developing), I would be happy to buy.

I am already buying and using "chinese" controllers and I am also taking advantage of them to develop my own controller for my needs.

Maybe we can find a project leader and manager, someone who will try to get funding and producing it. Funding on kickstarter or other site like that. There are a few OpenSource gadget shops that produces and sells OpenSource projects from ideas of users: Sparkfun, AdaFruits, Olimex, etc.

Lebowski, can you share with us your plan for your controller?
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Open BLDC controller

Postby Lebowski » Mon May 14, 2012 4:24 am

the plans for my controller are to design a PCB (in progress), after that
I want to add rotor position sensing by measuring winding inductances
for powered startup at motor standstill.

board.jpg
board.jpg (79.72 KiB) Viewed 740 times
User avatar
Lebowski
100 kW
100 kW
 
Posts: 1472
Joined: Tue Jun 28, 2011 1:38 am
Location: beautiful Zurich, Switzerland

Re: Open BLDC controller

Postby bigmoose » Mon May 14, 2012 8:11 am

Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.
bigMoose's electronic pieces & parts (GENUINE IRFB4110Pbf's, Nomex 410, AntiCorrosion Grease, Current Sensors) available HERE.
Thanks to Justin ebikes.ca for securing the board then setting us FREE! Tech Tips in the WiKi: http://endless-sphere.com/w
"Live simply. Love generously. Care deeply. Speak kindly. Leave the rest to God..." all the best, Dave
User avatar
bigmoose
10 MW
10 MW
 
Posts: 2451
Joined: Thu Aug 06, 2009 3:05 pm
Location: Northern Ohio, USA

Re: Open BLDC controller

Postby Arlo1 » Mon May 14, 2012 10:08 am

Hey Walls. With my controller project I did it all in the open. I didn't licence it as an open source don't know much about that. I will be working on the code more this winter.
I made mine modular so we can make any power level with it we want. I like things in the open. I just want to get my off the ground to encourage more people to build them and to try to help prices come down. I love what I have learnt and cant wait to learn more.

On the other hand lebowski is right he has a skill and put a lot of time into his code so that is worth money to him. I would like to see lebowski sell chips and full controllers to maybe help with his financial need when his job ends in a few months. So I in no way want to hurt his sales if anything I will try to make a few items to help sell kits for him!

SO when I get back to the code this fall I will work on it open source and hopefully get peoples help. If not no biggie But I see a steep learning curve ahead and will likely take 5 years? to get the features lebowski has and will not likely be the same I will write code for different options on my way. As for why I will do this open source? Because I don't know enough to sell my code. IN 5 years maybe but by then I will maybe write code for something else to make money. At the end of the day I just want to go fast! :)
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 STUF
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!
[color=#FF0000][b][size=150]Never above 4.2v never below 2.7v EVER!!!
User avatar
Arlo1
100 GW
100 GW
 
Posts: 5227
Joined: Sun Apr 26, 2009 10:36 pm
Location: Nanaimo BC Canada

Re: Open BLDC controller

Postby casainho » Mon May 14, 2012 11:08 am

Arlo1 wrote:Hey Walls. With my controller project I did it all in the open. I didn't licence it as an open source don't know much about that. I will be working on the code more this winter.

Hello Arlo1.

Your thread is big, I can't find now time to read it all. Do you have working firmware? If so, could you please consider to use github to host the project sources?? Github also provides a wiki, which is great for documentation, instead forum messages.

Here is the github for my EBike Smart Controller project: https://github.com/casainho/EBike-Smart-Controller
Smart EBike (OpenSource): Dashboard/color display with touchscreen + Motor controller + Battery pack BMS:
  1. hackable/configurable options for advanced users
  2. Bluetooth communications with SmartPhones
  3. wireless communications between each three systems
Project page with documentation and source files: www.smartebike.likesyou.org
casainho
100 W
100 W
 
Posts: 254
Joined: Mon Feb 14, 2011 2:43 pm

Re: Open BLDC controller

Postby Lebowski » Tue May 15, 2012 1:18 am

bigmoose wrote:Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.


Let's hope for the best then, it'll be the only way in which it's all going to fit....
User avatar
Lebowski
100 kW
100 kW
 
Posts: 1472
Joined: Tue Jun 28, 2011 1:38 am
Location: beautiful Zurich, Switzerland

Re: Open BLDC controller

Postby texaspyro » Tue May 15, 2012 10:13 am

Lebowski wrote:
bigmoose wrote:Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.


Let's hope for the best then, it'll be the only way in which it's all going to fit....


Unfortunately, hoping for the best is no substitute for doing it right. Even the Chinese realize the problems that those vertical parts can cause. Potting or lots of RTV'd components might help.
texaspyro
1 MW
1 MW
 
Posts: 1539
Joined: Wed May 12, 2010 6:53 pm

Re: Open BLDC controller

Postby Arlo1 » Tue May 15, 2012 12:45 pm

Lebowski wrote:
bigmoose wrote:Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.


Let's hope for the best then, it'll be the only way in which it's all going to fit....

I realy think its best to be modular have the brain on one board and the powerstage seprate. Then people are able to build it to suit their needs and replace blown power stage parts with less trouble.
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 STUF
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!
[color=#FF0000][b][size=150]Never above 4.2v never below 2.7v EVER!!!
User avatar
Arlo1
100 GW
100 GW
 
Posts: 5227
Joined: Sun Apr 26, 2009 10:36 pm
Location: Nanaimo BC Canada

Re: Open BLDC controller

Postby Lebowski » Tue May 15, 2012 2:35 pm

Arlo1 wrote:
Lebowski wrote:
bigmoose wrote:Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.


Let's hope for the best then, it'll be the only way in which it's all going to fit....

I realy think its best to be modular have the brain on one board and the powerstage seprate. Then people are able to build it to suit their needs and replace blown power stage parts with less trouble.


Modular, that's the next step. First I want to do a 6 FET board which should maybe be capable of around 10 kW with TO247
(when you use 150 V devices, 120 V battery, 120 A phase amplitude (irfb 4568) gives around 80 A batter current -> 10 kW at
a dissipation of 22W per FET, is that do-able?). What kind of heatsink would 132 W of dissipation need ?

Dependent on how things go with the 6 FET I would like to design a 2 FET module including a full bridge, 2 caps, snubbers, current sensor
and a gate driver IC. 3 modules with a brain-board would give you a 6 FET, 6 modules with a brain-board a 12 FET controller etc etc...
Last edited by Lebowski on Tue May 15, 2012 2:39 pm, edited 2 times in total.
User avatar
Lebowski
100 kW
100 kW
 
Posts: 1472
Joined: Tue Jun 28, 2011 1:38 am
Location: beautiful Zurich, Switzerland

Re: Open BLDC controller

Postby Lebowski » Tue May 15, 2012 2:36 pm

texaspyro wrote:
Lebowski wrote:
bigmoose wrote:Lebo, a quick tip FWIW, vertical mount leaded components tend no to be optimum in high vibration and shock environments.


Let's hope for the best then, it'll be the only way in which it's all going to fit....


Unfortunately, hoping for the best is no substitute for doing it right. Even the Chinese realize the problems that those vertical parts can cause. Potting or lots of RTV'd components might help.


Maybe it also depends, I plan to use a double sided board with proper through-metalised via's. I cannot imagine components
breaking out then (single sided without vias, then it is maybe possible)
User avatar
Lebowski
100 kW
100 kW
 
Posts: 1472
Joined: Tue Jun 28, 2011 1:38 am
Location: beautiful Zurich, Switzerland

Re: Open BLDC controller

Postby amberwolf » Tue May 15, 2012 3:17 pm

It's not that they break out of the holes. It's that the parts wiggle back and forth, and break their leads off above the PCB. ;)
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: 13717
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 bigmoose » Tue May 15, 2012 7:15 pm

The proto's will work fine either way. If you were to manufacture them and have them used widely in the field, that is when you will see the problem. In the area I work in we must analyze for solder fatigue under vib and shock loads. My comment and advice comes from that experience. Granted, we are talking about environments 6 sigma more severe than an eBike, but the principles hold in general across the board.

... or as others have said to me: "Moose you are ruined for designing consumer products!" :P
bigMoose's electronic pieces & parts (GENUINE IRFB4110Pbf's, Nomex 410, AntiCorrosion Grease, Current Sensors) available HERE.
Thanks to Justin ebikes.ca for securing the board then setting us FREE! Tech Tips in the WiKi: http://endless-sphere.com/w
"Live simply. Love generously. Care deeply. Speak kindly. Leave the rest to God..." all the best, Dave
User avatar
bigmoose
10 MW
10 MW
 
Posts: 2451
Joined: Thu Aug 06, 2009 3:05 pm
Location: Northern Ohio, USA

Re: Open BLDC controller

Postby salty9 » Tue May 15, 2012 11:52 pm

bigmoose wrote:
... or as others have said to me: "Moose you are ruined for designing consumer products!" :P


Yeah, you gotta make it break quick so they will buy another one. :cry:
salty9
1 kW
1 kW
 
Posts: 484
Joined: Fri Aug 14, 2009 10:14 pm
Location: 42.6°N 122.71°W

BEMF filter and ZC detection

Postby walls99 » Wed May 16, 2012 7:47 am

casainho wrote:Could you please explain your BEMF circuit, logic behind it? How do you use the output of this circuit in the firmware?


The BEMF circuit is a standard voltage divider + low pass filter + virtual neutral comparator for Zero Crossing detection feeding the Input Capture module of the PIC. There is a lot of literature available about the Zero Crossing principles. I suggest you read this 2000+ post thread DIY BLDC controller.

The low pass filter is designed to limit the phase lag to below 30º for the maximum RPM, so it can be compensated for by adjusting the phase advance in software. I also make use of the PIC digital noise filters to reduce the interference from the PWM signal.

See attached, the BEMF filter LTspice:
bemf_filter_3.zip
BEMF filter LTspice
(873 Bytes) Downloaded 103 times
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 May 16, 2012 12:20 pm

Arlo1 wrote:Hey Walls. With my controller project I did it all in the open. I didn't licence it as an open source don't know much about that. I will be working on the code more this winter.
I made mine modular so we can make any power level with it we want. I like things in the open. I just want to get my off the ground to encourage more people to build them and to try to help prices come down. I love what I have learnt and cant wait to learn more.

On the other hand lebowski is right he has a skill and put a lot of time into his code so that is worth money to him. I would like to see lebowski sell chips and full controllers to maybe help with his financial need when his job ends in a few months. So I in no way want to hurt his sales if anything I will try to make a few items to help sell kits for him!

SO when I get back to the code this fall I will work on it open source and hopefully get peoples help. If not no biggie But I see a steep learning curve ahead and will likely take 5 years? to get the features lebowski has and will not likely be the same I will write code for different options on my way. As for why I will do this open source? Because I don't know enough to sell my code. IN 5 years maybe but by then I will maybe write code for something else to make money. At the end of the day I just want to go fast! :)


I started to play with BLDC motors back in 2007, my first controller used sine wave open loop control. So it took me about 5 years, working maybe few hundred hours per year, to get where I'm today! I did spend a bit of time to get the solar power management working on my gen 2 controller for solar RC planes but it's still many hours to get everything working...

see below the picture of my first gen prototype
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 bigmoose » Wed May 16, 2012 12:43 pm

walls99 wrote:I started to play with BLDC motors back in 2007, my first controller used sine wave open loop control. So it took me about 5 years, working maybe few hundred hours per year, to get where I'm today! ...


Congrats on the journey! Those who have walked with you can relate. It "looks" so easy... but it's not, to do the integrated system well.
bigMoose's electronic pieces & parts (GENUINE IRFB4110Pbf's, Nomex 410, AntiCorrosion Grease, Current Sensors) available HERE.
Thanks to Justin ebikes.ca for securing the board then setting us FREE! Tech Tips in the WiKi: http://endless-sphere.com/w
"Live simply. Love generously. Care deeply. Speak kindly. Leave the rest to God..." all the best, Dave
User avatar
bigmoose
10 MW
10 MW
 
Posts: 2451
Joined: Thu Aug 06, 2009 3:05 pm
Location: Northern Ohio, USA

PreviousNext

Return to Motor Technology

Who is online

Users browsing this forum: Bartimaeus, Google [Bot] and 4 guests