high power/high speed BLDC controller build

dirty_d

10 kW
Joined
Jun 16, 2007
Messages
985
Location
Massachusetts
i just ordered one of those 130kV 6.5kW motors from hobbycity to replace my poor melted MY1020 motor that my brushed controller killed. i could buy a beefy R/C ESC, but i think it would be more fun and cheaper to make one. also i think most of the rc controllers use a low PWM freq like 8khz, im pretty sure that will make a loud audible sound because when i first programmed my brushed controller i used 10khz pwm by mistake and it was loud as hell like a speaker, 20khz was silent.

i got a pretty good idea of what im going to do, ill use a ATMega168 at 20MHz to control the whole thing, ill only need one PWM output and i will use 6 AND gates controlled by 6 of the general purpose I/O pins to route the PWM signal to the correct high and low side fet's driver. ill need 6 because im going to apply the same signal to both the high and low side, the only way i can measure the backemf during the PWM off time is if the low side fet is also off, not just the high one. i need to get backemf information all the time because of the commutation speed of the motor im using, there is only 278us where each phase is floating to measure backemf. the ADC would only be able to take 4 samples in this time period at full resolution, thats nowhere near good enough. what im going to do is use is 3 analog comparators that compare each phase voltage with half the voltage across the other two phases. this will work during PWM on and off time but with some noise that needs filtering, the three signals will be the same as 120degree hall sensors except 30 degrees in advance. the signals will go to 3 different interrupt enabled pins, when the signal changes from low to high or high to low an interrupt routine will be called that will doublecheck the state of all three pins then set a timer up to trigger an interrupt when the commutation should occur. the timed interrupt will use a lookup-table to change the two on of four off AND gates to energize the correct phases, it could also doublecheck the states of the 3 signal pins again to make sure the interrupt wasnt triggered by PWM noise.

theres a lot of stuff to do there in a very short amount of time(278us), so id have to prioritize things. the most important i think would be the commutation timing, so it would use interrupts and everything else would be done in the spare time(throttle sampling, current sampling and limiting), current limiting is also very important, but i could have something like an emergency current limit enforced by analog circuitry, if it goes over it a comparator will pull down the PWM output of the MCU and turn off all the fets.

what do you all think? does it make sense?
 
youre making a brushless one right, not brushed? i thought about the dead time issue but i dont think i will need any, the bottom fet under the one that was on last is never one of the next ones to turn on so i dont think you can have any shoot through, i might be mistaken though, im gonna look into that more. i would need dead time if i did complementary switching like i did on my brushed controller to reduce freewheeling losses, but i dont think im going to have enough spare processing time for that. actually maybe i can pull it off somehow with more AND gates or soemthing.
 
Sounds like a really good project - just what these RC motors need for EV use. I'll be watching closely to see how it works out.

I'm seriously thinking about doing something similar, but cheating by using the core logic from a relatively cheap, low voltage, RC controller. It looks like adding a new power board, complete with voltage regulator for the salvaged RC controller logic board, might be an easier way to go. Looking at the RC controllers they seem to be built for this, with modular construction that separates the control board from the power boards.

Jeremy
 
Did you check out AVR444 application note (Sensorless control of 3-phase brushless DC motors) on Atmel's site?
 
yea ive read about 10 different appnotes like that from different companies, although none were for high speed motors like this so most just used ADC sampling to detect zero crossing. one of the atmel appnotes had the analog comparators in it thats where i got the idea. the one thing im worried about is the pwm noise causing noise in the comparator outputs, i think if i low pass filter the inputs and set up the comparator as a schmitt trigger, it might have a stable output, or maybe just low pass filter the inputs and the outputs as long as the amplitude of the noise isnt enough to cause a state change, it should be fine, and if duration of the noise is less than the time of one processor clock period it will also be fine. all i know is if it doesnt work right the first time im gonna have a hard time getting it to work without a scope.
 
>i need to get backemf information all the time

Are you doing pedal-first or are you going to try the blind-spin-and-capture thing?

>ill use a ATMega168 at 20MHz to control the whole thing, ill only need one PWM
>output and i will use 6 AND gates controlled by 6 of the general purpose I/O pins
>to route the PWM signal to the correct high and low side fet's driver.

Might want to consider the dsPIC30F2020. It has 4 motor PWM channels (you only need 3) and has programmable PWM duty cycle top and bottom, dead time generation, on-board current limiting (so you can do current mode control instead of straight PWM) onboard oscillator, analog comparators, D/A for reference generation, 1MHz A/D converter, extra standard PWM output, serial, CAN and I2C output etc.

>but i could have something like an emergency current limit enforced by analog circuitry,
>if it goes over it a comparator will pull down the PWM output of the MCU and turn off all the fets.

One of the cool things about the 2020 is that it has four analog ins that go to a high speed comparator with a programmable reference on the other side. That can be internally routed to the "fault" signal in the PWM block; that shuts everything down (puts it into a preprogrammed state.) You can also drive the fault pin externally.
 
Just to add another flavour to this, my Tower Pro 5330 motor arrived yesterday from Hobby City (three days from order to my doorstep, from China to the UK - impressive!). I've just taken one apart (dead easy) and it looks extremely simple to add three small Hall sensors to it. This would allow the use of a beefed-up controller like the Infineon, plus may well make a home-built design simpler with regard to the start up algorithm.

For info, the Tower Pro 5330 has fourteen magnets (7 pole pairs) and twelve stator windings. My simple logic tell me that if I fit three Hall sensors between adjacent stator poles (small ones will "just" fit) then I should have 120 degree timing as required for most simple controllers.

Good luck with this controller build, I'll be watching with interest. If the Hall sensor mod looks viable I'll start another thread so this can stay as your build thread.

Jeremy
 
well im already really famaliar with the avr mcus and ive heard that there are problems with the C compiler for the PICs, im not really willing to learn how to do everything in assembly right now. also 20000rpm with 2 poles is 333Hz commutation speed, i think the motor im getting is 12 pole at 6000rpm, thats 600Hz commutation speed. i can still do everything i want with this AVR including the current throttle, the analog current limit i was talking about is just a failsafe incase somethign goes wrong. i really dont know how many poles that motor has so im just using 12 poles as a worst case. right now im just thinking about how im going to do the power stuff, i think im gonna use some copper bars or rods to mount the fets on off of the pcb.

yea if i can fit hall sensors in the motor im getting im going to do it, but ill also still try the sensorless stuff to see how it works.
 
Jeremy, hmm im not sure about that, i think the hall sensors need to be spaced at a multiple of 8.571 degrees 360 / (7 * 6), 8.571 mecahnical degrees will be 120 electrical degrees. 12 stator poles and 14 magnet poles seems like a weird combination though 8.571 degrees isnt an even multiple of the angle between stator teeth(30 degrees), so im not sure where you would center the three hall sensors. if you have like 3 stator teeth and 4 poles you get nice numbers, 3 / 4 = 0.75, 120 degrees between stator teeth and 30 degrees between commutation points, 120 / 30 = 4.0, it works out like that for a lot of combinations, but with 14 magnets and 12 teeth its wierd, im not sure how you figure it out.
 
dirty_d said:
well im already really famaliar with the avr mcus and ive heard that there are problems with the C compiler for the PICs

I've had no problems with the CCS line of compilers; they've worked pretty well on parts from the tiny stuff (the 12F) up to the big boys (dsPIC33F.)


right now im just thinking about how im going to do the power stuff, i think im gonna use some copper bars or rods to mount the fets on off of the pcb.

How are you planning to drive the FETs? The IR2110 line is pretty common; I've also had good luck with the LTC4444's, depending on max voltage.

yea if i can fit hall sensors in the motor im getting im going to do it, but ill also still try the sensorless stuff to see how it works.

If you do end up considering the PIC line, there's code written already for both sensored and sensorless control of BLDC motors. It's in their app notes. They also have a motor control board (picdem MC LV) that already has FETS, drivers etc populated; good for SW development. (Note - not trying to push you away from the AVR, I've just been working with a lot of PIC stuff lately and it's worked out well.)
 
dirty_d said:
Jeremy, hmm im not sure about that, i think the hall sensors need to be spaced at a multiple of 8.571 degrees 360 / (7 * 6), 8.571 mecahnical degrees will be 120 electrical degrees. 12 stator poles and 14 magnet poles seems like a weird combination though 8.571 degrees isnt an even multiple of the angle between stator teeth(30 degrees), so im not sure where you would center the three hall sensors. if you have like 3 stator teeth and 4 poles you get nice numbers, 3 / 4 = 0.75, 120 degrees between stator teeth and 30 degrees between commutation points, 120 / 30 = 4.0, it works out like that for a lot of combinations, but with 14 magnets and 12 teeth its wierd, im not sure how you figure it out.

Can't say that I can get my head around it, either, but from what I've read quite a lot of these RC motors are built with fourteen magnets and twelve stator segments. There must be something somewhere around the web that explains this relationship simply and clearly, but I've yet to find it...........

Jeremy
 
i did a little test with my avr, in the datasheet it says the highest ADC clock you should use is 200khz for maximum accuracy, but in another atmel appnote i read that you can go up to 1mhz without siginificant loss in resolution, so i tried it, it was just as accurate as 200khz as far as my multimeter could tell, so i tried 4mhz, even then the result was within 0.01V for a 0-5V reading, thats about 308,000 samples per second, so i could just use the ADC for zero cross detection, but i still think the analog comparators will be more accurate, all it takes is a LM339 and some resistors and capacitors. one of the problems ive been thinking about when using just the ADC to watch for the next zero crossing is that you dont know the state of all three of the phase voltages at the same time, so if you get a false zero crossing it will send your commutation sequence all out of wack since youre just waiting for the next zero crossing to advance to the next commutation step, not looking at the state of each phase backemf at the same time and choosing the correct commutation step. if i use the comparators and interrupts then when an interrupt is triggered i can get the state of all 3 comparators in one operation, and still have time to doublecheck that it wasnt an interrupt just generated by noise by checking the status of the pins a few times and making sure i get the same results each time.

billvon, i used an ir2011 driver on my brushed controller, for this i think i might use an irs2186, they can output 4A so i could use more fets if i had to and still be able to drive the gate capacitance fast enough. im gonna take a look at that LTC4444, maybe its cheaper than the irs2186, they are like $4 each. one mistake i think i made in my brushed controller was connecting the COM pin on the ir2011 to my control circuitry ground, i think i was supposed to connect it directly to the low side mosfet's source pins, i imagine there was a lot of inductance added to the drive circuit since it had to go all the way through the ground trace. in the functional diagram there is a level shift on the low side input, so im thinking i really was supposed to connect COM to the source.
 
Jeremy Harris said:
For info, the Tower Pro 5330 has fourteen magnets (7 pole pairs) and twelve stator windings. My simple logic tell me that if I fit three Hall sensors between adjacent stator poles (small ones will "just" fit) then I should have 120 degree timing as required for most simple controllers.

Jeremy

For fourteen magnets (7 pole pairs) and twelve stator windings.
7 pole pairs = 360 x 7 = 2520 elect deg
1 stator pole = 360 x 7 / 12 = 210 elect deg

(a) Spacing Hall sensors across 1 stator pole = 210 elect deg
210 deg : 0 : -210 deg
It is not possible to obtain 120 deg spacing (even if you try to invert one or two of the Hall sensors).

(b) Spacing Hall sensors across 2 stator poles = 210 x2 = 420 elect deg
420 deg : 0 : -420 deg

Note that 420 deg is same as 60 deg;
and -420 deg is same as -60 deg.

This means that you have 60 deg spacing.
60 deg : 0: -60 deg.

Inverting the Hall sensors at 60 deg and -60 deg, you will have an effective 120 deg spacing.
-120 deg : 0 : 120 deg.

(c) Spacing Hall sensors across 4 stator poles = 210 x 4 = 840 elect deg
840 deg : 0 : -840 deg

Note that 840 deg = 120 deg;
and -840 deg = -120 deg

This means that you have an 120 deg spacing.
120 deg : 0 : -120 deg

Now you could use case (a) and (b) to obtain an effective 120 deg spacing.
 
The7,

Many thanks for that. You've neatly summed up in one post stuff that I've spent hours trying to find using Google!

Do you think it would be OK to fit the sensors in the gaps between the pole pieces or should I mill out grooves in the stator to accept them?

Jeremy
 
Jeremy Harris said:
The7,

Many thanks for that. You've neatly summed up in one post stuff that I've spent hours trying to find using Google!

Do you think it would be OK to fit the sensors in the gaps between the pole pieces or should I mill out grooves in the stator to accept them?

Jeremy

From some previous posts, both methods seem to work as well as the other.
 
Are the sensors not affected by the changing field of the windings?


Very interested to see how this turns out. I have wondered how easy it would be to fit sensors into an outrunner for a while.
 
Looks like I may be in line for the next "fried guinea pig" award then, as soon as I get a controller built to check out this mod.................

Jeremy
 
ive done a little thinking and i think what ill try first is the ADC only zc detection method since its the physically simplest and cheapest approach. the reason i didnt want to do this before is that at maximum motor speed there is only going to be about 278 microseconds(at 6000rpm and 12 magnets) where the unpowered phase is floating, and if i take an adc sample in the middle of the pwm on or off period ill only get 5.5 samples, i wasnt satisfied with that amount of resolution, but i realised i can just store the last ADC value and the adc value that was at or after the zero cross point and just interpolate the time that the exact zero crossing took place, then just adjust the commutation timer delay accordingly. i could also sample all the time at high frequency using a virtual neutral point as the ADC Vref instead of 1/2Vcc. i hope this motor doesnt have more than 12 poles, i emailed the manufacturer but i havent got a response.
 
johnrobholmes said:
Are the sensors not affected by the changing field of the windings?


Very interested to see how this turns out. I have wondered how easy it would be to fit sensors into an outrunner for a while.

Seems like they'd have to if the current was high enough. One thing is they are oriented so that the flux going from one stator tooth to the next will be 90 deg. to their sensitive direction. The other thing is the flux from the permanent magnets is really high, so I don't think the current ever gets high enough to overpower them.

If the sensors were mounted off to the side of the magnet ring, then it could be a problem.
 
Back
Top