Wednesday, November 25, 2009

Everything You Ever Wanted to Know About Brushless Motors

I've been doing a lot of reading lately about brushless motors and their control. Every once in a while I find a good application note or paper or website that makes something clearer to me. (Other times, the information I find contradicts other things I've read or just makes things more confusing.) But just last week I stumbled across the single most consistent and thorough explanation of motors I have ever seen, a Master's thesis by James Mevey from Kansas State.

Make no mistake, this is not a quick read (355 pages), and it requires a basic background in electromagnetism, circuit theory, and electric machine theory. But I promise you that if you have at any point been frustrated by the inconsistent or incomplete treatment of electic motors found on the interwebs, or by the abstracted and overly complex theory in research papers and electric machine textbooks, this report is what you've been missing.

It's clear that the author put a tremendous amount of effort into this thesis, more than I can even comprehend.The explanations are clear, but not simplified. The notations are internally consistent and many (most?) variations found in other literature are explained and compared in tables, charts, and figures. Oh, the figures! They are all HAND DRAWN. And not like my hand drawn pictures.

Is that a jellyfish stuck inside an axial flux motor?

No, nothing like that. These have all the nice scale and readability of computer-generated graphics, but with the friendly this-isn't-as-complicated-as-it-sounds style of whiteboard sketches. Almost like a comic strip. About electric mtors. Look for yourself!

Anyway, I'm not telling you to read the whole thing (yes I am) but I did. In case you're busy watching football or eating Thanksgiving dinner (I will be, but I already read it), I can do a book review-style highlight of the most important concepts that I got out of it, without going into detail or ruining the ending.

1. Back EMF and torque are two sides of the same coin.
I sort-of knew this already. In a brushed motor, the back EMF constant (relating voltage produced at the open motor terminals to the speed of the motor) and the torque constant (relating torque produced to the current passing through the motor) are the same number. The simple explanation for this is that after all the electrico-magneto-mechanical interactions that happen inside the motor, the only thing that really matters is power conservation. Pushing current into a voltage (such as the back EMF) is positive power. This results in a positive torque (torque attempting to increase the speed of the motor).

The conversion is lossless.
All the losses are taken into account by adding resistors to the electrical model and/or damping to the mechanical model. So if you put 500 electrical Watts into the back EMF, you will get 500 mechanial Watts out. If you divide by the speed of the motor, this gives you the torque. This is always true. At zero speed, you can take the limit of this to find that torque is still proportional to current. For negative power (generating), you have to be pulling negative current out of a positive back EMF (or pushing positive current into a negative back EMF).

The simple DC motor model.

The thing made clear to me by James Mevey's thesis was that this model works just as well for a brushless DC motor. The power conservation through back EMF works the same way. You can prove this using a few different E&M and/or field theory tricks. (He does all of them, for good measure.) But intuitively it also makes sense that there needs to be something to push against, namely the back EMF, for power to be converted. In the limit as the back EMF and speed go to zero, torque is still proportional to current.

But, unlike a brushed DC motor, the shape of the back EMF of each phase of a brushless motor is a function of rotor position and is periodic. It repeats every two poles, so for a 14-pole motor like on the scooter, it repeats seven times per revoltion. This base shape then gets scaled by the speed. It's as if the back EMF "constant" for a given phase is actually a periodic function of the rotor position. That's sort-of obvious, but the less obvious conclusion is that, taking the limit of the power conversion through the back EMF as speed approaches zero, the torque "constant" is the same period function of rotor position. So another way to look at it is that the torque produced by each phase is simply the base shape of this same rotor position-dependent function multiplied by the current going into the phase. This is also always true.

2. None of the above changes for trapezoidal (BLDC) vs. sinusoidal (BLAC/PMSM) motors.
Just by applying the very simple power-conserving back EMF idea, you can analyze any motor with any drive. I was wondering about the functional differences between BLDC and BLAC/PMSM. James Mevey says:
"It is the author’s opinion that the difference between trap and sine BPMs is surrounded by more misunderstanding and confusion than any other subject in the field of brushless motor control..."
I am inclined to agree. But this thesis makes it very clear that the only functional difference is the shape of the waveforms (both the back EMF and the drive waveform). BLDC refers to motors with more-or-less trapezoidal back EMF, common in small motors. Like this:

From the scooter motors, line-to-line and assumed line-to-neutral.

Why is it trapezoidal? This is entirely due to the geometry of the motor. It has nothing to do with the controller, which should be obvious (although for some reason it's not) since this measurement can be made with nothing attached to the motor at all. It has to do with the layout of magnets and coils and steel. The more you can see sharp transitions in magnets, coils, or steel, the more trapezoidal it becomes. This is common in small motors because it's easier to make a motor with concentrated windings and discrete, non-skewed magnets.

As a counter-example, larger motors often called "brushless AC" or "permanent magnet AC" tend to have skewed magnets and overlapped windings in a large number of slots, so their back EMF looks more sinusoidal. These motors can (should) be driven with a pure AC signal. If, for example, the back EMF and current are both sine waves that are in phase, and there are three balanced phases separated by 120º electrical, the power (torque) produced will be constant. Try adding together three sin^2 waves (current times backEMF) shifted by 1/3 period each. Or have Wolfram Alpha do it for you. There is clearly an advantage to having constant torque in things like large machines, electric vehicles, etc.

But what about BLDC motors with trapezoidal back EMFs? Well, this is where things get more interesting. You can drive them with a signal that looks like a square wave, except with gaps where the trapezoid has non-zero slope. Like this:

Ignore the blips.

To the extent which you back EMF is truly a trapezoid with a 120º-wide top, you can split the drive into six equal-length segments, two positive, two negative, and two off. By doing so, you get zero current during the sloped part of the trapezoid and full current during the flat part. Multiplying back EMF by current still gives power (torque). Accounting for all three phases, offset by 1/3 period each, also gives constant power (torque). This is the basis of brushless DC motor control. It's very simple to implement in software or even just pure logic chips. Since it relies only on 60º position estimates, it can be easily accomplished with three hall-effect sensors or with many sensorless estimation methods.

If they are simpler to make and to control, but yet still give constant ripple-free power, why not make all brushless motors this way? Well, for one, the purely trapezoidal back EMF is not realistic. It may not be as flat, for as long, as the 120º approximation. Things tend to smooth out into sinusoids if you let them. Which brings up the next point: what happens when you account for inductance?


That's the same square-wave drive, but now with a reasonable inductance factored in. Permanent magnet motors tend to have low inductance in general, but even so it still distorts the shape of the drive current at even modest speeds. It's not even a clean low-pass filter. That's because the drive inverter has flyback diodes start to conduct current during the "off" period. And on top of all that, the whole thing is phase-shifted so that current and back EMF no longer line up perfectly. The net result is a power (torque) fluctuation. The good news is that the fluctuation is at six times the commutation frequency, and so at high speed the system inertia easily damps it out. The bad news is it's still significantly lower than the torque produced at zero speed, since the low pass filter takes power out of the harmonics and moves the whole thing out of phase with the back EMF. The other bad news is that the diode conduction in the controller can start to cause more heating in otherwise highly-efficient MOSFET drives.

There is an obvious benefit to using sinusoidal drive, then. Everything, after passing through a low-pass filter, gets closer to looking like a sine wave anyway. You can also eliminate the diode conduction periods which throw the whole analysis off. And if your motor is designed to have sinusoidal back EMF, everything works nicely and all that's left are magnitude and phase shifts. To the extent which a trapezoidal motor can be thought of as having a fundamental sinusoidal component, some of the analysis used in sinusoidal drive can also be applied to trapezoidal motors, understanding that there will be harmonic distortion. But everthing still works within the back EMF power conservation analysis method for figuring out torque.

3. Field-oriented control is all about keeping current and back EMF in phase.
There are a lot of complicated ways to explain it, but the one that makes the most sense to me is that the goal of field-oriented control is to make up for the phase lag that comes in at high speed when the inductance start to become significant. Obviously for induction motors, there is more to it. But for permanent magnet motors, it's as simple as keeping the two sine waves (or whatever waves) of the back EMF and the current in phase as much as possible. This produces maximum torque, for reasons that should be obvious from the power conservation approach I keep mentioning.

The back EMF in a permanent magnet motor is fixed to the rotor position, always. This was another point of confusion for me, namely when it comes to field weakening. But field weakening is a lot simpler than I thought. It does not change the back EMF. The back EMF comes from the rotor magnets alone. What field weakening does is produce another field that fights the magnets in the air gap, reducing the flux to some degree. But this is all accounted for already! It's the inductor in the circuit! It's really that simple. But it only really makes sense if you look at things from the rotor reference frame, often called the d-q frame. (d = direct = in line with the magnet flux, q = quadrature = leading the magnet flux by 90º electrical). In this frame, there are only a few simple rules:
  • Back EMF leads magnet flux by 90º. That is, it is always on the q-axis.
  • Voltage leads current by some amount determined by the motor inductance and resistance.
  • Torque is proportional to the amount of current in phase with back EMF, i.e. the dot product.
What this looks like for a few different cases:


The first case is what things look like when the motor is spun up with no load. The voltage on the terminals (whether you apply it or not) is equal in magnitude to and in phase with the back EMF, which leads the magnets by 90 electrical degrees. (Keep in mind this whole picture is in electrical degrees, so you have to divide by the number of pole pairs to get the mechanical equivalent.) The second case is what happens when a load is applied to the motor without changing the relative position of the voltage. This would be like a simple hall-sensor or encoder based commutation that always fires the phases at the same position.,i.e. open-loop control. The problem is that at high speeds, current goes out of phase with back EMF, since some voltage is developed across the low pass filter. The sum of back EMF, voltage on the inductor, and voltage on the resistor is still equal to the voltage applied at the terminals, but this is a vector sum so things get tricky.


Now here are two cases where the relative phase of voltage can be controlled (advanced). For demonstration purposes, this could be done by physically rotating the position sensor on the motor. Obviously for control, it would instead be done by adding some phase offset in software. The left-most case is field-oriented torque control. The voltage is advanced to make up for the current lagging behind it. The net result is current in phase with back EMF, the theme of this story, and ideal torque. The right-most case is what happens when you advance the voltage even more. Now, current goes out of phase the other way, so some torque is lost. But, the other components of voltage rotate out of the way a little, allowing the back EMF (speed) to grow without increasing the voltage applied. This is field weakening. You trade off torque for a bit more speed. The back EMF could even be higher than the voltage applied, extending the speed range of the motor without increasing the DC supply voltage. How much of this you can get away with depends on the inductance of the motor. Generally, surface-mounted magnet motors have low inductance and limited field-weakening capability. But "limited' might still mean you can get 50% or 100% more speed!

To some extent, I knew this already. But the great thing about seeing it consistently presented is that I now understand why it works. And even more cool, I see that it's all part of the same, simple model. Everything is accounted for without even diving into the magnetic domain. You just measure back EMF, draw some triangles, and come up with the performance of the motor. It's all become simpler to comprehend because it fits into a minimalist model.

Now I have some more solid footing to stand on for the full-AC version of my controller. I can start thinking about field-oriented control, how it will interact with different motors (trapezoidal, sinusoidal) at different speeds, etc. I guess at heart I am more interested in motor control than in motors themselves, but as I can see now you can't understand one without the other!

READ IT! Here's the link again.

31 comments:

  1. thx for great link to Mevey's thesis! you are right - definitely a great compilation of all the works giving insight in el. machines - I like Fig. 2.27 !!

    ReplyDelete
  2. Hi,

    maybe I'm not smart enough! but how do you relate the d-q frame vectors to V, I and rpm measurements made with a wattmeter and a tachometer on a brushless motor ?
    "Popular litterature" seems to ignore or minimize inductance, armature resistance being seen has the only source of losses.

    ReplyDelete
  3. V and I measured by a wattmeter would probably be DC input voltage and current. If the controller were 100% efficient, then (V_dc*I_dc) would be equal to K*(V_d*I_d + V_q*I_q) where K depends on whether I_d/V_d and I_q/V_q are RMS or peak quantities. (Whatever value is required for power conservation to hold.)

    I agree most simple explanations ignore inductance, which is a mistake for BLDC motors. Maybe it's a reasonable assumption at low speed or for motors with very low inductance like coreless motors. The description of torque production in Mevey's thesis does a very good job of showing the effects of inductance.

    ReplyDelete
  4. Thanks a lot, Mevey's thesis make it obvious, but doxa is heavy to move, thanks!!

    ReplyDelete
  5. Sorry, I hope you don't mind spending a little of your time answering my question, this is very confusing for me. I have to deal with finding torque from simple DC values and rotational speed.

    What happens, in the ideal case, when I_d comes to zero? Is that so simple that back emf = V_dc - I_dc*R?

    I would have thought from your F.O.C. example that it still needs something like a voltage drop proportional to I.w (w = rotational frequency).

    This is what I seem to see, but can't explain it: back emf = U_dc - I_dc.(R + k.w).

    ReplyDelete
  6. Maybe the missing term might have to do with the controller converting from higher voltage / lower current DC input to lower voltage / higher current motor phase AC output. The relationship between I_dc and I_q depends on the duty cycle, which depends on the speed.

    ReplyDelete
  7. Well, that's something I haven't thought of, but maybe I can explain the thing with my simple words.

    This is how I understand it: on the F.O.C. picture, current being kept constant, if w is increased, then the length of the V_L vector should increase, the voltage vector (the green one) should move to the left and its length should also be increased ?

    I'm computing power consumption of small propellers from DC voltage/current and rpm measurements, in a wind tunnel. I can't have torque from direct measurements. So I have made a math model of the motor that computes torque, it works very well but I just can't explain why R is not constant! that's quite embarrassing...

    Thanks for your patience.

    ReplyDelete
  8. What type of controller are you using to drive the propellers? (Is itimplementing field-oriented control or is it six-step BLDC?)

    ReplyDelete
  9. It's just a cheap RC brushless controller, six-step BLDC.

    The model I use for the motor is very simple,
    V = Ke*w + I.R

    From my data (and from many others), R is then in very close linear relation with w. That's why I thought there was in fact a resistive and an inductive component. But many people told me to forget about inductive effects.

    (you shouldn't put tape on only one blade of your props, this might ruined the bearings and prop efficiency, vibrations...)

    ReplyDelete
  10. Interesting, then it could be an effect of inductance. If the ESC uses "fixed" timing, the current may go out of phase with back EMF at high speeds. That is one of the effects that F.O.C. tries to minimize. Do you have a graph of data? Also can you try different timing settings on the ESC and see how it affects the data?

    The tape is for balancing the props. :P They are horribly out of balance from the factory. I use yellow to make the edge more visible, but mostly it's to balance them.

    ReplyDelete
  11. I've made some tests as you suggested, you can find it here:

    http://g.rouby.free.fr/timing_test.htm

    Interesting experiment !

    ReplyDelete
  12. Interesting results. I thought of another possibility: At high speeds, the diode commutation period is longer (when the phase turns off and the inductance causes current to keep flowing through the MOSFET body diode). That is more "lossy" than commutation through the FET itself because of the diode drop, so maybe when that is averaged it it looks like a resistance that increases with speed.

    ReplyDelete
  13. Ok,in fact there is probably several reasons I guess!
    I was very surprised by the "constant" variations, the way I find it is probably too simplistic.
    Thanks again, this is a great blog, I'll keep watching...

    ReplyDelete
  14. Ok would you please help me with the concept of back emf. Actually I wanted to.know whether the machine tries to maintain its back emf constant? if yes then why

    ReplyDelete
    Replies
    1. The back EMF constant [V/(rad/s)] is determined by motor geometry, magnet strength, winding configuration, and to some extent the way the motor is driven. (For brushed motors it can depend on the brush timing, for BLDC or PMAC it can depend on the phase of the driving voltage.) The constant might change slightly as a function of load or speed, but for the most part it's considered to be a fixed number for DC or BLDC motors or surface PMAC motors.

      As for whether the motor tries to maintain its back EMF: I would say it does, but only due to the inertia of the rotor and load. Mechanically, the inertia will try to keep spinning, and the rotation will continue to create a back EMF.

      Delete
  15. What is the L value in IwL? Is it phase to phase?

    ReplyDelete
    Replies
    1. It's the synchronous inductance. Appendix B of James Mevey's thesis has a good explanation of what it is and how it's related to phase-to-phase inductance.

      Delete
  16. I was reading an app note (Atmel AVR448) that says
    "There are [three common methods to control 3 phase motors using a MCU] : Trapezoidal, Sine Wave, and direct Torque control."

    I understand that depending on the stator windings and how current is driven to the stators, it will have either trap or sine emf.. but what is the 'direct torque control' (DTC) method ?

    According to the wiki, DTC is vector control (as opposed to Scalar control) and is an alternative to FOC, which I *thought* was only for AC induction (async) motors. Can FOC be used on BLDC/PTSM? How does DTC differ from Trap/Sine in implementation?

    Does anyone knows of a better block diagram than this one, that lists how all this fits together?
    http://en.wikipedia.org/wiki/Direct_torque_control

    ReplyDelete
    Replies
    1. I sort-of disagree with the classification system of both the Atmel note and the Wikipedia article. In my mind, your understanding is correct - the "trapezoidal" vs. "sinusoidal" has more to do with the shape of the motor's back EMF. Trapezoidal back EMF lends itself to being driven by square wave currents (BLDC). Sinsuoidal back EMF lends itself to being driven by sine wave currents (FOC).

      You can definitely use FOC on a permanent magnet motor. It's more well-suited to ones with sinusoidal back EMF, but it can also be used on ones with more trapezoidal back EMF with some of the same benefits.

      I consider both FOC and DTC to be vector control and I think SVM is a technique that can be used by both. FOC operates in the rotor frame of reference, so it requires a method for estimating the rotor position. One of the big benefits of the rotor frame is that the important variables are DC quantities, so you can filter the crap out of them without introducing lag. DTC operates in the stator frame of reference, using phase voltage and current to estimate torque and flux directly without any transformations into the rotating frame, and select voltage vectors to increase or decrease the torque and flux as needed. So the switching isn't periodic...it's hysteresis-based.

      I was looking around for a good explanation of Direct Torque Control and I think my favorite is this: http://www.texample.net/media/tikz/examples/PNG/ac-drive-dtc.png. It explains it better than I can in words.

      Delete
  17. Hi !

    thanks for the great tutorial !

    i have small issue that i would be happy if you can please advise me about:

    i am trying to implement a positioning algorithm with direct drive brushless motor - using pwm duty_cycle sine array (commutation each phase with 120 offset), if i command the motor to hold a certain position and then try to move it with my hand - i fill (as expected) the motor resistance to my movement is bigger as the rotor is shifting from the original commanded position (off course in some point the rotor moves to same position but with 360 electrical degrees shift).

    what i dont understand is why the current values dosent change - as the motor tourqe is growing much bigger as i move it away from its command position?





    ReplyDelete
    Replies
    1. It's a good question and fundamental to understanding torque generation in this type of motor! One way to answer would be to say that the torque is only proportional to current if the phase of the current is fixed with respect to the phase of the rotor flux (i.e. the position of the magnets). In this case you are driving current at a fixed phase and rotating the magnets, so the constant of proportionality is changing. The maximum torque per amp is at 90º to the rotor flux, for surface permanent magnet motors. After this point the torque decreases and then, as you mention, reverses and force the rotor to a new location 360º away from the start.

      Another way to answer is that the current must stay the same, since the voltage is fixed and the back EMF is very small. The motor looks like a resistor in that condition, and most of the power is going into heat in the winding. When the motor is spinning, power conservation dictates that more torque needs more current. But at zero speed the power out is zero, so the power in is only feeding the resistance.

      Hope that helps!

      Delete
  18. Hi !

    I'm back 4 years later with another question !

    I'm involved into a software project for RC plane / UAV power system optimization. I have made some torque measurements on a off the shelf RC plane outrunner motor with its ESC in "high timing" and "low timing" mode.
    The measurements were made at full throttle with various propellers under various applied voltages.
    RPM and input voltage and current were also recorded.
    From delta amps / delta torque I could compute KT, which I suppose = KE. From RPM and KE I then find a value for the bEMF, and then R from the simple motor model using bEMF = U - R.I.
    I find a little higher value of KE in "low timing" mode than in "high timing" (84.5 vs 86.8 red/s/V), as expected I guess.
    But what I didn't expect is the high variations of the computed R in "high timing" mode, and its low value (with the lighter propeller, the computed R is even lower than the measured winding resistance ! 0.12 ohms vs 0.2 ohms measured).
    I keep thinking about what you wrote about the bEMF that can be higher than the applied voltage with field weakening... in this case this would lead to a negative computed R when using the simple motor model isn't it ?
    Could the use of the "high timing" mode lead to something somewhat similar with RC motors ? showing a R lower than the winding resistance ?
    This is all a bit confusing for me !
    Thanks a lot for your help !

    Guillaume

    ReplyDelete
    Replies
    1. Interesting. I suppose the timing could change the computed value of resistance in that way. Fixed voltage, advance the timing, the motor gets faster. For sine drive motors it's easier to figure out because you can represent the entire thing as a triangle with U as the hypotenuse and E+R*I as one side. Not sure how it looks exactly for BLDC but it's conceivable that in some cases the estimated R appears lower than the true R.

      One question: You said you are measuring input voltage and current - does that mean input to the motor (output from the ESC) or input to the ESC (output from the battery or power supply)? Or, if you're at full-throttle on the ESC it wouldn't matter since they'd be the same.

      Delete
    2. Thanks for the answer ! The input voltage and current are measured via a logger eagle tree (I checked the values against other meters), so it is measured between battery and ESC, at full throttle.

      This shows the difficulty of using the specifications of off the shelf motors with the classical motor model ( RPM = KV x (U - R.I) ), in order to find a motor/propeller combo able to reach the required performances...

      Delete
  19. Hi!

    Thanks for the interesting post! I am just wondering is it possible to run a BLDC with sinusoidal back EMF with a square wave PWM (the method which is used to run a trapezoidal back EMF motor).

    I just need the motor to spin for a university project very urgently. It is a 3-phase 250W 36V BLDC. We are running a launchpad from TI F28069M as the micro and the DRV8301 as the driver chip. We don't have enough time to set up code for a sinusoidal wave method. Im not concerned about any efficiency or speed factors just need to spin one way or another!

    Thanks!

    ReplyDelete
    Replies
    1. Certainly. You can make a motor spin with just about any periodic waveform. It's hard to make it not spin if the voltages are periodic and roughly 120º apart!

      Delete
  20. Hi Shane.
    I just discovered your blog and I am amazed by the quality of this article. Thanks a lot! Thanks as well for the link to James Mevey's thesis. You two guys have cleared a lot of things for me (yet, I still want to read James's report... I only had time to go through it quickly so far).

    I have one question that may be quite a basic one... but I could not figure out the answer by myself. Here it is.
    * I have a motor which is known to be BLDC (this is the way it is called by my supplier). The only electrical characteristic I have is a plot of current vs. time. From this chart, I think back EMF is trapeze-shaped (I supposed so, since current waveform is trapezoidal-style).
    * This motor heats up and we are figuring out a way to cut down the heating.
    * I am submitted another motor of the same kind (though no name such as "BDLC" has been stated). It is supposed to show less self heating. The current waveform is sine-type.

    In my understanding, the first motor heats up more than the second one, due to its tendency to go to sine-shaped back EMF, instead of pure trapezoidal one. Is this the right explanation ? That would explain why the second motor does not self heat as much as the first one...

    Thanks for your help! I am puzzled right now... :)

    ReplyDelete
    Replies
    1. Thanks for the kind words!

      There are too many reasons why one motor might dissipate more heat than another that it would be hard to say it's due to the back-EMF shape (which is not necessarily the same as the current waveform shape). If you have the current waveform of both motors, though, you can estimate the resistive heating by integrating I^2*R for each phase over one electrical cycle. That's not the only possible source of heat dissipation, but it's usually the biggest. Eddy current and bearing losses are probably the next two biggest.

      Sometimes BLDC control has more current ripple as well, due to diode commutation in the "off" phase. This will be accounted for by integrating I^2*R though.

      Hope that helps!

      Delete
  21. Hi Shane,
    I am currently working with a BLDC motor. What I'd like to know is about the Hall-effect sensors implemented in the motor. Is it possible to calculate the resolution of the sensors? Have you written an article about Hall effect or do you have any ideas that can help me?
    Thanks.

    ReplyDelete