LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

This page will describe how to set up EMC2 to drive brushless DC motors ( BLDC ). These are also known as Permanent Magnet AC motors ( PMAC ), AC Servo motors and Electronically Commutated motors


A conventional DC motor consists of a set of coils which rotate inside a set of permanent magnets. The coils connect to a current source through a commutator on the motor shaft, and as the motor rotates the direction of current flow in the coil automatically reverses to keep the motor spinning.

A brushless motor uses the same principle, however the coils remain stationary, and the magnets rotate. The motors used on machine tools generally have the magnets rotating inside the coil laminations, but in some applications it is common to have the magnets rotating outside the coil. The two layouts are sometimes termed "inrunner" and "outrunner". The outrunner style can produce a great deal of torque for the motor volume, simply because the magnetic forces are working at the maximum possible radius. The drawback of the outrunner style is that coil cooling is more difficult. The most common use for outrunner motors is in model aircraft, where the airflow from the propellor produces adequate cooling. In both configurations the motor output shaft is fixed to, and rotates with, the magnets.

Brushless motors are almost always three-phase machines, which in practical terms means that they have three power wires. These are generally referred to as phases A B and C, or sometimes U V and W. The phases are linked together internally such that connecting A to a positive voltage and B to ground (or any lower or negative voltage) will produce a current flow into the A phase and out of the B phase. The A phase is wrapped around a set of soft iron laminated poles inside the motor, the B phase round a separate set, and the C round a third set. The A to B current will thus produce a North magnetic charge on the A poles, and a South magnetic charge on the B poles. (In practice depending on how the motor is built, it could be the opposite way round). A two-pole motor would have one pole piece for each phase, and a single North and South pole on the permanent magnet rotor. Motors generally have 4, 6 or 8 poles, meaning that the magnetic rotor has two Norths and two Souths, three of each or 4 of each respectively.

Trapezoidal Commutation:

The combination of three electro-magnets and 2 permanent magnets means that it is possible to always keep the rotor "chasing" the electromagnet poles as long as the phases are excited in the right sequence, for example

 A->B (and repeat)

This pattern is fixed, there is no other way to do it other than the reverse pattern, which runs the motor the other way (but see Sinusoidal Commutation later) and has the helpful feature for three-phase H-bridge drives that no phase ever switches directly from Positive to Negative without being Off in the interim, limiting the danger of what is called "Shoot Through" where both high-side and low-side drivers devices are "On" at the same time, short-circuiting the bridge with expensive results.

In a conventional DC motor the correct sequencing of the phases happens automatically due to the action of the commutator. With a brushless motor there is no commutator, and so the phases are switched on and of by external electronic circuitry in the drive. To make this possible the drive needs to know the rotor position, so that the correct combination of the 6 possible current paths described above can be driven. This requires some form of position feedback from the motor to the drive. This is often accomplished by using three Hall sensors ( http://en.wikipedia.org/wiki/Hall_effect ). These are arranged around the motor in such a way that the rotor magnets turn them on in six different combinations to indicate 6 different rotor positions, corresponding to the 6 current flow patterns. To run the motor in the reverse direction it is necessary to reverse the current flow.

A good animation of a 2-pole, trapezoidally-commutated, inrunner brushless motor can be found here: http://www.townbiz.com/animations/2-pole_bldc.html I suggest single stepping through the animation, watching how the 3 hall signals change the 6 high/low bridge driver switches, and how the poles alternately pull and push the rotor. Then come back to this page, read it, and possibly go back to the animation.

Reference works, online and paper, will generally describe this system in such a way as to suggest that there is only one Hall sensor pattern which describes unambiguous rotor angular positions and matches one phase current pattern each. In practice there is no universally accepted convention for where zero rotor degrees is and there are a number of possible ways to arrange the hall sensors around the motor to measure the rotor angle. As an example, the following table shows the phase excitation to hall-signal pattern for a specific motor. (Rapidsyn)

Hall 100 110 010 011 001 101
A + +   - -  
B -   + +   -
C   - -   + +

This shows a common pattern, but some motors produce 000 and/or 111 patterns and even then, depending on the relative position of the sensors and phase poles there is no convention that, for example, 100 always means A->B for clockwise torque. One common variant of this pattern uses the opposite phase polarities, unfortunately this doesn't mean that the motor runs the other way, it means that the rotor angle and electromagnetic phase angle run in opposite directions, converge and the motor stops. What needs to happen is that the rotor "chases" the electromagnetic field, but never catches it.

This pattern of 6 distinct phase patterns is called Trapezoidal Commutation, it works well and is very simple. However, it does result in a significant (13%) torque ripple which also leads to a certain amount of motor noise.

Sinusoidal Commutation:

With only 6 angular positions measurable there are only 6 ways to pass current through the windings. However, with a finer-resolution feedback system such as an encoder or resolver it is possible to run the Three-Phase brushless motor rather like a standard 3-phase induction motor, with three sinusoidal wave forms. One very important difference, though, is that the phase voltages/currents follow the rotor position, whereas in an induction motor the rotor (approximately) follows the phase voltages. This gives a perfectly smooth torque, and very low noise. With this scheme more than two phases will be energised at one time. More care needs to be take to eliminate the possibility of shoot-through because of this.

"Servo Mode" v "Stepper Mode"

A BLDC motor can be made to rotate simply by applying phase voltages to the motor windings in exactly the same way as one might with an AC induction motor. In fact a conventional 3-phase inverter drive will probably spin a BLDC motor of suitable voltage rating reasonably well. However, this is not a particularly efficient way to run one. The full explanation involves discussing direct and quadrature current and Park / Clarke transforms and these are far better discussed in sites such as [wikipedia]. Simplistically the open-loop driving of a bldc can be considered as running it much like a low-count stepper motor with only 3, 6, or 8 steps per rev. The motor will settle in a position where there is no net torque on the rotor (with the rotor magnets aligned to the poles). The motor will only produce any torque when the rotor is displaced from this equilibrium position, and the torque will rise linearly to be equal to max motor torque when the rotor has been deflected by 90 electrical degrees from the equilibrium position. This is exactly the same for a stepper motor, but for a typical stepper motor 90 electrical degrees is 0.45 shaft degrees, whereas for a 4-pole BLDC it is 45 shaft degrees.

Consider the situation where a small movement of the motor is required to rotate a leadscrew: No useful torque will be produced until the electromagnetic phase angle has moved 10 degrees or so relative to the rotor, and then it will have to move back 10 degrees to remove the torque. This would be an almost impossible drive system to tune. Also, running in this mode the motor is taking full rated current at all times and will get hot.

A better solution is to actively control the motor position using a closed-loop controller and to only ever apply enough current to hold position or speed and to apply that current at the phase angle which gives the maximum possible torque for the curent, ie at 90 degrees to the rotor angle. This is clearly only possible if the rotor angle is known. Operating like this the motor will take zero current while stationary and under no load, but can apply full torque with only a few encoder counts of displacement if the feedback loop is well tuned (typically full holding torque might be generated with only 0.18 degrees of shaft displacement with a 1000 line encoder, this is even "stiffer" than a stepper motor).

"Stepper Mode" operation can be useful for initial motor alignment to an encoder index or known rotor alignment, however.

The LinuxCNC Perspective:

There are a large number of ways in which LinuxCNC can drive a Brushless motor, Using a conventional BLDC motor driver is one way, as long as the motor Hall sensor pattern matches that expected by the drive. Alternatively a drive can be easily manufactured from discrete power semiconductors to build a 3-phase H-bridge, or a commercial power driver IC such as the International Rectifier [IRAMS] modules. Alternatively LinuxCNC compatible drives from [Pico Systems] and [Mesa] are available. Some of these solutions will work with only a HAL PID component and a PWM generator, whereas others may need Hall-pattern translation, individual 3-phase amplitude signals, 3-phase PWM for direct H-bridge drive or simply as a bit-pattern to be modulated by a separate PWM. In addition there are a number of potential feedback devices that could be connected to the motors, including various patterns of hall sensors, encoders of various types or resolvers.

The HAL bldc component has been designed to bridge between these various combinations, it can be configured to take input from several combinations of motor feedback devices and output many different types of motor drive signals.

A typical section of HAL code using the bldc component might look like this

 loadrt bldc cfg=qH,a6
 addf bldc.0 servo-thread
 addf bldc.1 servo-thread

net enc0 encoder.0.rawcounts => bldc.0.rawcounts net H1 bldc.0.hall1-out =>

=== Input Options==

<To be continued. Sorry>

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited January 6, 2015 2:58 am by Andypugh (diff)
Published under a Creative Commons License