BLDCs, the Wrong Way

Hall Sensor Boo Boo
The above is a set of scope traces from the three coils of a BLDC which is being commutated incorrectly. Read on.

The job that’s been paying my bills and keeping me away from artsy-fartsy circuits for the past six months involves making a set of these enormous robot doors for a Certain Very Fancy Person’s house. Each door is 13 feet tall, around 7 feet wide, and weighs 1500 pounds. There are 66 of them in said house, and more in the servant quarters(!?!). The circuits on board each door have to handle running an onboard air compressor (which regulates a pneumatic weatherseal) as well as keeping track of temperature to linearize the pressure sensors when the weather gets cold. They also have to charge and maintain sealed lead acid batteries. They have commutated power rails. They have to communicate over said power rails, and do so using an capacitively-coupled data slicer and a proprietary protocol I wrote. This protocol has to be robust enough to bootload the processor over. It’s a proper embedded systems job.

All this having been said, the great majority of the real estate on the PCB is dedicated to running the big BLDCs that make the doors move. This post is some observations particulars of said motors.

I’d run lots of standard DC motors in past, and built H-bridges galore, but this was my first encounter with BLDC driving. As such, I made some mistakes in the prototype. And I am going to lay those out for you, dear reader, such that you might learn from the fires of MY workbench.

The motors in question were Maxon EC-Max 30 series motors with a gearhead. They are small, powerful, and expensive. We decided to use BLDCs for this job primarily because of their size, but the fact that the reliability is generally greater (no brushes) than a standard brushed motor certainly was a bonus. The BLDC driver circuit needed to fit into the stile of this door, which was only 1.5″ wide or so. The motors could be expected to stall under certain conditions, so the motor drivers had to be more Conan than not.

Once that driver was designed and fabbed, the fun on the workbench began.

A quick BLDC review:
Brushless DC Motors are like normal DC motors — except the user has to handle commutating the motor on their own. This means, more or less, wrangling the electric fields in the motor at the right time such that the motor turns. A standard DC motor has a set of “brushes” (usually pieces of carbon) that squeeze against the moving part of the motor (the rotor). These are responsible for getting power from stationary part into the spinning part. As the rotor turns, the brush presses on the correct bit of the rotor to get the fields doing their thing. This is cool because it’s easy to drive and relatively simple mechanically. The BAD thing about it is that the graphite/carbon brush wears down over time, AND the brush-scrape nature of the contact makes a world of tiny electrical arcs inside the motor which look cool but kick off a ton of electrical noise (and audio noise, which in this case mattered).
In a BLDC, it’s YOUR job to energize a set of coils at the right time to keep the motor turning. There are three (usually) coils in the stationary part of a BLDC and a number of magnets in the rotor. The trick is to energize the right combination of coils such that you pull the right magnet to the right spot at the right time. If you do this, the motor turns smoothly. It’s a sort-of-not-really like timing a spark plug, if you’ve ever had to do that.
The trick is, you need to know WHERE the rotor is at any given time, such that you can know when to turn off the last set of coils and turn on the next set. There are lots of ways to do this, but a common one is with hall sensors which read the rotation of the motor shaft via some magnets on that shaft. These are usually conveniently built into the motor. In my case, they read with 60 degree resolution, which is plenty to keep the motor moving correctly. Often, either a piece of hardware or an ISR reads the hall sensors, and then energizes the correct coils. This whole process can be as simple as a look up table.

There are lots of documents on the internet about BLDCs, but there are relatively few about what happens with incorrect commutation. The interesting part is when you mess it up and try to figure out what went wrong.

First step, the datasheet: The Maxon datasheet more or less recommends that you buy the Maxon motor drivers and just be done with it. Our form factor, target budget, and my not-insignificant sense of pride ruled that out. It DOES have a commutation chart, but it’s pictorial and is not that clear about “active high / active low” and other minor details like that. So, I made some guesses and let her rip.

In the course of letting her rip, I saw all kinds of exciting (read: trainwreck) motor beahvior. I figured out how that Maxon ran, but I also made a handy set of rules of thumb about what BLDCs do when you drive them wrong. From this, I made some procedures with which I ought to be able to start out with any unknown three-phase BLDC with hall sensors and derive how to get the correct drive sequencing. It’s like this:

Observations:

1.) BLDCs _WILL_ turn with some combinations of incorrect drive. This can mislead the un-wary.

2.) BLDCs usually not turn if the commutation sequence is mixed up. I assumed this would always be the case. It isn’t.
When a BLDC has a commutation sequence which is out of order, usually you see it STOP at some position and lock up, drawing stall current. If you aren’t on a current limited supply, or your motor drivers are not like Conan, you may damage your drive section. This is because whatever coil you’ve energized is pulling the BLDC to the wrong place and then KEEPING it there, since another set of halls has not been triggered. This probably means you have your driving steps out of order (or are energizing the wrong combination of coils).

3.) The interesting part — the BLDC _WILL_ spin, maybe, if you have the commutation sequence right BUT offset from the hall sensors readings. Meaning, if you are always energizing your coils one step ahead of where they should be, the BLDC will pull the motor to the right spot, but it will draw a lot of power doing it AND you will not have very much torque. If this happens, you probably have your hall sequence right AND your commutation sequence right, BUT they are lined up incorrectly.

Corollary:

1.) If you aren’t sure what your hall sequence is, you can spin the motor with your fingers (or a wrench, or whatever) and read the correct order of hall transitions.
2.) If you aren’t sure what your commutation sequence is, you can try messing with the order of different valid coil combinations and running your motor OPEN LOOP. This means stepping through your coil combinations on a timer, energizing them, and seeing if the motor turns. It will turn with bad efficiency again, and probably draw a lot of current, but it will turn when you have the sequence right. Best to do this on a current limited supply.
3.) Once you have those two pieces of information, you can line them up and figure out the correct drive sequence. This sequence will be the one in which the motor spins with the greatest torque and the best efficiency in both directions (IE, it has to work when reversed, too).

An unexpected benefit of doing this is that you see all kinds of BLDC commutation problems. This is useful when you’re debugging a system later, and have to deal with broken wires or damaged drivers, and can guess symptoms much more easily.

Tags: , , ,

14 Responses to “BLDCs, the Wrong Way”

  1. BLDCs, the Wrong Way « adafruit industries blog Says:

    […] Nerdy Texts of Analog and Embedded Systems Wizardry » Blog Archive » BLDCs, the Wrong Way. The job that’s been paying my bills and keeping me away from artsy-fartsy circuits for the past six months involves making a set of these enormous robot doors for a Certain Very Fancy Person’s house. Each door is 13 feet tall, around 7 feet wide, and weighs 1500 pounds. There are 66 of them in said house, and more in the servant quarters(!?!). The circuits on board each door have to handle running an onboard air compressor (which regulates a pneumatic weatherseal) as well as keeping track of temperature to linearize the pressure sensors when the weather gets cold. They also have to charge and maintain sealed lead acid batteries. They have commutated power rails. They have to communicate over said power rails, and do so using an capacitively-coupled data slicer and a proprietary protocol I wrote. This protocol has to be robust enough to bootload the processor over. It’s a proper embedded systems job. […]

  2. The trials of working with brushless DC motors for the first time. - Hack a Day Says:

    […] are normally taken care of with the brushes. This article won’t teach you how, rather it will show you the mistakes one person made in his inaugural effort to use them. It is mildly amusing, but the project summary that he’s using them for seems even more […]

  3. Jordan Says:

    why wouldn’t you use some pneumatic pistons instead of motors to open the door(s!)?

  4. The trials of working with brushless DC motors for the first time. » Geko Geek Says:

    […] are normally taken care of with the brushes. This article won’t teach you how, rather it will show you the mistakes one person made in his inaugural effort to use them. It is mildly amusing, but the project summary that he’s using them for seems even more […]

  5. Denbo Says:

    Curious about the scope trace of the hall sensors in the pic above. What would it look like if they were properly commutated?

  6. TBailey Says:

    @Jordan —
    Good question. I think the mechanical guys were thinking of using Elephants at some point, but only if we could bring them across the Alps first.

  7. TBailey Says:

    @Denbo —
    Actually, I think I mislabeled those traces. Looking at them again, they’re almost certainly the traces taken directly off the BLDC coils. That explains the rise and fall times and the fact that the v/div shows something like 10V on the top two traces.
    And they wouldn’t look THAT different really. If you had your probes attached in a sensical way, you’d want to see the first coil go high, then the second, then the third — in that picture, it would be “right” if you moved the top trace to the middle. But, that’s just the position of the scope probes.
    Noteworthy on those traces are the dips in the middle of the top and bottom plateaus. That means that the voltage there is dropping when the next coil is switched on, which indicates a current spike. Depending on the supply you’re using and the motors, the magnitude of this spike can tell you a lot about losses in your system.

  8. Macona Says:

    Another way to figure out the commutation order on the halls is to apply current to one winding. The motor will then lock to one position. Read the states of the halls and move to the next position. Compumotor lists the process in more details in their drive manuals for people wanting to hook up motors from other manufacturers.

  9. JoLau Says:

    I’m interested of your door opener mechanism. How does it look like? How does it work? I ask because I want to implement a door opener in my room. Thanks.

  10. TBailey Says:

    @Macona —
    For sure. That, along with the Maxon manual, was how I figured out the commutation pattern initially. Good call.

    Do you have a link to those Compumotor manuals? I’d love to link them in here for other people trying to figure this stuff out. Thanks!

  11. TBailey Says:

    @JoLau–
    I’m afraid I can’t tell you about the opener mechanism. The project is NDA’d so I can’t talk specifics, which is why this post is so vague. But a good place to start is always http://www.mcmaster.com/# — do a search for openers and see what you can find. Even if the mechanism you want isn’t there, it’ll help narrow down the terminology which makes trolling the internet for what you want a lot easier.

  12. Eric Says:

    My favorite method of aligning commutation sequence and hall sequence it to compare the motor’s back EMF to the hall sensor outputs. (I’ve built a lot of BLDC and PMAC drives using poorly documented motors).

    Grab a scope with at least two inputs. Put one hall sensor’s output to scope channel 1 and the voltage between two of the motor leads (using a decent differential probe!) to channel 2.

    Then connect an electric drill to the motor shaft (a piece of garden hose and a couple of hose clamps works wonders) and spin. Observe which hall outputs correspond to the generated phase voltages and design your commutation sequence accordingly.

  13. David Says:

    [3.) The interesting part … you probably have your hall sequence right AND your commutation sequence right, BUT they are lined up incorrectly.]

    I am newbie to bldc motor and driver control.

    I have an eval-board motor driver whose hall-commutation sequence is 1 step (60 degree; ie. 612345) different from the motor’s hall-commutation sequence as provided by the manufacturer (ie. 123456).

    In this case, is the motor considered not operating correctly at all?

    If yes, is it mandatory to change the driver code to make it match 100%?
    I would assume the motor is operating correctly (ie. no extra power should be drawn), because the driver is just not energizing the coils in the same hall-sensor sector only (ie. not following a textbook example), but as long as the commutation-sequence is adhered to.

    I hope you understood my question, because I am just not clear if I need to:
    1) Change driver code to match motor hall-commute sequence?
    2) And/or, match hall sensor wire connection to driver input?
    3) And/or, match motor winding wire connection to driver output?

    Hope to hear from you. Cheers! =)

  14. TBailey Says:

    @David —
    So, the basic idea is that the hall sensors tell you when you are in the right place to energize a coil. Driving a motor correctly requires a.) correctly interpreting the hall sensors and b.) correctly updating the coil drivers when the hall sensors change.

    If you have the _order_ on the hall sensors correct, AND the _order_ of the coils correct but the two are slightly out of phase, you MAY still get the motor to turn. However, your coil drive will be effectively “leading” or “lagging” the position of the rotor. This usually gives you less torque, and will usually not start up about 1/6th of the time, and will sometimes have trouble reversing. It’s best to get this right.

    If you aren’t sure what changing various parameters will do, my recommendation is to hook everything up on the bench. Use a current limited supply so you won’t blow anything up, and try changing things. It will help you get a good intuition about how BLDCs work.

Leave a Reply