Let's apply what we have learned about the basics of brushless
motor control in Part
1 to the example of Hall sensor
signal processing.
At every interrupt, the MCU has to execute a code that properly changes
the output state. This interrupt-based code must interpret the Hall
signals correctly and then change power-switch states, first turning
off one switch and then turning on the next.
Since Hall sensors provide polarity, we can easily determine which
Hall sensor interrupt has been received by reading all three polarity
levels. A Hall sensor set-up in which rising Hall signals occur at
every 120- degree position is shown in Figure
10 below.
Notice that the rising U Hall signal
is at 0 degrees, the rising V
Hall signal is at 120 degrees, and the rising W Hall signal is at 240
degrees. Because Hall sensors have a south pole located 180 degrees
from the north pole, a falling signal will occur at the 180-degree
offset of each rising signal, thus creating six signals over the
complete rotation.
On receiving the first interrupt -the rising edge of Hall A - the
MCU firmware reads the three interrupt input pins as 1, 0, 1 and sets
the output pins to state 1, with Up and Vn on. On receiving the second
interrupt - the falling edge of Hall C - the MCU firmware reads the
input pins as 1, 0, 0; compares this reading to the previous state (1,
0, 1); and sets state 2.
On receiving the third interrupt - the rising edge of Hall B - the
MCU reads the input pins as 1, 1, 0; compares the reading to 1, 0, 0
and sets state 3. The next three interrupts are processed in a similar
manner to complete the cycle.
 |
| Figure
10. Six step changes for 120 deg input Hall sensors. |
In this example, we need to know which sensor is A, which is B, and
which is C. Motor manufacturers generally provide this information.
Nevertheless, it's instructive and helpful to lay out the board,
connect the motor, power up the MCU only (not the entire motor), and
view the signals from the Hall sensors, which get their power from the
MCU board. Now we can examine the sequence of Hall signals easily,
turning the motor by hand for one complete rotation. The signals can
also be viewed on a scope as the motor is rotated to determine whether
or not they are 120-degree Hall signals.
If we observe 60-degree Hall signals, which means that the rising
edge occurs every 60 degrees rather than every 120 degrees, then the
sequence of inputs changes as shown in Figure
11 below. On the first interrupt, the firmware reads 1, 0, 0
instead of 1, 0, 1. The sensor changes to a state-1 configuration in
which Up and Vn are still on.
It does not change to the state-2 configuration used in the
120-degree example. On the next interrupt, the sensor reads the input
pins as 1, 1, 0 and then the firmware makes the change to state 2. The
cycle continues according to the sequence of Hall signals. Notice that
the firmware is changed slightly and the sequence of Hall input signals
is different. For proper sensor implementation, designers must know how
the Hall sensors are mounted and how the firmware should be written.
 |
| Figure
11. Six step changes for Hall sensors mounted 60 degree rising signals. |
Table 2, below further
compares two Hall-sensor configurations. Again, the best way to
implement the firmware is to perform some initial tests to determine
what is necessary for rotation in one direction and what is necessary
for rotation in the reverse direction. Once this information is
available, the firmware can be implemented easily, including the
correct rotational sequence.
It's important to note that these examples are based on a one
pole-pair motor. A motor that has more pole pairs will have a larger
sequence on the signals in one mechanical rotation. For example, a
Bodine motor has two pole pairs, and so instead of six interrupts, it
has 12 interrupts per mechanical rotation. Thus, when tests are
performed to obtain the sequence of Hall signals, the motor must be
rotated slowly, smoothly, and continuously—otherwise, the sequence
observed may be incorrect.
 |
| Table
2. Comparison of two Hall-sensor configurations. |
The C programming code for a commutation sequence for the Renesas
R8C MCU is shown in Figure 12
below.
The case statements are translated into a compact code size by the
compiler. Individual phase voltages and voltages between U-V, V-W and
W-U are shown in Figure 13.
 |
| Figure
12. R8C code in C language for 6 step changes for BLDC motor. |
 |
| Figure
13. Phase voltages for six step trapezoidal control. |
Trapezoidal control with Hall
sensors
To understand trapezoidal control in a BLDC motor, let's first consider
full-speed operation. When a full voltage is turned on every 120
degrees of rotation, and when proper commutation is performed according
to the Hall-signal inputs, the motor rotates at its full operational
speed. The MCU receives interrupt inputs and properly executes outputs
according to the sequence desired.
The full speed at which the motor operates is determined by certain
characteristics. The applied voltage and back-EMF are balanced so that
the torque necessary to maintain operational speed is achieved. Figure 14 below shows a current
profile - that is, the shape of the currents - at full speed with
input Hall signals and six-step currents. Notice that the shape of the
phase currents is trapezoidal.
As we have seen before, torque in BLDC motors is proportional to the
current passing through the coils. Therefore, to reduce the speed, we
must reduce the current. Torque is maintained at the necessary level by
changing the current to maintain the desired speed.
 |
| Figure
14. Current at full speed operation is trapezoidal and hence the name
"Trapezoidal" control. |
To reduce the current in coils, voltage is modulated using the pulse
width modulation (PWM) method illustrated in Figure 15, below. During a state,
the voltage is turned on and off at a suitable frequency, known as the
carrier frequency, in a manner that applies less current to each coil.
As a result, less torque is created on the rotor and speed is
reduced. A PWM timer is used to modulate the output state of the pin
and thus the voltage applied to the phase. This modulation is typically
performed at a carrier frequency higher than the state-change
frequency. Even when the voltage is modulated, the current profile
remains trapezoidal - thus the name, trapezoidal control.
 |
| Figure
15 Trapezoidal currents with modulation in lower switches. |
The PWM method requires us to know carrier frequency and duty cycle.
We can select an arbitrary frequency for the carrier signal we will
modulate. But how do we know what duty cycle is needed to maintain the
desired speed?
Hall sensors come to rescue again, as speed can be measured using
the Hall signal interrupts. The angle between two consecutive Hall
signals is 60 degrees by construction, and these signals are mapped
onto the interrupt pins by the MCU.
Using an MCU timer peripheral, the time between two consecutive Hall
signals can be measured and speed can be computed: It's 60 degrees
divided by the time measured between two Hall signals. To determine
average speed, we can measure the time between six or more Hall signal
interrupts, whatever is suitable in terms of time to control the speed.
Now it becomes easy to adjust the duty cycle. If the measured speed is
high, the duty cycle is reduced. If the measured speed is low, the duty
cycle is increased.
 |
| Figure
16. R8C based BLDC control. |
The MCU resources required for this activity include six output
pins, three input pins, one internal timer to measure the time between
two consecutive Hall signals. We also need one PWM timer that can
modulate each output pin, or a timer that can generate six outputs
properly with modulation, as well as one interrupt for emergency
shut-down. These resources are depicted in Figure 16 above, in which an R8C is
the MCU.
Timing example
Now let's consider an example of how timing is used in speed control.
Assume that we have a BLDC motor that has two pole pairs and a maximum
operational speed of 3600 RPM. The MCU is running on a 20-MHz CPU
clock, and that clock is also used for the timers and counters. Our
calculations will be based on the following formulas:
<>Speed (Hz) = Speed (RPM) / 60 = mechanical Hz
Mechanical Hz = 60
Electrical Hz = #pole pairs * mechanical Hz
Electrical Hz = 120
Electrical time period or period = 1/electrical Hz;
Period = 1/120 =
8.3333 ms = 8333.3 µs
Time tH between two Hall signals =
electrical Hz / 6;
tH = 8333.3 /6 =
1388.9 microseconds.
Counts between two Hall signals = Count Frequency in MHz * time
between two Hall signals
Counts = 20 * 1388.9 = 27,778
counts in our
example.
When we fix the counting frequency at 20 MHz and the pole-pair equal
to 2, the formula can be simplified to give
Counts = 100,000,000 / RPM
This is a very simple formula.
Next we can prepare a table, shown
below that gives RPM and corresponding counts. It's important to
check at what RPM the size of the 16-bit counter will become an issue.
In the example above, at 1200 RPM the count value is 83,333, which
causes the counter to overflow. In fact, for a count less than 65,535,
the minimum RPM is 1535. Therefore, a 16-bit counter driven by a 20-MHz
clock is usable only as long as the motor speed stays above 1535 RPM.
 |
| Table
3. Counts for various reference speeds. (Note: 16-bit counter overflows
because motor speed is too slow.) |
Based on this simple formula and table, a control scheme can be
developed to adjust the duty cycle. We can measure counts between two
Hall pulses fairly easily and thus determine whether or not a motor is
running at the desired speed. For example, if the desired speed is 3000
RPM, then we should expect 33,333 counts.
If we measure 40,000 counts, the motor is running slow and PWM duty
cycle must be increased. If we measure 30,000 counts, the motor is
running fast and the duty cycle must be reduced.
Code for such control is shown in Figure
17 below, which again uses an R8C MCU as an example. The timer C
peripheral in this setup has two registers, tm0 and tm1. Register tm1 sets up the carrier frequency
and tm0 sets up the duty
cycle. Output is low (= 0) until the count reaches tm0. When the count
matches tm0, the output is
turned high (= 1). When the count matches the tm1 value, the output is set low
(=0) and the counter is reset. Thus, the active duty cycle extends from
the tm0 value to the tm1 value, and the non-active duty
cycle is from 0 to the tm0
value.
 |
| Figure
17. R8C code in C language for PWM duty control to achieve desired
speed. |
In our example, the register tm1
is set to a value of 1000 to get a
20 kHz carrier frequency. The time between two Hall pulses is called CountMeas and the high and low
reference counts are CountRefH
and CountRefL. When time is
measured, the value of CountMeas
is compared to CountRefH and
register tm0 is adjusted
accordingly.
If the measured count is higher than the reference count CountRefL, the motor is running
slow and the tm0 value is
reduced to increase the duty cycle. If the measured count is lower than
the reference count, the tm0
value is increased to reduce the duty cycle. Finally, a check is made
to protect the minimum and maximum values.
Simple code such as this works well for adjusting the duty cycle to
get a desired speed. However, in a few cases this control method fails
to work properly, particularly, when the increase and decrease in the tm0 register moves back and forth.
Recall that we are using CountRefH
and CounteRefL - not just a
single CountRef - for
comparison. This allows us to insert what is known as a dead band.
Let's say that we want our motor to rotate at 3000 RPM. From Table 3, earlier, we see that the
reference count or expected count is 33,333. Now we must apply a
dead-band value, which is determined by the accuracy we require.
If we require 100-RPM accuracy, then we must compute values for CountRefH using 2900 RPM (34,483)
and CountRefL using 3100 RPM
(32,258). When RPM gets within this range, the control algorithm will
stop adjusting the PWM value. Based on the control frequency, the
sensor measurement frequency, and the accuracy requirements, we can
tighten this dead-band value. However, we must be cautious. Too tight a
dead band will cause the motor speed to fluctuate between one value and
another.
Design engineers frequently use proportional-integral control and
motor response characteristics to determine gains. This approach
generally gives a better control algorithm. We have used such
algorithms successfully, but only after we first made the motor rotate
closed-loop using the simple approach just described. We generally
suggest such an approach.
Starting a motor. Because
motors are started in open-loop fashion, they require a duty cycle
somewhere between 50 and 70%. This ensures that the motor has enough
starting torque and that the rotor will turn in synchronization with
the rotating magnetic field of the stator. If the starting torque is
insufficient, the rotor may never attain a synchronous state and the
firmware may never get feedback from the Hall signals.
Generally motors are started at a 70% duty cycle with a fixed
commutation period of about 500 RPM. Once the MCU starts to receive the
Hall signals, the speed measurements are stabilized. Then the simple
control algorithm stabilizes the PWM value and the speed command is set
to the desired speed.
This process works best when we make small, incremental speed
changes and allow the algorithm to follow with the appropriate PWM
changes.
Modulation schemes
Another issue in speed control is whether to modulate only the Up or
both the Up and Vn.
Several approaches can be taken. Many designers prefer to modulate only
the upper IGBT or power-MOSFET
switches, while
others
choose to
modulate only the lower switches. These approaches are known as
asymmetric modulation schemes.
If only the upper switches are modulated, then access energy is
drained out of the motor because the lower switches are always on. If
only the lower switches are modulated, the motor continues to store
energy in the system.
The result may be good or bad. Asymmetric modulation creates
differing stresses on the switches, so the control algorithm for such
modulation has to exactly fit the operation. If the upper switches are
modulated, they are subject to greater stress and wear and tear, which
increases the probability of their failure. If only the lower switches
are modulated, they will be more prone to failure.
Asymmetric modulation typically employs one of two schemes:
120degree modulation or 60-degree modulation. As Figure 18 below shows, in
120-degree modulation the upper switches are modulated as necessary
during the entire on time. In 60-degree modulation, the upper switches
are modulated for the first 30 degrees and the last 30 degrees, with
the switch left on for the middle 60 degrees.
This 60-degree modulation scheme does not permit a full range of
operation. In many cases, the motor can be operated only in 50 to 100%
of its speed range.
 |
| Figure
18 Asymmetric modulation schemes for six step control method. |
Some designers modulate both the upper and lower switches. Even
though this scheme is somewhat more complicated to implement, it allows
more symmetrical stress and wear and tear on the switches. With this
scheme, each switch can be modulated 60 degrees at a time, as
illustrated in Figure 19 below,
stressing it in a more symmetrical fashion. The scheme also works well
with the interrupts and state-change requirements.
As we know from the six-step algorithm, a state change is required
every 60 degrees. Thus, when a state change is made, a switch is also
selected for modulation. As shown in Figure 19, each switch is
modulated 60 degrees, creating an equal stress on each.
Also, the motor can operate in the full speed range, because the
modulation covers the entire electrical cycle. Generally, each switch
remains on for 120 degrees of electrical rotation time, and the
state-change algorithm selects which 60-degree portion will be
modulated.
 |
| Figure
19. Symmetric modulation scheme that stresses all power switches
equally. |
If we combine our modulation scheme, speed sensing, and PWM
computation within our motor control firmware, then our firmware
structure will be similar to that shown in Figure 20 below. Block 1 ensures
that proper state changes are made to achieve 120-degree modulation.
Many times this commutation is based strictly on the MCU receiving
the Hall-sensor signals and processing them in interrupts, an
implementation technique that ensures that state changes are made
properly. Thus, if the motor is running slowly, no abrupt state changes
will be made, and the motor will maintain its synchronization.
Block 2 of Figure 20 has
two components, the first of which is used to measure speed from the
Hall sensors. This measurement requires the use of a timer resource.
For every Hall-signal interrupt, the timer is read and reset so that it
will measure the time of the next Hall signal.
 |
| Figure
20. Closed loop control method with position sensor |
The second component in Block 2 uses this measured count or measured
speed in the control algorithm to set the new duty cycle according to
the calculations discussed earlier. Notice here that we have added a
bus-voltage measurement into our scheme.
When AC is rectified into DC, voltage ripple can occur at about 60
Hz. Often this ripple is in the 5% range - a large variation that can
be handled properly. Because the modulation runs at 20 kHz and the
ripple is at 60 Hz, we can correct for the ripple by accurately
measuring the bus voltage at the right frequency.
Experience tells us that when we make such corrections, the motor
will reach the desired speed quickly and maintain that speed properly.
If we don't make such corrections, then the voltage ripple will cause
torque ripple that may, in turn, cause the speed of the motor to
continually vary above and below the set point.
To read Part 1 go to : The
basics
of brushless motor control.
Next in Part 3: Pros and cons of
sensor vs sensorless motor control
Yashvant Jani is director of
application engineering for the system LSI business unit at Renesas
Technology America.
References
1. Power
Electronics and Variable Frequency Drives Technology and Applications,
Edited by Bimal K. Bose, IEEE Press, ISBN 0-7803-1084-5, 1997
2. Motor
Control Electronics Handbook, By Richard Valentine, McGraw-Hill,
ISBN 0-07-066810-8, 1998
3. FIRST
Course On Power Electronics and Drives, By Ned Mohan, MNPERE, ISBN
0-9715292-2-1, 2003
4.
Electric Drives, By Ned Mohan, MNPERE, ISBN 0-9715292-5-6, 2003
5. Advanced Electric Drives,
Analysis, Control and Modeling using Simulink, By Ned Mohan,
MNPERE, ISBN 0-9715292-0-5, 2001
6. DC Motors Speed Controls Servo Systems including Optical Encoders,
The Electro-craft Engineering Handbook by Reliance Motion Control, Inc.
7. Modern
Control System Theory and Application, By Stanley M. Shinners,
Addison-Wesley, ISBN 0-201-07494-X, 1978
8. The Industrial
Electronics Handbook, Editor-in-Chief J. David Irwin, CRC Press and
IEEE Press, ISBN 0-8493-8343-9, 1997
This article is excerpted from a
paper of the same name presented at the Embedded
Systems Conference Boston 2006.
|