A conventional method of controlling BLDC motors is to implement an inner current loop for
torque / current control. Reference to this inner loop is provided either by an outer speed
loop or by some other means based on application requirement. The linearity of inner
current / torque loop is greatly affected by the faithfulness of current feedback. In the first
section, an outline to various approaches for obtaining current feedback is presented and
analyzed with the limitations of each. In the subsequent sections, a presentation is given of
a simple, linear and cost effective approach of implementing the inner current loop by
sampling the DC link current at the mid-point of PWM “on time” with ST7FMC. Experimental
results are also discussed.
An accompanying software file is available with this application note and can be downloaded
from www.st.com/mcu
A BLDC motor driven in a conventional 6-step method greatly resembles a brushed DC
motor. Hence, one may choose to regulate the average DC link current. But this actually
results in constant power operation for the motor because at constant DC link voltage, if the
average link current is regulated at a certain value, it effectively regulates the power at that
point for any variation in motor load, and the average load current / motor torque varies
inversely with speed depending on the load. Any effort to compensate the average DC link
current data with the duty cycle to obtain average phase current will be impaired by a filter
time constant, rendering this option ineffective.
Since the DC link current does not reveal winding currents during PWM “off time”, one may
choose to monitor all 3 winding currents and build a regulator. But this requires two current
sensors to monitor any two phase currents, while the third phase current can be
reconstructed from these two. However, the cost of these sensors makes this option
expensive.
A third option would then be to regulate the peak current per PWM period. Though it is
inexpensive and easy to implement, it is not exactly linear. During PWM on time, at lower
duty cycles, when both speed and BEMF are small, the phase current rises much faster
than at higher duty cycles when the speed and BEMF are large. The same peak currents
per PWM period represent different average currents at different duty cycles. An intuitive
geometric approach will reveal this as shown in Figure 1. A typical variation in average
current vs duty cycle at a given peak current reference is shown in Figure 2.
Figure 1.Peak current regulation at different duty cycles with BEMF load
I
phase
I
peak
I
phase
I
peak
tt
Figure 2.I
vs duty cycle at a given I
ave
I
ave
I
peak
peak
dutycycle
00.51.0
3/19
Obtaining the average currentAN2267
2 Obtaining the average current
For linear torque control, it is important that we sample the average phase current as
feedback to the current regulator. It is best to get this information from the DC link current
using only a shunt resistor because of its low cost and simplicity. However, the DC link
current is not continuous and is present only during PWM on time. As a simple model for
current control, assume a simple buck converter feeding an RL load as shown in Figure 3.
Figure 3.Buck converter feeding an RL load
PWM
CONTROL
SW1
1
BT1
2
R1
D1
V
L
R
sh
I
sh
I
L
L1
The switching frequency, PWM on time and load inductance are such that the load current is
continuous. Figure 4 shows the load voltage, load current and DC link current waveforms. A
close look at the load current waveform reveals that its average value is equal to its
instantaneous value during the middle of PWM on time or off time. Since the load current
flows through the DC link during PWM on time, sampling the DC link current during the
middle of PWM on time gives the average load current.
Figure 4.Buck Converter - Waveforms
V
I
L
I
L(ave
I
S
4/19
T
o
T
off
AN2267BLDC motor control using ST7FMC
(
g
C
g
d
3 BLDC motor control using ST7FMC
The main feature of ST7FMC is its powerful motor control macro cell, capable of generating
control signals to drive a sensorless or sensored 3 phase BLDC or AC motor.
STMicroelectronics application notes AN1946 [1] and AN2030 [2] explain, in detail, the
procedure to control a 3 phase BLDC motor using ST7FMC.
Figure 5 shows the simplified block diagram of the hardware motor control macro cell. The
macrocell has multiple timers performing various functions in parallel to generate control
pulses for the motor. An auto scalable 8-bit timer (MTIM) monitors the time difference
between successive phase back EMF zero crossings (Z events) of the motor. When a Z
event occurs, the timer value is captured into MZREG and the timer restarts counting from
zero, and, the previous content of MZREG is transferred to MZPRV. This timer is a part of
what is called DELAY MANAGER that, based on this time difference and a delay coefficient
(MWGHT), identifies the timing for next phase commutation instant (C events). All in
parallel, a 12-bit free running counter generates the PWM carrier for inverter switching.
Figure 5.Simplified block diagram of Motor control Macro cell for BLDC motors
or SPEED MEASURE UNIT (not
WEIGH
DELAY = WEIGHT x
MEASUREMENT
WINDOW
GENERATOR
PWM
12-bit
Phase
Phase V
Phase W
[Z] : Back EMF Zero-crossin
: Time elapsed between two consecutive Z
Z
n
[C] : Commutation
: Time delayed after Z event to generate C
n
(I): Current
e
(V): Volta
DELAY
(I
CAPTURE
(V
Phase
CURRENT
VOLTAGE
MOD
(V
MTI
TIME
=
COMMUTE
PCN
BEMF ZERO-CROSSING
BEMF=
[Z
TACH
Encoder
INPUT DETECTION
P
H
A
U, V,
Phase
CFAV
CHANNEL
12-bit THREE-PHASE
PWM GENERATOR
Vre
OAON
MCI
MCI
MCI
Ex
In
+
-
AD
MCO
MCO
MCO
MCO
MCO
MCO
NMCE
MCAO
MCAO
MCCRE
C
MCPWM
MCPWM
MCPWM
MCVRE
MCAOZ/
MCCFI
(V
Vd
I
R
3
5/19
BLDC motor control using ST7FMCAN2267
Figure 6.Motor Control Macro cell - BLDC motor control configuration
HV
C
C
ext
Board + Motor
MCPWMU / V/ W
V
DD
(I)
R
(V)
R
1ext
2ext
Microcontroll er
Z
H
D
H
Fcpu
+1
ST3-0 bits
-1
Z
H
MZREG Reg [ Zn]
Z
S,H
MZP RV Reg [Z
DCB bit
MWGHT R eg [a
SWA bi t
MCOMP Reg [C
EF[2: 0]
Filte r / D
SR bit
X T16 bi t
+
R
MTIM
= FFh?
MZREG
< 55h?
-
R
MTIM [8-bit Up Counter]
]
n-1
]
n+1
A x B / 256
n+1
+
-
S,H
D
S,H
D
V
REF
VR2- 0
SR b it
S,H
Filt er / PWM
Reg
MPHST
CFF[2:0] bit
ISn bit
12- bit P WM ge nera tor
n
bits
OS
MREF
3
n
66
Reg
Ch0Ch1Ch2Ch3Ch4
Dead
Time
Dead
Time
High Frequency Chopper
Dead
Time
Ch5
8
2
6
PCN bi t =0
DTG register
MPAR Reg
+
CL
-
x6 x6
AO bit
+
-
CFA V bi t
MCIA
MCIB
MCIC
MCVREF
MPWME Reg
MCPWMU
MCPWMV
MCPWMW
MCO0
MCO2
MCO4
MCO1
MCO3
MCO5
1
NM CE S
MOE bi t
MPOL Reg
MCAOP
MCAON
MCAOZ
MCCFI
MCCREF
B
A
A
CP Bn bit
1 / 2
1 / 2
nn-1
88
Compare
EF[2:0]
Filter / C
Rat i o
ck
C
HDMn bit
1 / 4
8
Compare
S,H
ororor
SA3- 0 &
OT1-0 bits
SZn
bit
Z
S
PZ bit
1 ¾ 1/128
Filter / C
EF[2 :0]
or
CP Bn bit
1 /20
REO bi t
cl r
D
S,H
C
2
1
SPLG
SWA bi t
1
0
D
H
MDREG Reg [ Dn]
Com p a re
SDMn bit
EF[2:0 ]
F ilter / C
CL
-/+
R
E
Z
S,H
D
S,H
C
S,H
S,H
DQ
CP
C
2
1
V
I
Com p ar e U
Z
V
I
C
H
SQ
R
D
S
MISR R eg
MI MR Reg
ZVD bit
4
8
]
A PWM output is generated as a result of comparison between this carrier and a compare
register (MCPUH:MCPUL) that carries pulse width (duty cycle) information. This PWM
signal is directed to one of the six inverter switches by a CHANNEL MANAGER that acts as
a traffic diverter on the PWM output. The channel manager also selects a complementary
switch, as programmed by the user, which together with the switch receiving PWM will force
current into the motor windings. Based on the motor terminal voltages or Hall sensor
outputs, an analog block identifies the motor phase BEMF Z events and captures the
contents of MTIM timer into MZREG and the previous value of MZREG into MZPRV and this
cycle repeats all over again.
6/19
AN2267Implementation using ST7FMC
4 Implementation using ST7FMC
A typical schematic block diagram of ST7FMC based sensorless control of BLDC motor [2]
is shown in Figure 7. Refer to Appendix C on page 16 for a complete schematic of the
experimental hardware. This schematic resembles the motor control starter kit schematic
from Softec Microsystems, with matching I/O assignments wherever possible.
Figure 7.Schematic block diagram of ST7FMC based sensorless control of BLDC
motor
V
V
CC
Speed Ref
AINy
MCO0
MCO1
MCO2
MCO3
MCO4
MCO5
Shut Down
dclink
BLDC
AINx
PE0
PE1
PE2
MCIA
MCIB
MCIC
V
CC
Max Current
ST7FMC
Limit
Figure 8a shows the PWM carrier configured in center aligned mode, where the counter
counts up to a maximum value (as defined by MCP0) and starts counting down to zero and
repeats this cycle again. (See Appendix A for information on setting the PWM frequency).
The PWM generator is set to generate a duty cycle update interrupt (U event) upon
completion of every N carrier cycles as specified by MREP register. (See Appendix A for
information on setting the periodicity of this interrupt). The timing of the U event or interrupt
is positioned as shown in Figure 8a. The carrier is compared with MCPU and PWM pulses
are generated as shown in Figure 8b. Due to the application of PWM voltage on motor
windings, a current flows in its windings as shown in Figure 8c.
7/19
Implementation using ST7FMCAN2267
Figure 8.PWM on time midpoint identification and control
MCP0
U event
Carrier
U event
Ref
Fig 8a
t
Fig 8b
PWM
t
Fig 8c
Current
t
Fig 8d
U ISR
t
T
From Figure 8a and Figure 8b, it is clear that the U event takes place at the center of PWM
on time. Based on the previous discussions, this is the right instant to read the
instantaneous DC link current in order to get the average phase current value. Hence the
interrupt associated with U event should be set to the highest priority and the very first
instruction in this Interrupt Service Routine (ISR) should read the DC link current value. In
any case, there is an interrupt latency time of approximately 3-4µs, which is also the typical
conversion time of on-chip Analog to Digital Converter (ADC). If the current feedback analog
input channel was previously selected and set for sampling continuously, then, when the first
instruction in U event interrupt subroutine reads the ADC data register, it will aptly hold the
DC link current value fairly close to that during the middle of PWM on time.
The flowchart in Figure 9 shows the actions within the U event interrupt service routine. To
coordinate the reading of any other analog inputs to the ADC, it is recommended that they
are all read within this U event subroutine after the DC link current read. However, before
returning from the interrupt, it is important to restore the ADC to sample the DC link current
channel again so that on re-entry in the next U event, the DC link current value can be read
from ADC right away. If required, interrupt priority of this routine can be lowered after
reading the current value upon entry, but should be restored to the highest value before
returning for obvious reasons.
Refer to the accompanying file for a complete listing of the code and experimental
workspace.
9/19
ResultsAN2267
ω
ω
5 Results
Experimental implementation of this scheme yielded satisfactory results. A closed loop
regulator for BLDC motor control with inner current and outer speed loops as shown in
Figure 10 was implemented. Current loop sampling time of 500µs and speed loop sampling
time of 2ms was chosen. The amount of computing time required within a 2ms time window
to execute through a full cycle of control loop and all motor control ISRs at an electrical
frequency of 200Hz is less than 1ms. The important waveforms obtained are shown in
figures 11 and 12. Figure 11 shows the convergence of reference and actual phase current
values at the instant of occurrence of U event which is the feedback sampling instant. Notice
that the U event occurs during the middle of PWM ON time. Figure 12 shows the tight
control of motor average phase current for a given current reference.
Figure 10. Closed loop current and speed control - block diagram
ST7FMC controller
PI reg
+
-
I*
+
-
Vdclink
PI reg
duty
BLDC
Speed
estimator
10/19
AN2267Results
Figure 11. DC link current sampling at U event and closed loop convergence
Figure 12. Tight control of average phase current vs reference
11/19
ConclusionAN2267
6 Conclusion
The experiments performed based on the described method gave fairly linear current
control. One limitation of this sampling method is when the motor current becomes
discontinuous, in which case the actual average current is less than the instantaneous value
at the mid point of PWM on time, and correcting this error is quite cumbersome.
12/19
AN2267References
7 References
[1]. STMicroelectronics AN1946 - Sensorless BLDC motor control and BEMF sampling
methods with ST7MC
[2]. STMicroelectronics AN2030 - Back EMF detection during PWM on time by ST7MC
13/19
Sampling inner current loop procedureAN2267
p
Appendix A Sampling inner current loop procedure
Procedure to set carrier frequency (Fpwm) and periodicity of U event (TU) for sampling inner
current loop:
Chosen F
where,
F
pwm
pwm
= F
= 16KHz
/ (Prescaler . 2 . MCP0)
mtc
F
mtc
Prescaler Up/ Down
MPCR
PCP[2:0]
Given F
and choosing Prescaler = 1,
then,
Choosing TU = 500µS
where,
= 16MHz,
mtc
MCP0 = 500
TU = Tpwm . (MREP + 1) / 2
UU
MCP0 MREP
counter
F
wm
Repeat
Counter
MPCR
CMS = 1
U
Substituting for TU and T
pwm
,
MREP = 15
14/19
AN2267Event U interrupt service routine
Appendix B Event U interrupt service routine
/***************************************************
Motor control - Event U interrupt service routine
***************************************************/
@interrupt @nosvf void mtcU_CL_SO_ISR(void)
{
if (bitTest_TRUE(MISR, PUI) ) // check for U event presence
{
/* === Current loop PI Controller begins here === */
currentFb = (ADCDRMSB << 2) + ADCDRLSB; // get new value of currentFb
piconCur(); // call current loop PI regulator
to get new dutycycle
MCPUL = PIconCur.byte.b2; // update MCPUH :MCPUL with new dutycycle
MCPUH = PIconCur.byte.b3;
/* === Current Loop PI controller ends here === */
// Read potentiometer to get latest speed reference
getADC_10bit (speedRef , SPEED_REF_CHNL);
if (speedRef > SPEED_REF_MAX)
speedRef = SPEED_REF_MAX;
// Current Feedback measurement setup for next cycle
ADCCSR = ADON + CURRENT_FDBK_CHNL;
ADCDRMSB; // to clear EOC of prev conv
MISR = 0xff - PUI; //reset IT flag
}
return;
}
Information in this document is provided solely in connection with ST products. STMicroelectronics NV and its subsidiaries (“ST”) reserve the
right to make changes, corrections, modifications or improvements, to this document, and the products and services described herein at any
time, without notice.
All ST products are sold pursuant to ST’s terms and conditions of sale.
Purchasers are solely responsible for the choice, selection and use of the ST products and services described herein, and ST assumes no
liability whatsoever relating to the choice, selection or use of the ST products and services described herein.
No license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. If any part of this
document refers to any third party products or services it shall not be deemed a license grant by ST for the use of such third party products
or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoever of such
third party products or services or any intellectual property contained therein.
UNLESS OTHERWISE SET FORTH IN ST’S TERMS AND CONDITIONS OF SALE ST DISCLAIMS ANY EXPRESS OR IMPLIED
WARRANTY WITH RESPECT TO THE USE AND/OR SALE OF ST PRODUCTS INCLUDING WITHOUT LIMITATION IMPLIED
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE (AND THEIR EQUIVALENTS UNDER THE LAWS
OF ANY JURISDICTION), OR INFRINGEMENT OF ANY PATENT, COPYRIGHT OR OTHER INTELLECTUAL PROPERTY RIGHT.
UNLESS EXPRESSLY APPROVED IN WRITING BY AN AUTHORIZE REPRESENTATIVE OF ST, ST PRODUCTS ARE NOT DESIGNED,
AUTHORIZED OR WARRANTED FOR USE IN MILITARY, AIR CRAFT, SPACE, LIFE SAVING, OR LIFE SUSTAINING APPLICATIONS,
NOR IN PRODUCTS OR SYSTEMS, WHERE FAILURE OR MALFUNCTION MAY RESULT IN PERSONAL INJURY, DEATH, OR
SEVERE PROPERTY OR ENVIRONMENTAL DAMAGE.
Resale of ST products with provisions different from the statements and/or technical features set forth in this document shall immediately void
any warranty granted by ST for the ST product or service described herein and shall not create or extend in any manner whatsoever, any
liability of ST.
ST and the ST logo are trademarks or registered trademarks of ST in various countries.
Information in this document supersedes and replaces all information previously supplied.
The ST logo is a registered trademark of STMicroelectronics. All other names are the property of their respective owners.