An1914 PDF
An1914 PDF
An1914 PDF
Rev. 1, 11/2005
Application Note
minimized by using dedicated on chip peripheral modules (such as A/D converter, dedicated PWM outputs,
input capture and output compare functions).
Three phase Brushless DC (BLDC) motors are good candidates because of their high efficiency capability and
easy to drive features. The disadvantage of this kind of motor is the fact that commutation of motor phases
relies on its rotor position. Although the rotor position is usually sensed by sensors, there are applications that
require sensorless control. Benefits of the sensorless solution are elimination of the position sensor and its
connections between the control unit and the motor.
The sensorless rotor position technique detects the zero crossing points of Back-EMF induced in the motor
windings. The phase Back-EMF Zero Crossing points are sensed while one of the three phase windings is not
powered. The obtained information is processed in order to commutate energized phase pair and control the
phase voltage, using Pulse Width Modulation.
This application note provides a fundamental mathematical method for modelling, torque calculation and
control concept of the presented drive. The drive was developed in order to address simple applications (e.g.
pumps, compressors, fans...) within certain ranges of speed and load. Results from simulation show the drive
behavior at different working conditions and better explain the drive strategy.
Program Flash 8188 x 16-bit 32252 x 16-bit 32252 x 16-bit 61436 x 16-bit
The BLDC motor control greatly benefits from the flexible PWM module, fast ADC and Quadrature Timer
module. The PWM offers flexibility in its configuration, enabling efficient control of the BLDC motor.
The PWM block has the following features:
• Three complementary PWM signal pairs, or six independent PWM signals
• Features of complementary channel operation
• Deadtime insertion
• Separate top and bottom pulse width correction via current status inputs or software
• Separate top and bottom polarity control
• Edge-aligned or center-aligned PWM signals
• 15-bits of resolution
• Half-cycle reload capability
• Integral reload rates from one to 16
• Individual software-controlled PWM output
• Programmable fault protection
• Polarity control
• 20-mA current sink capability on each PWM pin
• Write-protectable registers
The PWM module is capable of providing the six PWM signals with bipolar switching (the diagonal power
switches are driven by the same signal) and six-step BLDC commutation control where one motor phase is left
unpowered so the Back EMF can be detected. The PWM duty cycle can be set asynchronously to the
commutation of the motor phases using the channel swap feature.
The Quadrature Timer feature set is as follows:
• Four channels, independently programmable as input capture or output compare
• Each channel has its own timebase source
• Each of four channels can use any of four timer inputs
• Rising edge, falling edge, or both edges input capture trigger
• Set, clear, or toggle output capture action
• Pulse Width Modulator (PWM) signal generation
• Programmable clock sources and frequencies, including external clock
The Quadrature Timer provides the capability to precisely control the key sensorless BLDC events by
providing the time base for zero crossing events and the output compare function for scheduling the
commutation events.
Dual Analog-to-Digital Converter (ADC) modules—four inputs on each has the following feature set:
• Eight total analog inputs
• 12-bit range
• Monotonic over entire range with no missing codes
• First channel on each ADC can be swapped with the alternate ADC
• Can perform two simultaneous analog-to-digital conversions
• Conversion time = 1.25 us
• Contains programmable zero offset register
• Generates interrupt on completion of conversion
• Optional conversion interrupt is asserted when the analog voltage level exceeds, or
• falls below, the value contained in the zero offset register
• Output is in two’s complement or unsigned formats
The Analog-to-Digital Converter is utilized to measure DC-bus voltage, DC-Bus current and the power module
temperature. Its Hi/Lo level detection capability provides automatic detection of the over/under-voltage,
over-current and over temperature protection (serviced in associated ISR).
Stator
Stator winding
(in slots)
Shaft
Rotor
Air gap
Permanent magnets
The motor can have more then just one pole-pair per phase. This defines the ratio between the electrical
revolution and the mechanical revolution. The BLDC motor shown has three pole-pairs per phase which
represent three electrical revolutions per one mechanical revolution.
The rectangular, easy to create, shape of applied voltage ensures the simplicity of control and drive. But the
rotor position must be known at certain angles in order to align the applied voltage with the Back-EMF. The
alignment between Back-EMF and commutation events is very important. In this condition the motor behaves
as a DC motor and runs at the best working point. Thus simplicity of control and good performance make this
motor a natural choice for low-cost and high-efficiency applications.
electrical
angle
Figure 3-3 shows number of waveforms: the magnetic flux linkage, the phase Back-EMF voltage and the
phase-to-phase Back-EMF voltage. The magnetic flux linkage can be measured; however in this case it was
calculated by integrating the phase Back-EMF voltage, which was measured on the non-fed motor terminals of
the BLDC motor. As can be seen, the shape of the Back-EMF is approximately trapezoidal and the amplitude
is a function of the actual speed. During the speed reversal the amplitude is changed its sign and the phase
sequence change too.
The filled areas in the tops of the phase Back-EMF voltage waveforms indicate the intervals where the
particular phase power stage commutations occur. As can be seen, the power switches are cyclically
commutated through the six steps. The crossing points of the phase Back-EMF voltages represent the natural
commutation points. In normal operation the commutation is performed here. Some control techniques
advance the commutation by a defined angle in order to control the drive above the PWM voltage control.
Ps i_ A
Ps i_ B
Ps i_ C
A to p B to p C to p
Ph. B Ui_ C
A-B Ui_ B C
Ui_ CA
B-C
C-A
~ Position
AC Line Voltage Power Stage M Sensors
LOAD
=
Control Signals
Speed Position
Setting Feedback
Control Unit
The second goal of the model is to find how the motor characteristics depend on the switching angle. The
switching angle is the angular difference between a real switching event and an ideal one (at the point where
the phase to phase Back-EMF crosses zero).
The motor-drive model consists of a normal three phase power stage plus a Brushless DC motor. The power
for the system is provided by a voltage source (Ud). Six semiconductor switches (SA/B/C t/b), controlled
elsewhere, allow the rectangular voltage waveforms (see Figure 3-2) to be applied. The semiconductor
switches and diodes are simulated as ideal devices. The natural voltage level of the whole model is put at one
half of the DC bus voltage. This simplifies the mathematical expressions.
⎛ C ⎞
1--- ⎜ ⎟
uA = ⎜ 2u VA – u VB – u VC +
3 ∑ ix⎟
u
⎝ x=A
⎠
C
⎛ ⎞
1--- ⎜
uB = 2u VB – u VC – u VA + ∑ u ix⎟
3⎜ ⎟
⎝ x=A ⎠
⎛ C
⎞
(EQ 3-1.)
1
uC = --- ⎜⎜ 2u VC – u VA – u VB + ∑ u ix⎟⎟
3
⎝ x=A ⎠
⎛ C C
⎞
1--- ⎜
uO = ⎜ ∑ u Vx – ∑ u ix⎟⎟
3
⎝x = A x=A ⎠
0 = iA + iB + iC
where:
u VA …u VC are “branch” voltages; the voltages between one power stage output and its virtual zero.
u A …u C are motor phase winding voltages.
u iA …u iC are phase Back-EMF voltages induced in the stator winding.
uO is the voltage between the central point of the star of motor winding and the power stage natural
zero
i A …i C are phase currents
The equations (EQ 3-1.) can be written taking into account the motor phase resistance and the inductance. The
mutual inductance between the two motor phase windings can be neglected because it is very small and has no
significant effect for our abstraction level.
⎛ C C
⎞ di A
1--- ⎜
u VA – u iA – ∑ u Vx – ∑ u ix⎟ = R ⋅ i A + L
3⎜ ⎟ dt
⎝x = A x=A ⎠
⎛ C C
⎞ di B
1
u VB – u iB – --- ⎜ ∑ u Vx – ∑ u ix⎟ = R ⋅ i B + L (EQ 3-2.)
3 ⎜ ⎟ dt
⎝x = A x=A ⎠
⎛ C C
⎞
1--- ⎜ ⎟ = R ⋅ i + L di C
u VC – u iC –
3 ⎜ ∑ u Vx – ∑ u ix⎟ C dt
⎝x = A x=A ⎠
where:
R,L - motor phase resistance, inductance
where:
Ti - internal motor torque (no mechanical losses)
ω,θ - rotor speed, rotor position
x - phase index, it stands for A,B,C
Ψx - magnetic flux of phase winding x
It is important to understand how the Back-EMF can be sensed and how the motor behavior depends on the
alignment of the Back-EMF to commutation events. This is explained in the next sections.
u VA = +− 1--- u , u = ± 1--- u
2 d VB 2 d (EQ 3-1.)
i A = – i B, i C = 0, di C = 0
u iA + u iB + u iC = 0
The branch voltage C can be calculated when considering the above conditions:
3
u VC = --- u iC (EQ 3-2.)
2
As shown in Figure 3-5, the branch voltage of phase C can be sensed between the power stage output C and
the zero voltage level. Thus the Back-EMF voltage is obtained and the zero crossing can be recognized.
The general expressions can also be found:
3
u Vx = --- u ix where x = A ,B ,C (EQ 3-3.)
2
0 30 60 90 120 150 180 210 240 270 300 330 360 390
uVA
uA
1n
2x27k
1n
1n MUX
Zero Crossing
1n 2x27k 2x27k 2x27k Detection signal
MUX Command
Figure 3-7. Back-EMF Sensing Circuit Diagram
As explained in the theoretical part of this application note, the phase zero crossing event can be detected at the
moment when the branch voltage (of a free phase) crosses the half DC-bus voltage level. The resistor network
is used to divide sensed voltages down to a 0-15V voltage level. The comparators sense the zero voltage
difference of the input signal. The multiple resistors reduce the voltage across each resistor component to an
acceptable level. A simple RC filter prevents the comparators from being disturbed by high voltage spikes
produced by IGBT switching. The MUX selects the phase comparator output, which corresponds to the current
commutation stage. This Zero Crossing Detection signal is transferred to the timer input pin.
The comparator control and zero crossing signals plus the voltage waveforms are shown in
Figure 3-8.
The voltage drop resistor is used to measure the DC-bus current which is chopped by the PWM. The obtained
signal is rectified and amplified (0-3.3V with 1.65V offset). The internal controller’s A/D converter and Zero
Crossing detection are synchronized with the PWM signal. This synchronization avoids spikes when the
IGBTs (or MOSFETs) are switching and simplifies the electric circuit.
The A/D converter is also used to sense the DC-Bus Voltage and drive Temperature. The DC-Bus voltage is
divided down to a 3.3V signal level by a resistor network.
The six IGBTs (copack with built-in fly back diode) or MOSFETs and gate drivers create a compact power
stage. The drivers provide the level shifting that is required to drive high side switch. PWM technique is used
to the control motor phase voltage.
Phase Current 2A
Optoisolation Required
Three-Phase
DC Bus Current & Inverter
DC Bus Voltage
Sensing
3 -p h
BLD C
Power line M o to r
3 BEMF Voltage
Zero Crossing
Comparators
3 phase BLDC
Power Stage
Digital
ADC PWM
Inputs
Generator
with
Zero Dead Time
Crossing Zero Crossing
Time moment
P C M a s te r
Zero Crossing
SCI Period, Position
Commutation
Control
Recognition
Duty
Commutation Cycle
Period
1/T
The Back-EMF zero crossing detection enables position recognition. The resistor network is used to divide
sensed voltages down to a 0-3.3V voltage level. Zero Crossing detection is synchronized with the center of
center aligned PWM signal by the SW in order to filter high voltage spikes produced by the switching of the
IGBTs (MOSFETs). This signal is transferred to the device’s Encoder Input which is also used as a digital
filter. The SW selects one of the phase comparator outputs which corresponds to the current commutation step.
5. Control Technique
5.1 Control Technique - General Overview
The general overview of used control technique is shown in Figure 4-1. It will be described in following
subsections:
• PWM voltage generation for BLDC
• Sensorless Commutation Control
• Speed Control
The implementation of the control technique with all the SW processes is shown in Flow Chart, State diagrams
and Data Flow (see Figure 7-2 through Figure 7-8).
POWER C
SOURCE A
DC VOLTAGE
MOSFET/IGBT DRIVERS
B-off B-off
IB
C-off C-off C-off
IC
0 60 120 180 240 300 360 electrical angle
Figure 5-2. 3-phase BLDC Motor Commutation PWM Signal
Commutation Commutation
PWM1 SAt
PWM2 SAb
PWM3 SBt
PWM4 SBb
PWM5 SCt
PWM6 SCb
IA
IB
IC
Figure 5-3 shows that the diagonal power switches are driven by the same PWM signal as shown with arrow
lines. This technique is called bipolar (hard) switching. The voltage across the two connected coils is always
±DC bus voltage whenever there is a current flowing through these coils. Thus the condition for successful
BEMF Zero Crossing sensing is fulfilled as described in Section 3.
uva
uvb
The non-fed phase “branch” voltage Uva is disturbed at the PWM edges. Therefore the presented BLDC Motor
Control application synchronizes the BEMF Zero Crossing detection with PWM.
Figure 5-5 shows the transitions between the states. First the rotor is aligned to a known position; then the
rotation is started without the position feedback. When the rotor moves, the Back-EMF is acquired so the
position is known and can be used to calculate the speed and processing of the commutation in the Running
state.
Start motor
Alignment
No
Alignment time
expired?
Yes
Starting
(BEMF Acquisition)
Minimal correct No
commutations done?
Yes
Running
5.4.1 Alignment
Before the motor starts, there is a short time (which depends on the motor’s electrical time constant) when the
rotor position is stabilized by applying PWM signals to only two motor phases (no commutation). The Current
Controller keeps the current within predefined limits. This state is necessary in order to create a high start-up
torque. When the preset time-out expires then this state is finished.
• The Current Controller subroutine with PI regulator is called to control DC Bus current. It sets the
correct PWM ratio for the required current.
The current PI controller works with constant execution (sampling) period determined by PWM frequency:
Current Controller period = 1/PWM frequency.
The BLDC motor rotor position with flux vectors during alignment is shown in Figure 5-6.
5.4.2 Running
The commutation process is the series of states which assure that the Back-EMF zero crossing is successfully
captured, the new commutation time is calculated and, finally, the commutation is performed. The following
processes needs to be provided:
• BLDC motor commutation service
• Back-EMF Zero Crossing moment capture service
• Computation of commutation times
• Handler for interaction between these commutation processes
captured before the preset commutation time expires, then the exact calculation of the commutation time
(T2*[n]) is made based on the captured zero crossing time (T_ZCros[n]). The new commutation is performed
at this new time.
If (for any reason) the Back-EMF feedback is lost within one commutation period corrective actions are taken
in order to return to the regular states.
The flow chart explaining the principle of BLDC CommutationControl with BEMF Zero Crossing Sensing is
shown in Figure 5-7.
Commutation Done
No
BEMF Zero Crossing
detected between previous Corrective Calculation 1.
commutations?
Yes
Service of Commutation:
Preset commutation
No
No
has commutation has commutation
time expired? time expired?
No
Yes Yes
Figure 5-7. Flow Chart - BLDC Commutation with BEMF Zero Crossing Sensing
n-2 n-1 n
COEF_CMT_PRESET *
* Per_ZCrosFlt[n-1]
Commutation is preset
Zero Crossing
Detection Signal
Per_ZCros0[n] = Back-EMF feedback
Per_ZCros[n-2] Per_ZCros[n-1] Per_ZCros[n] Per_HlfCmt[n] received and evaluated
T_ZCros[n-1] T_ZCros[n]
Per_Toff[n] T_Cmt0**[n+1]
Per_ZCros[n] Per_HlfCmt[n]
The following calculations are made to calculate the commutation times (T_Next[n])
during the Running Stage:
• Service of Commutation - The commutation time (T_Next[n]) is predicted:
T_Next[n] = T_Cmt0[n] + Per_CmtPreset[n] =
= T_Cmt0[n] + Coef_CmtPrecomp*Per_ZCrosFlt[n-1]
coefficient Coef_CmtPrecomp = 2 at Running Stage!
If Coef_CmtPrecomp*Per_ZCrosFlt>Max_PerCmt
then result is limited at Max_PerCmt
• Service of received Back-EMF zero crossing - The commutation time (T_Next*[n]) is evaluated
from the captured Back-EMF zero crossing time (T_ZCros[n]):
Per_ZCros[n] = T_ZCros[n] - T_ZCros[n-1] = T_ZCros[n] - T_ZCros0
Per_ZCrosFlt[n] = (1/2*Per_ZCros[n]+1/2*Per_ZCros0)
HlfCmt[n] = 1/2*Per_ZCrosFlt[n]- Advance_angle =
= 1/2*Per_ZCrosFlt[n]- C_CMT_ADVANCE*Per_ZCrosFlt[n]=
Coef_HlfCmt*Per_ZCrosFlt[n]
The best commutation was get with Advance_angle: 60Deg*1/8 = 7.5Deg
which means Coef_HlfCmt = 0.375 at Running Stage!
Per_Toff[n+1] = Per_ZCrosFlt*Coef_Toff and Max_PerCmtProc minimum
Coef_Toff = 0.35 at Running Stage, Max_PerCmtProc = 100!
Per_ZCros0 <-- Per_ZCros[n]
T_ZCros0 <-- T_ZCros[n]
T_Next*[n] = T_ZCros[n] + HlfCmt[n]
• If no Back-EMF zero crossing was captured during preset commutation period (Per_CmtPreset[n])
then Corrective Calculation 1. is made:
T_ZCros[n] <-- CmtT[n+1]
Per_ZCros[n] = T_ZCros[n] - T_ZCros[n-1] = T_ZCros[n] - T_ZCros0
Per_ZCrosFlt[n] = (1/2*Per_ZCros[n]+1/2*Per_ZCros0)
HlfCmt[n] = 1/2*Per_ZCrosFlt[n]-Advance_angle = Coef_HlfCmt*Per_ZCrosFlt[n]
The best commutation was get with Advance_angle: 60Deg*1/8 = 7.5Deg
which means Coef_HlfCmt = 0.375 at Running Stage!
Per_Toff[n+1] = Per_ZCrosFlt*Coef_Toff and Max_PerCmtProc minimum
Per_ZCros0 <-- Per_ZCros[n]
T_ZCros0 <-- T_ZCros[n]
• Where:
T_Cnt0 = time of the last commutation
T_Next = Time of the Next Time event (for Timer Setting)
T_zCros = Time of the last Zero Crossing
T_zCros0 = Time of the previous Zero Crossing
Per_Toff = Period of the Zero Crossing off
Per_CmtPreset = Preset Commutation Periof from commutation to next commutation if no
Zero Crossing was captured
Per_ZCros = Period between Zero Crossings (estimates required commutation period)
Per_ZCros0 = Pervious period between Zero Crossings
Per_ZCrosFlt = Estimated period of commutation filtered
Per_HlfCmt = Period from Zero Crossing to commutation (half commutation)
Rotor movement
during one Starting (BEMF Acquisition)
commutation Direction of
Phase current The two fast (faster then the rotor can
move) commutations are applied to
Zero crossing Phase winding create an angular difference of the
edge indicator stator magnetic field and rotor
magnetic field.
Running
After several Back-EMF zero
crossing events the exact
commutation time is calculated. The
commutation process is adjusted.
Motor is running with regular
Back-EMF feedback.
Phase Back-EMFs
Phase C Phase A
Phase B
Figure 5-10 demonstrates the Back-EMF during the start-up. The amplitude of the Back-EMF varies
according to the rotor speed. During the Starting (Back-EMF Acquisition) state the commutation is done in
advance. In the Running state the commutation is done at the right moments.
Figure 5-11 illustrates the sequence of the commutations during the Starting (Back-EMF Acquisition) Stage.
The commutation times T2[1] and T2[2] are calculated without any influence of Back-EMF feedback.
.
T_Cmt0[1] T_Cmt0[2] T_Cmt0[3]
T2[1] T2[2] T2[n]
n=1 n=2 n=3
COEF_CMT_PRESET *
* Per_ZCrosFlt[n-1]
Per_CmtStart 2*Per_CmtStart Commutation is preset
Zero Crossing
Detection Signal Commuted at preset time.
No Back-EMF feedback was
received - Corrective Calculation 1.
T_ZCros[0]
T2*[n]
Zero Crossing
Detection Signal Commuted when correct
Back-EMF feedback
Per_HlfCmt[n] received and evaluated.
T_ZCros[n]
T2**[n]
Per_Toff[n]
Per_HlfCmt[n]
Figure 5-11. Calculation of the Commutation Times during the Starting (Back-EMF Acquisition)
Stage
6. Hardware
6.1 System Outline
The motor control system is designed to drive the 3-phase BLDC motor in a speed closed loop.
There are more software versions targeted for a specific device and Evaluation Module:
• 56F803
• 56F805
• 56F807
The hardware setup of the system for a particular device varies only by the EVM Board used. The application
software is identical for all devices; the EVM and chip differences are handled by SDK drivers for the
particular EVM board.
Automatic board identification allows one software program runs on each of three hardware and motor
platforms without any change of parameters:
• Low Voltage Evaluation Motor Hardware Set
• Low Voltage Hardware Set
• High Voltage Hardware Set
The hardware setup is shown in Figure 6-1, Figure 6-2 and Figure 6-3. More information can also be found in
Section 12.1.
Notes: The detailed description of individual boards can be found in comprehensive user’s manuals belonging
to each board. The user’s manual incorporates the schematic of the board, description of individual
function blocks and bill of materials. The individual boards can be ordered from Freescale as a
standard product.
40w flat
U2 ribbon U1
cable
+12
J3
Evaluation Controller Board
GND Motor Board J1 J30
(P1) DSP56805EVM
12VDC (DSP56803EVM)
J2
M1 Motor
ECMTREVAL
IB23810
Figure 6-1. Low Voltage Evaluation Motor Hardware System Configuration
All the system parts are supplied and documented according the following references:
• M1 - IB23810 Motor
— supplied in kit with IB23810 Motor as: ECMTREVAL - Evaluation Motor Board Kit
• U2 3 ph AC/BLDC Low Voltage POWER STAGE:
— supplied in kit with IB23810 Motor as: ECMTREVAL - Evaluation Motor Board Kit
— described in: Evaluation Motor Board User’s Manual
• U1 CONTROLLER BOARD for 56F805:
— supplied as: 56F805EVM
— described in: 56F805 Evaluation Module Hardware User’s Manual
• or U1 CONTROLLER BOARD for 56F803:
— supplied as: 56F803EVM
— described in: 56F803 Evaluation Module Hardware User’s Manual
Information of all above mentioned boards and documents can be found on:
http://mot-sps.com/motor/devtools/index.html
40w flat
U2 ribbon U1
cable
3ph AC/BLDC
+12 J19 Low Voltage Controller Board
GND J20 Power Stage J13 J30
(P1) DSP56805EVM
12VDC
ECLOVACBLDC (DSP56803EVM)
J16 J17 J18
Black
White
Red
MB1 Motor-Brake
SM40N SG40N
J5
White
Black
ECMTRLOVBLDC
Red
All the system parts are supplied and documented according the following references:
• U1 Controller Board for 56F805:
— supplied as: 56F805EVM
— described in: 56F805 Evaluation Module Hardware User’s Manual
• or U1 Controller Board for 56F803:
— supplied as: 56F803EVM
— described in: 56F803 Evaluation Module Hardware User’s Manual
• U2 - 3 ph AC/BLDC Low Voltage Power Stage
— supplied as: ECLOVACBLDC
— described in: 3 Phase Brushless DC Low Voltage Power Stage
• MB1 - Motor-Brake SM40N + SG40N
— supplied as: ECMTRLOVBLDC
Information of all above mentioned boards and documents can be found on:
http://mot-sps.com/motor/devtools/index.html
+12V DC
GND
MB1 Motor-Brake
Red
ECOPTHIVACBLDC
SM40V SG40N
J5
ECMTRHIVBLDC
White
Black
Red
All the system parts are supplied and documented according the following references:
• U1 - Controller Board for 56F805:
— supplied as: 56F805EVM
— described in: Evaluation Module Hardware User’s Manual
• or U1 - Controller Board for 56F803:
— supplied as: 56F803EVM
— described in: 56F803 Evaluation Module Hardware User’s Manual
• U2 - 3 ph AC/BLDC High Voltage Power Stage
— supplied in kit with Optoisolation Board as: ECOPTHIVACBLDC
— described in: 3 Phase Brushless DC High Voltage Power Stage
• U3 - Optoisolation Board
— supplied with 3 ph AC/BLDC High Voltage Power Stage as: ECOPTHIVACBLDC
— or supplied alone as: ECOPT - ECOPT optoisolation board
— described in: Optoisolation Board User’s Manual
Warning: It is strongly recommended to use opto-isolation (optocouplers and optoisolation amplifiers) during
the development time to avoid any damage to the development equipment.
• MB1 Motor-Brake SM40V + SG40N
— supplied as: ECMTRHIVBLDC
Information for all boards and documents can be found at:
www.freescale.com
7. SW Design
This section describes the design of the software blocks of the drive. The software will be described in terms
of:
• Main Software Flow Chart
• Data Flow
• State Diagram
For more information of the used control technique see Section 5.
Reset
Initialize
Interrupt
OC Cmt Timer
Application State Machine:
Commutation Timer OC ISR:
precedes/sets requirements of:
Motor Commutation Timing
Drive Fault Status
Commutate. Control Proceed
Application Mode
Zero Crossing Setting
Omega Required Mechanical
Interrupt
Commutation Control OC Cmt2Timer
proceed Status_Commutation:
Running Speed/Alignment Timer OC ISR:
Starting set Speed Control Request
Alignment Alignment stage timing
Stopped
RTI
Check Run/Stop Switch
Interrupt
PWM A Reload
Interrupt
ADC complete PWM Reload ISR:
start ADC
memorize sampling time
ADC complete ISR: evaluate Zero Crossing
read Temperature
DC bus Voltage/Current
set Current Control Rq RTI
RTI
Interrupt Interrupt
Up Button Down Button
RTI RTI
Interrupt Interrupt
ADC Low Limit ADC High Limit
RTI RTI
Interrupt
PWM A Fault
RTI
Process
Application
State Machine
Status_Commutation
Process
Commutation Control
Omega_Actual_Mech
Process Process
Current PI Controller Speed PI Controller
U_Desired Step_Cmt,
Cmt_Drv_RqFlag
Process
PWM Generation
Protection processes are shown in Figure 7-4 and described in the following sub-sections.
Process
Fault Control
DriveFaultStatus
Process Process
Application PWM Generation
State Machine
.
Reference Corrected
Speed Speed Speed
(Omega_Desired) Error (U_Desired)
PI Controlled
Controller System
-
Actual Motor
Speed
(Omega_Actual)
The speed closed loop control is characterized by the feedback of the actual motor speed. This information is
compared with the reference set point and the error signal is generated. The magnitude and polarity of the error
signal corresponds to the difference between the actual and desired speed. Based on the speed error, the PI
controller generates the corrected motor voltage in order to compensate for the error.
The speed controller works with a constant execution (sampling) period. The request is driven from the timer
interrupt with the constant PER_SPEED_SAMPLE_S. The PI controller is proportional and integral
constants were set experimentally.
7.3.2 Initialize
In Main SW initialization provides following actions:
• CmdApplication = 0
• DriveFaultStatus = NO_FAULT
• PCB Motor Set Identification
— boardId function is used to detect one of 3 possible hardware sets. According to used hardware
one of three control constant sets are loaded (functions EVM_Motor_Settings,
LV_Motor_Settings, HV_Motor_Settings)
• ADC Initialization
• Led diodes initialization
• Switch (Start/Stop) initialization
• Push Buttons (Speed up/down) initialization
• Commutation control initialization
• PWM initialization
• PWM fault interrupts initialization
• Zero Crossing inputs = Quadrature decoder filter initialization
• Output Compare Timers initialization
Notes: The EVM board can be connected to the power stage boards. In order to assure the right hardware is
connected the board identification is performed. When inappropriate hardware is detected the
DriveFaultStatus|=WRONG_HARDWARE is set, motor remains stopped!
In manual control, the application is controlled with Start/Stop switch and Up Down Push buttons to set
Required Speed.
In PC master software control mode the Start/Stop is controlled manually and the Required Speed is set via the
PC master software.
The motor is stopped whenever the absolute value of Required speed is lower then Minimal Speed or switch
set to stop or if there is a system failure - Drive Fault (Emergency Stop) state is entered. All the SW processes
are controlled according this Application State Machine status.
PC Master Software
Up Button Down Button Required Speed setting
Reset
Bldc Run
Bldc Stop with Required Speed
Drive Fault
Drive Fault Drive Fault
Emergency Stop
Reset
Set Alignment
BLDC Run done
Alignment
Stopped Alignment Time-out
Starting
exceeded Maximal
Zero Crossing
Error commutations
Minimal commutations
with Zero Crossing OK
Running Set Running
passed
done
Figure 7-7. State Diagram - Process Commutation Control
registers are preset. If Zero Crossing already happen during Per_Toff time period, the commutation period is
corrected using Corrective Calculation 2. When the commutation time expires, then a new commutation is
performed.
Running - Begin
No Zero Crossing
detected during last motor Commutation
commutation period
commutation time
Calculate Next Commutation (T_Next) expired
after No Zero Crossing Zero Crossing
Corrective Calculation 1. Detected/Missed during last
commutation period
This state is almost wholly serviced by the BLDC Zero Crossing algorithms which are documented in Motor
Control.pdf, chapter BLDC Motor Commutation with Zero Crossing Sensing (see Section 12.1). First the
bldczcHndlr is called with actual time from Cmt Timer Counter to control requests and commutation control
registers. Other BLDC Zero Crossing algorithms are called, according to the request flags. The state services
are located in main loop and in Cmt (commutation) Timer Interrupt.
Reset
Commutation
Running
U_Desired =
Speed Control
PI (Reference Speed - Actual Motor Speed)
Disabled
Commutation
Speed Control Stopped/Alignment/Starting
Request
Speed Control
Timer Interrupt
(PER_SPEED_SAMPLE)
The Speed PI controller algorithm controllerPItype1 is described in the SDK documentation. The controller
execution (sampling) period is PER_SPEED_SAMPLE, period of Speed Control Timer Interrupt.
The Current PI controller algorithm controllerPItype1 is described in the SDK documentation. The controller
execution (sampling) period is determined by the PWM module period, because the ADC conversion is started
each PWM reload (once per PWM period). The Current Control Request is set in ADC Conversion Complete
Interrupt.
8. SDK Implementation
The Embedded SDK is a collection of APIs, libraries, services, rules and guidelines. This software
infrastructure is designed to let 56F8xx software developers create high-level, efficient, portable code. This
chapter describes how the BLDC motor control application with BEMF Zero Crossing is written under SDK.
• bldczcHndlrStop (stop handler for BLDC commutation control with BEMF Zero Crossing; BLDC.LIB
library)
• bldczcComputInit (computation initialization for BLDC commutation control with BEMF Zero
Crossing; BLDC.LIB library)
• bldczcComput (computation for BLDC commutation control with BEMF Zero Crossing; bldc.lib
library)
• bldczcCmtInit (commutation initialization for BLDC commutation control with BEMF Zero Crossing;
BLDC.LIB library)
• bldczcCmtServ (commutation serve for BLDC commutation control with BEMF Zero Crossing;
BLDC.LIB library)
• bldczcZCrosInit (zero crossing initialization for BLDC commutation control with BEMF Zero
Crossing; BLDC.LIB library)
• bldczcZCrosIntAlg (zero crossing interrupt algorithm for BLDC commutation control with BEMF
Zero Crossing; BLDC.LIB library)
• bldczcZCrosServ (zero crossing service for BLDC commutation control with BEMF Zero Crossing;
BLDC.LIB library)
• controllerPItype1 (calculation of PI controller; MCFUNC.LIB library)
• boardId (hardware board identification; BSP.LIB library)
8.4 Interrupts
The SDK serves the calling of interrupt routines and automatically clears interrupt flags. The user defines the
callback functions which are called during interrupts. The callback functions are assigned during the driver’s
opening. The callback function assignment is defined as one item of the initialization structure which is used as
input parameter of open function. Some drivers define the callback function in the appconfig.h file.
9. PC Master Software
PC master software was designed to provide the debugging, diagnostic and demonstration tool for
development of algorithms and application. It consists of components running on PC and parts running on the
target development board.
The PC master software application is part of the Embedded SDK and may be selectively installed during SDK
installation.
The baud rate of the SCI communication is 9600Bd. It is set automatically by the PC master software driver.
To enable the PC master software operation on the target board application, the following lines must be added
to the appconfig.h file:
#define SCI_DRIVER
#define INCLUDE_PCMASTER
This can be seen in the Software Design chapter of the SDK. It automatically includes the SCI driver and
installs all necessary services.
A detailed PC master software description is provided by the PC Master User Manual.
In the following text the EVM, LV, HV will be replaced by x. The sections is sorted in order recommended to
follow, when one is tuning/changing parameters.
Notes: Most important constants for reliable motor start-up are described in Section 11.2.2 and in
Section 11.1.2.
Notes: Note the hardware protection with setting of pots R116, R71 for 56F805EVM or R40, R45 for
56F803EVM (see EVM manuals for details)
Notes: If the overcurrent fault is experienced during Alignment stage, then it is recommended to slow down
the regulator. If the yy_GAIN_SCALE is increased, the gain is decreased.
Notes: For first tuning it is recommended to set this period high enough (e.g. 5s). Then, if the motor works
well it can be significantly lowered (e.g. 0.1s).
Notes: Setting of this constant is an empirical process. It is difficult to use a precise formula, because there are
many factors involved which are difficult to obtain in the case of a real drive (motor and load
mechanical inertia, motor electromechanical constants, and sometimes also the motor load). So they
need to be set with a specific motor.
Table 11-2 helps with setting of this constant.
Notes: Slowing down the speed regulator (see Section 11.3.1) helps if a problem with start up is encountered
using the above stated setting .
Notes: It is recommended to use the value 0x02 or 0x03 only. If this constant is set too high, the motor control
will not enter the Running stage fast enough.
Notes: During tuning of the software for other motors, this constant can be temporarily increased.
Notes: This constant needs to be lower than 1/3 of (minimal) commutation period at motor maximal speed.
The older versions of the software (SDK 2.2) used the constant with system units:
#define x_CONST_PERPROCCMT 100 /* Period of Commutation proceeding [1.7777us]*/
The unit of this constant is 1.777us. This constant is automatically calculated in newer SDK software versions.
Coef_CmtPrecompLShft
Coef_CmtPrecompFrac
fractional and scaling part of Coef_CmtPrecomp
final Coef_CmtPrecomp = Coef_CmtPrecompFrac << Coef_CmtPrecompLShft
this final Coef_CmtPrecomp determines the interval between motor commutations when no BEMF Zero
Crossing is captured. The application SW multiplies fractional Coef_CmtPrecomp with commutation period.
Coef_HlfCmt
determines Commutation advancing (retardation) - the interval between BEMF Zero Crossing and motor
commutation
The application SW multiplies fractional Coef_HlfCmt with commutation period.
Coef_Toff
determines the interval between BEMF Zero Crossing and motor commutation
The application SW multiplies fractional Coef_Toff with commutation period
Notes: Remember that minimal angular speed is not in radians, but in system units where 32768 is the maximal
speed done by x_SPEED_ROTOR_MAX_RPM
The speed PI regulator constants can be tuned as described below. All settings can be found in
bldcadczcdefines.h.
The execution period of the speed controller is set by:
#define PER_SPEED_SAMPLE_S 0.001 /* Sampling Period of the Speed Controller [s] */
Both proportional and integral gain have two coefficients: portion and scale.
Speed Proportional gain:
#define x_SPEED_PI_PROPORTIONAL_GAIN 22000 /* speed proportional gain portion*/
#define x_SPEED_PI_PROPORTIONAL_GAIN_SCALE 19 /* speed proportional gain scale*/
Notes: If the motor has problems when requested speed is changed, then it is recommended to slow down the
regulator. If the yy_GAIN_SCALE is increased, the gain is decreased.
The coefficients x_SPEED_PI_PROPORTIONAL_GAIN_REAL (resp.
x_SPEED_PI_INTEGRAL_TI_REAL) are not directly used for regulator setting, but can be used to calculate
x_SPEED_PI_PROPORTIONAL_GAIN, x_SPEED_PI_PROPORTIONAL_GAIN_SCALE (resp.
x_SPEED_PI_INTEGRAL_GAIN, x_SPEED_PI_INTEGRAL_GAIN_SCALE) using the formulae in the comments.
12. References
12.1 Software Development Kit, SDK Rev.2.2
• Targetting_DSP56805_Platform.pdf
— located at:
Embedded SDK\help\docs\sdk\targets\Targetting_DSP56805_Platform\content
• Targetting_DSP56803_Platform.pdf
— located at:
Embedded SDK\help\docs\sdk\targets\Targetting_DSP56803_Platform\content
• Motor Control.pdf, chapter BLDC Motor Commutation with Zero Crossing Sensing
— located at: Embedded SDK\help\docs\sdk\libraries\motorcontrol\content
E-mail:
[email protected]
Japan:
Freescale Semiconductor Japan Ltd.
Headquarters
ARCO Tower 15F
1-8-1, Shimo-Meguro, Meguro-ku,
Tokyo 153-0064, Japan Information in this document is provided solely to enable system and
0120 191014 or +81 3 5437 9125 software implementers to use Freescale Semiconductor products. There are
[email protected] no express or implied copyright licenses granted hereunder to design or
fabricate any integrated circuits or integrated circuits based on the
information in this document.
Asia/Pacific:
Freescale Semiconductor Hong Kong Ltd.
Technical Information Center Freescale Semiconductor reserves the right to make changes without further
notice to any products herein. Freescale Semiconductor makes no warranty,
2 Dai King Street
representation or guarantee regarding the suitability of its products for any
Tai Po Industrial Estate particular purpose, nor does Freescale Semiconductor assume any liability
Tai Po, N.T., Hong Kong arising out of the application or use of any product or circuit, and specifically
+800 2666 8080 disclaims any and all liability, including without limitation consequential or
[email protected] incidental damages. “Typical” parameters that may be provided in Freescale
Semiconductor data sheets and/or specifications can and do vary in different
For Literature Requests Only: applications and actual performance may vary over time. All operating
Freescale Semiconductor Literature Distribution Center parameters, including “Typicals”, must be validated for each customer
application by customer’s technical experts. Freescale Semiconductor does
P.O. Box 5405
not convey any license under its patent rights nor the rights of others.
Denver, Colorado 80217 Freescale Semiconductor products are not designed, intended, or authorized
1-800-441-2447 or 303-675-2140 for use as components in systems intended for surgical implant into the body,
Fax: 303-675-2150 or other applications intended to support or sustain life, or for any other
[email protected] application in which the failure of the Freescale Semiconductor product could
create a situation where personal injury or death may occur. Should Buyer
purchase or use Freescale Semiconductor products for any such unintended
or unauthorized application, Buyer shall indemnify and hold Freescale
Semiconductor and its officers, employees, subsidiaries, affiliates, and
distributors harmless against all claims, costs, damages, and expenses, and
reasonable attorney fees arising out of, directly or indirectly, any claim of
personal injury or death associated with such unintended or unauthorized
use, even if such claim alleges that Freescale Semiconductor was negligent
regarding the design or manufacture of the part.
AN1914
Rev. 1
11/2005