Open Sensorless BLDC controller

Electric Motors and Controllers

Re: BEMF filter and ZC detection

Postby casainho » Wed May 16, 2012 1:04 pm

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

Thank you for this information. I did read something about using the PWM OFF time to read directly the Zero Crossing.

Right now I am experimenting to learn and be able to detect the rotor position, using the current sensing as you described. Later I need to implement the startup strategy.
I found that one parts of mosfet drivers are not working as expected (much slow turn on) and I need to find why. A big change is that my ARM works at 3.3V and the original controller worked at 5V, so, the drivers may need 5V logic.

Hmm, I don't know about spice simulation... is there any OpenSource software for it? (I am limiting myself to OpenSource software).
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 S.B.D » Sun May 20, 2012 8:53 am

Hey Walls,

I am finding this thread very educational and learning a lot from it. Your design makes my DIY sensored BLDC controller look like a broken toaster.... :mrgreen:
I'm just starting to understand sensorless detection methods. Can you give a short explanation on your BEMF detection design?
The analog circuit is straight forward and I understand it well. The FW implementation is new to me.
Do you sample the comparator outputs when PWM is low? What digital filtering are you implementing?
I read a Microchip app note about majority voting algorithm and FIR filtering...what do you use?
Keep posting and updating..

Thanks,
S.B.D
S.B.D
100 mW
100 mW
 
Posts: 48
Joined: Thu Dec 29, 2011 1:59 pm

Re: Open BLDC controller

Postby walls99 » Sun May 20, 2012 6:35 pm

S.B.D wrote:Do you sample the comparator outputs when PWM is low? What digital filtering are you implementing?
I read a Microchip app note about majority voting algorithm and FIR filtering...what do you use?

The comparator outputs are "sampled" continuously by the Input Capture module independently of the PWM signal. Interferences from the PWM are filter out by the analog low pass filter and the digital noise filter integrated in the PIC, check section 16.3 of the 18F4431 datasheet for more info.

In running mode, the Input Capture is only enable for the comparator output you expect an event from and only from 15º before the expected zero-crossing until it happens or time's out. see the function below for more info on the Input Capture setup depending on the step/position:

Code: Select all
LOAD_IC     org 0x1000
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby casainho » Sun May 20, 2012 6:56 pm

Walls, could you please share with us some pictures from the simulation?? Maybe some pictures can help us learn how it works... like I am curious to see the result signal after the filter and input to microcontroller.
Thank you.
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 walls99 » Mon May 21, 2012 9:36 am

casainho wrote:Walls, could you please share with us some pictures from the simulation?? Maybe some pictures can help us learn how it works... like I am curious to see the result signal after the filter and input to microcontroller.
Thank you.


Here is the LTspice model based on Bearing's model:
motor_sim_0.4.zip
(2.52 KiB) Downloaded 61 times


And the picture:
Image
Last edited by walls99 on Mon May 21, 2012 7:40 pm, edited 1 time 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 bearing » Mon May 21, 2012 5:56 pm

Nice!
I'm happy someone made use of that spice model. I see you have made some enhancements too.
bearing
1 kW
1 kW
 
Posts: 449
Joined: Wed Dec 24, 2008 2:14 am

Re: Open BLDC controller

Postby walls99 » Mon May 21, 2012 7:42 pm

bearing wrote:Nice!
I'm happy someone made use of that spice model. I see you have made some enhancements too.

I'm glad you recognized it, I couldn't remember where I found it and give you proper credit for the original model. Thanks!
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Open BLDC controller update

Postby walls99 » Fri May 25, 2012 9:26 am

Progress update:
- PIC clock increased to 40MHz do to more stuff per 50us PWM cycle.
- Implemented and tested temperature monitoring and management for the mosfets
- Implemented regenerative braking
- Stress tested with 90A phase current accelerations up to 4600RPM (~1900W) then 40A regen braking

See below the battery current, voltage and power during the stress test. Note that regen current appears as positive:

Image

Todo:
- Test on my Goped...
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Open BLDC controller testing

Postby walls99 » Sun May 27, 2012 2:49 pm

walls99 wrote:Todo:
- Test on my Goped...

6km of road testing later, I'm happy to report that the controller is working well!

The top speed is 34Km/h as expected. Regenerative braking is also working but the fixed braking phase current makes it too aggressive at speed, so I probably need to control to power rather than phase current to have a more progressive braking experience. However it does feel great to know that some of the kinetic energy is returned to the battery rather than being wasted in heat in the brake disk!!!!

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 dnmun » Sun May 27, 2012 3:20 pm

just exceptional, really nice thread to follow your progress.

i would request you change the title to "open source BLDC motor controller" so it will come up more rapidly on google search since it is the more commonly used term.

really really nice.
dnmun
100 GW
100 GW
 
Posts: 9200
Joined: Mon Jun 09, 2008 1:32 pm
Location: portland, or and loveland, co

Re: Open BLDC controller

Postby casainho » Sun May 27, 2012 4:06 pm

walls99, great news!!

Will you design a PCB for this controller? I would use if it could control my 24V 250W electric bicycle. I could buy the components, assembly and test my board.

Why don't you put the firmware and schematic/board sources on Github (as other Open Source projects)??

dnmun wrote:i would request you change the title to "open source BLDC motor controller" so it will come up more rapidly on google search since it is the more commonly used term.

Good idea but I would also use the words "ebike" on the title for the same reason.
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 walls99 » Sun Jun 03, 2012 2:02 pm

casainho wrote:Will you design a PCB for this controller? I would use if it could control my 24V 250W electric bicycle. I could buy the components, assembly and test my board.
Why don't you put the firmware and schematic/board sources on Github (as other Open Source projects)??


I have designed a custom PCB for my Goped controller, see pictures below. I'm happy to share the design with other who want to use it as a starting point but I wouldn't recommend a straight copy of it.

Image

Image

Image

Image

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 Jun 03, 2012 7:13 pm

Walls I frocking love it!!! Thats easily more powerfull then a 12 fet with 4110s!
Last edited by Arlo1 on Sun Jun 03, 2012 8:18 pm, edited 1 time in total.
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 kfong » Sun Jun 03, 2012 8:16 pm

Subscribed, Nice work
kfong
1 MW
1 MW
 
Posts: 1648
Joined: Tue Sep 02, 2008 11:34 am
Location: SE Michigan, USA

Open Sensorless BLDC controller summary

Postby walls99 » Thu Jun 07, 2012 12:44 pm

FYI, I have updated the 1st post to add a summary and more details on the story behind this projects.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Open BLDC schematics and layouts

Postby walls99 » Sun Jun 17, 2012 11:13 am

walls99 wrote:I'm happy to share the design with other who want to use it as a starting point but I wouldn't recommend a straight copy of it.


Here are the schematics and board layouts for the brain and brawn of my controller. I have updated them with all the changes I made on my prototype, so use them at your own risk.

Hoverboard_blmc_brain_40.zip
(87.41 KiB) Downloaded 162 times


Image

Hoverboard_blmc_brawn_40.zip
(70.52 KiB) Downloaded 122 times


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

Re: Open BLDC schematics and layouts

Postby casainho » Fri Aug 31, 2012 5:33 am

Hey, thanks for sharing!!

I am planning to buy the components and assembly by hand on a perfboard the power section. I really like the modular way of the system. I also want to use the ARM processor/board I am familiar with and program in C instead of assembly.

I also want modular because I plan to use bluetooh UART module.
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 bearing » Fri Sep 14, 2012 7:52 am

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

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.


Is this the latest version of the projekt?

I would like to play with this, and then maybe make a board which can drive a 80100 on 80V.
bearing
1 kW
1 kW
 
Posts: 449
Joined: Wed Dec 24, 2008 2:14 am

Re: Open BLDC controller

Postby walls99 » Mon Sep 17, 2012 9:41 pm

bearing wrote:Is this the latest version of the projekt?

I would like to play with this, and then maybe make a board which can drive a 80100 on 80V.


No, it's quite out of date. I'm planning on releasing new soft but I haven't had the time to finalize everything I wanted. They are many upgrade to handle "high power": Torque control, automatic advance timing, sensorless startup, temperature control, regenerative braking...

I've sent you a PM to discuss alpha release, if you're interested?
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open BLDC controller

Postby casainho » Tue Sep 18, 2012 2:36 am

walls99 wrote:
bearing wrote:Is this the latest version of the projekt?

I would like to play with this, and then maybe make a board which can drive a 80100 on 80V.


No, it's quite out of date. I'm planning on releasing new soft but I haven't had the time to finalize everything I wanted. They are many upgrade to handle "high power": Torque control, automatic advance timing, sensorless startup, temperature control, regenerative braking...

I've sent you a PM to discuss alpha release, if you're interested?

Walls99, please share your code on github. There you also have a wiki were you can place the information. Thank you.
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 Sensorless BLDC controller

Postby nieles » Sun Sep 23, 2012 8:50 am

hi walls99,

i would like to make a similar inertia dyno for some controller testing.

what material did you use for the flywheel? i would like to use MDF, but i am a little concerned with the centrifugal forces and the flywheel breaking.

very cool project btw!
nieles
1 kW
1 kW
 
Posts: 469
Joined: Mon Jul 14, 2008 5:39 pm
Location: The Netherlands

Re: Open Sensorless BLDC controller

Postby walls99 » Mon Sep 24, 2012 5:51 am

nieles wrote:hi walls99,

i would like to make a similar inertia dyno for some controller testing.

what material did you use for the flywheel? i would like to use MDF, but i am a little concerned with the centrifugal forces and the flywheel breaking.

very cool project btw!

Hi Nieles,
I used 16mm particle board, I'm sure MDF would be fine too, probably better from the balancing point of view. I wouldn't worry about the flywheel breaking but your motor mount! At speed >1000RPM I really had bad vibrations, as seen in the video due to the lack of balancing of my DIY flywheel.
So it was perfect for testing start-up, low speed and regen but not good for high speed testing for more than a few seconds.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open Sensorless BLDC controller

Postby casainho » Mon Sep 24, 2012 5:59 am

walls99, could you please tell me if you think the motor could work (with load, like on a bicycle wheel, starting from 0 velocity) only with current feed-back and not BEMF?

I got my motor running but without BEMF.



I made some simple but interesting tests.

With 15% duty-cycle and 10ms the motor were running very slow (about 12 RPMs, motor Cute85 for 20'' wheel). But I were using the variable power supply and I could change the power applied to motor by defining the voltage supply.

(Case 1) I found that with a lower voltage, like say 15V, the motor don't turn or vibrates/makes noise/small turns. (Case 2) If I rise slow the voltage it starts to turn up to a velocity which seems to be perfect (but slow due to the 10ms), no noise, no vibrations. But if I brake the motor with the hand, it starts to vibrate/make noise and stops...

(Case 3) Continuing, if I rise the voltage (without braking the motor with my hand) the motor starts vibrating/making noise again but this time rising also the current/power used!!! Then I tried to brake and it stopped to make noise/vibrations but the current still high. I had a bit difficult to brake and stop the motor. I rise again the voltage and keeping brake the motor, until I found I couldn't no more brake it!! it turns with strong power, no vibrations nor noise.
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 Sensorless BLDC controller

Postby walls99 » Mon Sep 24, 2012 7:53 am

casainho wrote:walls99, could you please tell me if you think the motor could work (with load, like on a bicycle wheel, starting from 0 velocity) only with current feed-back and not BEMF?

I got my motor running but without BEMF.

I made some simple but interesting tests.

With 15% duty-cycle and 10ms the motor were running very slow (about 12 RPMs, motor Cute85 for 20'' wheel). But I were using the variable power supply and I could change the power applied to motor by defining the voltage supply.

(Case 1) I found that with a lower voltage, like say 15V, the motor don't turn or vibrates/makes noise/small turns. (Case 2) If I rise slow the voltage it starts to turn up to a velocity which seems to be perfect (but slow due to the 10ms), no noise, no vibrations. But if I brake the motor with the hand, it starts to vibrate/make noise and stops...

(Case 3) Continuing, if I rise the voltage (without braking the motor with my hand) the motor starts vibrating/making noise again but this time rising also the current/power used!!! Then I tried to brake and it stopped to make noise/vibrations but the current still high. I had a bit difficult to brake and stop the motor. I rise again the voltage and keeping brake the motor, until I found I couldn't no more brake it!! it turns with strong power, no vibrations nor noise.


It looks like you are running in open loop, so this is the expected behaviour. This mode of operation is not really usable as you can't control timing or torque, however it's a good 1st step to understand brushless motor control :)
BEMF sensing/timing and close loop control is the logical next step but it's also more complicated. Using only current feedback is possible but a lot more complicated, see FOC theory.
User avatar
walls99
10 W
10 W
 
Posts: 96
Joined: Wed Mar 11, 2009 5:34 am
Location: UK

Re: Open Sensorless BLDC controller

Postby casainho » Tue Sep 25, 2012 7:47 am

walls99 wrote:It looks like you are running in open loop, so this is the expected behaviour. This mode of operation is not really usable as you can't control timing or torque, however it's a good 1st step to understand brushless motor control :)

Yes! I need to feel to understand.

walls99 wrote:BEMF sensing/timing and close loop control is the logical next step but it's also more complicated. Using only current feedback is possible but a lot more complicated, see FOC theory.

I would like to work on a robust start-up scheme. I read about yours (you shared before on this post) but my hardware lacks a current sensor, it just reads very high current value (probably the maximum current). Could you please share your thoughts about this system that don't reads current, only the maximum? how do you think it works? PLEASE see my controller schematic PDF and here more info about the controller.

Could you please share your thoughts about the BEMF circuit of this controller?

Since the controller don't have current sensor, I am thinking in trying to start-up the motor by making it rotate at slow and constant speed (10ms commutation in my motor) and going increase the duty-cycle up to get rotation/signal of BEMF. I must care about maximum current or I may miss the BEMF circuit but short-circuit the motor with maximum current/duty-cycle. What do you think about this idea?
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

PreviousNext

Return to Motor Technology

Who is online

Users browsing this forum: No registered users and 3 guests