3-Phase PMSM Vector Control
3-Phase PMSM Vector Control
56800
Hybrid Controller
DRM063
Rev. 2
08/2004
freescale.com
3-Phase PMSM Vector Control
Designer Reference Manual
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc.
This product incorporates SuperFlash® technology licensed from SST.
© Freescale Semiconductor, Inc., 2004. All rights reserved.
Freescale Semiconductor 3
Revision History
The following revision history table summarizes changes contained in this document. For your
convenience, the page number designators have been linked to the appropriate location.
Revision History
Revision Page
Date Description
Level Number(s)
January
1 Limited initial release N/A
2003
August,
2 Reformatted to latest Freescale Semiconductor documentation standards Throughout
2004
4 Freescale Semiconductor
Table of Contents
Chapter 1
Introduction
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 Freescale DSP Advantages and Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Chapter 2
Control Theory
2.1 Permanent Magnet Synchronous Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Mathematical Description of PM Synchronous Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2.1 Space Vector Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Digital Control of PM Synchronous Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.3.1 Vector Control of PM Synchronous Motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.2 Block Diagram of Vector Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.3.3 Vector Control Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.3.1 Clarke Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3.3.2 Transformation from α,β to d-q Coord. and Backwards . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.3.3.3 Transformation from α,β to d-q Coord. and Backwards . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.3.4 PMSM Vector Control and Field-Weakening Controller. . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.4.1 Control in Normal Operating Range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.3.4.2 Control in Field-Weakening Range. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 3
System Concept
3.1 System Specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2 Vector Control Drive Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 System Blocks Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.1 Position and Speed Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.3.1.1 Position Sensing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.3.1.2 Speed Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.3.1.3 Minimum and Maximum Speed Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
3.3.1.4 Position Reset with Rotor Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.3.2 Current Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.3.3 Voltage Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.3.4 Power Module Temperature Sensing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Chapter 4
Hardware
4.1 Hardware Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.2 DSP56F805EVM Controller Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3 3-Phase AC BLDC High Voltage Power Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.4 In-Line Optoisolation Box. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.5 Motor-Brake Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Freescale Semiconductor 5
Table of Contents
Chapter 5
Software Design
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2 Main Software Flow Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.3 Data Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.3.1 Application Control Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.3.2 LED Indication Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.3.3 Analog Sensing Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.3.4 Position and Speed Measurement Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.3.5 PMSM (PM Synchronous Motor) Control Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.3.5.1 Current Control Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.3.5.2 Speed Ramp. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.3.5.3 Speed, Alignment Control Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.3.5.4 Field-Weakening Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.3.6 Brake Control Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.3.7 Brake Control Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.3.8 PWM Generation Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.3.9 Fault Control Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.4 State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.4.1 DSP Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.4.2 Application Control State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5.4.3 PMSM Control State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4.4 Fault Control State Diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4.5 Analog Sensing State Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.5 Implementation Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.5.1 Scaling of Quantities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.5.1.1 Voltage Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
5.5.1.2 Current Scaling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.5.1.3 Speed Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
5.5.1.4 Position Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1.5 Temperature Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1.6 PI Controller Tuning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1.7 Subprocesses Relation and State Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.5.1.8 Run/Stop Switch and Button Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Chapter 6
Application Setup
6.1 Application Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.1 Control Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.1.2 Drive Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.2 Application Set-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.2.1 PM Synchronous Motor Versus BLDC Motor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.2.2 DSP56F805EVM Application Set-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.3 Projects Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.4 Application Build and Execute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6 Freescale Semiconductor
Chapter 1
Introduction
1.1 Introduction
This paper describes the design of a 3-phase Permanent Magnet (PM) synchronous motor drive based
on Freescale’s DSP56F805 dedicated motor control device.
PM synchronous motors are very popular in a wide application area. The PM synchronous motor lacks a
commutator and is therefore more reliable than the DC motor. The PM synchronous motor also has
advantages when compared to an AC induction motor. Because a PM synchronous motor achieves
higher efficiency by generating the rotor magnetic flux with rotor magnets, a PM synchronous motor is
used in high-end white goods (such as refrigerators, washing machines, dishwashers); high-end pumps;
fans; and in other appliances which require high reliability and efficiency.
The concept of the application is a speed closed-loop PM synchronous drive using a Vector Control
technique. It serves as an example of a PM synchronous motor control design using a Freescale DSP.
This reference design includes basic motor theory, system design concept, hardware implementation,
and software design, including the PC master software visualization tool.
Freescale Semiconductor 7
Introduction
Program Flash 8188 x 16-bit 32252 x 16-bit 32252 x 16-bit 61436 x 16-bit
In addition to the fast Analog-to-Digital converter and the 16-bit Quadrature Timers, the most interesting
peripheral, from the PM synchronous motor control point of view, is the Pulse Width Modulation (PWM)
module. The PWM module offers a high degree of freedom in its configuration, allowing efficient control
of the PM synchronous motor.
The PWM has the following features:
• Three complementary PWM signal pairs, or 6 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 1 to 16
• Individual software-controlled PWM outputs
• Mask and swap of PWM outputs
• Programmable fault protection
• Polarity control
• 20 mA current sink capability on PWM pins
• Write-protectable registers
8 Freescale Semiconductor
Freescale DSP Advantages and Features
The PM synchronous motor control utilizes the PWM block set in the complementary PWM mode,
permitting generation of control signals for all switches of the power stage with inserted deadtime. The
PWM block generates three sine wave outputs mutually shifted by 120 degrees.
The Analog-to-Digital Converter (ADC) consists of a digital control module and two analog sample and
hold (S/H) circuits. It has the following features:
• 12-bit resolution
• Maximum ADC clock frequency is 5 MHz with 200 ns period
• Single conversion time of 8.5 ADC clock cycles (8.5 x 200 ns = 1.7 µs)
• Additional conversion time of 6 ADC clock cycles (6 x 200 ns = 1.2 µs)
• Eight conversions in 26.5 ADC clock cycles (26.5 x 200 ns = 5.3 µs) using simultaneous mode
• ADC can be synchronized to the PWM via the sync signal
• Simultaneous or sequential sampling
• Internal multiplexer to select 2 of 8 inputs
• Ability to sequentially scan and store up to 8 measurements
• Ability to simultaneously sample and hold 2 inputs
• Optional interrupts at end of scan, if an out-of-range limit is exceeded, or at zero crossing
• Optional sample correction by subtracting a preprogrammed offset value
• Signed or unsigned result
• Single-ended or differential inputs
The application utilizes the ADC block in simultaneous mode and sequential scan. It is synchronized with
PWM pulses. This configuration allows the simultaneous conversion within the required time of required
analog values, of all phase currents, voltage and temperature.
The Quadrature Timer is an extremely flexible module, providing all required services relating to time
events. It has the following features:
• Each timer module consists of four 16-bit counters/timers
• Count up/down
• Counters are cascadable
• Programmable count modulo
• Maximum count rate equals peripheral clock/2 when counting external events
• Maximum count rate equals peripheral clock when using internal clocks
• Count once or repeatedly
• Counters are preloadable
• Counters can share available input pins
• Each counter has a separate prescaler
• Each counter has capture and compare capability
The PM synchronous motor vector control application utilizes four channels of the Quadrature Timer
module for position and speed sensing. A fifth channel of the Quadrature Timer module is set to generate
a time base for speed sensing and a speed controller.
Freescale Semiconductor 9
Introduction
The Quadrature Decoder is a module providing decoding of position signals from a Quadrature Encoder
mounted on a motor shaft. It has the following features:
• Includes logic to decode quadrature signals
• Configurable digital filter for inputs
• 32-bit position counter
• 16-bit position difference counter
• Maximum count frequency equals the peripheral clock rate
• Position counter can be initialized by software or external events
• Preloadable 16-bit revolution counter
• Inputs can be connected to a general purpose timer to aid low speed velocity.
The PM synchronous motor vector control application utilizes the Quadrature Decoder connected to a
Quad Timer module A. It uses the decoder’s digital input filter to filter the encoder’s signals, but does not
make use of its decoding functions, freeing the decoder’s digital processing capabilities to be used by
another application.
10 Freescale Semiconductor
Chapter 2
Control Theory
Stator
Stator winding
(in slots)
Shaft
Rotor
Air gap
Permanent magnets
In this respect, the PM synchronous motor is equivalent to an induction motor, where the air gap magnetic
field is produced by a permanent magnet, so the rotor magnetic field is constant. PM synchronous motors
offer a number of advantages in designing modern motion control systems. The use of a permanent
magnet to generate substantial air gap magnetic flux makes it possible to design highly efficient PM
motors.
Freescale Semiconductor 11
Control Theory
β
phase- b
is β
The space vector defined by (2-2) can be expressed utilizing two-axis theory. The real part of the space
vector is equal to the instantaneous value of the direct-axis stator current component, isα, and whose
imaginary part is equal to the quadrature-axis stator current component, isβ. Thus, the stator current space
vector, in the stationary reference frame attached to the stator can be expressed as:
i s = i sα + ji sβ (2-3)
In symmetrical three-phase machines, the direct and quadrature axis stator currents isα, isβ are fictitious
quadrature-phase (two-phase) current components, which are related to the actual three-phase stator
currents as follows:
i sα = k i sa – --- i sb – --- i sc
1 1
(2-4)
2 2
3
i sβ = k ------- ( i sb – i sc ) (2-5)
2
where k=2/3 is a transformation constant.
12 Freescale Semiconductor
Mathematical Description of PM Synchronous Motor
The space vectors of other motor quantities (voltages, currents, magnetic fluxes etc.) can be defined in
the same way as the stator current space vector.
For a description of the PM synchronous motor, the symmetrical three-phase smooth-air-gap machine
with sinusoidally-distributed windings is considered. The voltage equations of stator in the instantaneous
form can then be expressed as:
d
u SA = R S i SA + ψ SA (2-6)
dt
d
u SB = R S i SB + ψ SB (2-7)
dt
d
u SC = R S i SC + ψ SC (2-8)
dt
where uSA, uSB, and uSC are the instantaneous values of stator voltages, iSA, iSB, and iSC are the
instantaneous values of stator currents, and ψSA, ψSB, ψSC are instantaneous values of stator flux
linkages, in phase SA, SB, and SC.
Due to the large number of equations in the instantaneous form, the equations (2-6), (2-7), and (2-8), it is
more practical to rewrite the instantaneous equations using two axis theory (Clarke transformation). The
PM synchronous motor can be expressed as:
d
u Sα = R S i Sα + Ψ Sα (2-9)
dt
d
u Sβ = R S i Sβ + Ψ Sβ (2-10)
dt
Ψ Sα = L S i Sα + Ψ M cos ( Θ r ) (2-11)
Ψ Sβ = L S i Sβ + Ψ M sin ( Θ r ) (2-12)
dω p 3
= --- --- p ( Ψ Sα i Sβ – Ψ Sβ i Sα ) – T L (2-13)
dt J 2
where:
α,β is the stator orthogonal coordinate system
uSα,β is the stator voltage
iSα,β is the stator current
ΨSα,β is the stator magnetic flux
ΨM is the rotor magnetic flux
RS is the stator phase resistance
LS is the stator phase inductance
ω / ωF is the electrical rotor speed / fields speed
p is the number of poles per phase
J is the inertia
TL is the load torque
Θr is the rotor position in α,β coordinate system
Freescale Semiconductor 13
Control Theory
The equations (2-9) through (2-13) represent the model of PM synchronous motor in the stationary frame
α, β fixed to the stator.
Besides the stationary reference frame attached to the stator, motor model voltage space vector
equations can be formulated in a general reference frame, which rotates at a general speed ωg. If a
general reference frame is used, with direct and quadrature axes x,y rotating at a general instantaneous
speed ωg = dθg/dt, as shown in Figure 2-3, where θg is the angle between the direct axis of the stationary
reference frame (α) attached to the stator and the real axis (x) of the general reference frame, then (2-14)
defines the stator current space vector in general reference frame:
– jθ g
i sg = i s e = i sx + ji sy (2-14)
y β
14 Freescale Semiconductor
Mathematical Description of PM Synchronous Motor
The stator voltage and flux-linkage space vectors can be similarly obtained in the general reference
frame.
Similar considerations hold for the space vectors of the rotor voltages, currents and flux linkages. The real
axis (rα) of the reference frame attached to the rotor is displaced from the direct axis of the stator
reference frame by the rotor angle θr. Since it can be seen that the angle between the real axis (x) of the
general reference frame and the real axis of the reference frame rotating with the rotor (rα) is θg-θr, in the
general reference frame, the space vector of the rotor currents can be expressed as:
–j ( θg – θr )
i rg = i r e = i rx + ji ry (2-15)
where i r is the space vector of the rotor current in the rotor reference frame.
The space vectors of the rotor voltages and rotor flux linkages in the general reference frame can be
similarly expressed.
The motor model voltage equations in the general reference frame can be expressed by utilizing
introduced transformations of the motor quantities from one reference frame to the general reference
frame. The PM synchronous motor model is often used in vector control algorithms. The aim of vector
control is to implement control schemes which produce high dynamic performance and are similar to
those used to control DC machines. To achieve this, the reference frames may be aligned with the stator
flux-linkage space vector, the rotor flux-linkage space vector or the magnetizing space vector. The most
popular reference frame is the reference frame attached to the rotor flux linkage space vector, with direct
axis (d) and quadrature axis (q).
After transformation into d-q coordinates, the motor model as follows:
d
u Sd = R S i Sd + Ψ Sd – ω F Ψ Sq (2-16)
dt
d
u Sq = R S i Sq + Ψ Sq + ω F Ψ Sd (2-17)
dt
Ψ Sd = L S i Sd + Ψ M (2-18)
Ψ Sq = L S i Sq (2-19)
dω p 3
= --- --- p ( Ψ Sd i Sq – Ψ Sq i Sd ) – T L (2-20)
dt J 2
By considering that below base speed isd = 0, the equation (2-20) can be reduced to the following form:
dω p 3
= --- --- p ( Ψ M i Sq ) – T L (2-21)
dt J 2
From the equation (2-21), it can be seen that the torque is dependent and can be directly controlled by
the current isq only.
Freescale Semiconductor 15
Control Theory
Q1 Q3 Q5
C1
Q2 Q4 Q6
GND
Phase_A Phase_B Phase_C
Figure 2-4. 3-Phase Inverter
The inverter consists of three half-bridge units where the upper and lower switches are controlled
complimentarily, meaning when the upper one is turned on, the lower one must be turned off, and vice
versa. Because the power device’s turn off time is longer than its turn on time, some deadtime must be
inserted between the turn off of one transistor of the half-bridge, and the turn on of its complementary
device. The output voltage is mostly created by a pulse width modulation (PWM) technique, where an
isosceles triangle carrier wave is compared with a fundamental-frequency sine modulating wave, and the
natural points of intersection determine the switching points of the power devices of a half bridge inverter.
This technique is shown in Figure 2-5. The 3-phase voltage waves are shifted 120° to each other and,
thus, a 3-phase motor can be supplied.
Generated PWM Carrier
Sine Wave Wave
1
0
ωt
-1
1
PWM Output T
1 0
(Upper Switch)
ωt
1
PWM Output T
2 0
(Lower Switch)
16 Freescale Semiconductor
Digital Control of PM Synchronous Motor
The most popular power devices for motor control applications are Power MOSFETs and IGBTs.
A Power MOSFET is a voltage-controlled transistor. It is designed for high-frequency operation and has
a low voltage drop; thus, it has low power losses. However, the saturation temperature sensitivity limits
the MOSFET application in high-power applications.
An insulated-gate bipolar transistor (IGBT) is a bipolar transistor controlled by a MOSFET on its base. The
IGBT requires low drive current, has fast switching time, and is suitable for high switching frequencies.
The disadvantage is the higher voltage drop of a bipolar transistor, causing higher conduction losses.
Freescale Semiconductor 17
18
Control Theory
Speed Line Input
3-Phase PMSM Vector Control Designer Reference Manual, Rev. 2
Command USq_lin
- - USd USα
Decoupling
Space - Vector
USq
Modulation
USβ
Motor Flux
Command USd_lin
ΨRd pwm a
pwm b
pwm c 3-Phase Power Stage
ISq
ISα ISa
Rotor Flux
Forward Park Position Rotor Flux Forward Clarke ISb
ISd
Transformation Calculation ISβ Transformation ISc
AC Induction
Motor
Speed Speed
Sensor
β
phase- b
iS
iSβ
iSb - measured iSa - measured
iSα α, phase-a
iSc - calculated
phase- c
Figure 2-7. Clarke Transformation
1 1
1 – --- – --- a
α = K 2 2
(2-22)
b
β 3 3
0 ------- – ------- c
2 2
Freescale Semiconductor 19
Control Theory
In most cases, the 3-phase system is symmetrical, which means that the sum of the phase quantities is
always zero.
α = K a – --- b – --- c =
1 1 3
a+b+c = 0 = K --- a (2-23)
2 2 2
The constant “K” can be freely chosen and equalizing the α-quantity and a-phase quantity is
recommended. Then:
2
α = a ⇒ K = --- (2-24)
3
We can fully define the Park-Clarke transformation:
2 1 1
--- – --- – --- a 1 0 0 a
α = 3 3 3
(2-25)
b = a+b+c = 0 = 1 1 b
------- – -------
β 0
1 1
------- – ------- c
0
3 3 c
3 3
In most cases, the 3-phase system is symmetrical, which means that the sum of the phase quantities is
always zero.
α = K a – --- b – --- c =
1 1 3
a+b+c = 0 = K --- a (2-27)
2 2 2
The constant “K” can be freely chosen and equalizing the α-quantity and a-phase quantity is
recommended. Then:
2
α = a ⇒ K = --- (2-28)
3
We can fully define the Park-Clarke transformation:
2 1 1
--- – --- – --- a 1 0 0 a
α = 3 3 3
(2-29)
b = a+b+c = 0 = 1 1
------- – ------- b
β 0
1 1
------- – ------- c
0
3 3 c
3 3
20 Freescale Semiconductor
Digital Control of PM Synchronous Motor
Ψ Mβ
sin ϑ Field = -------------
Ψ Md
(2-31)
Ψ Mα
cos ϑ Field = --------------
Ψ Md
q β
ΨM d
ΨMβ ϑField
α
ΨMα
Figure 2-8. Establishing the d-q Coord. System (Park Transformation)
Freescale Semiconductor 21
Control Theory
nominal speed
stator voltage us
u_sdq_max
stator current id
Figure 2-9. Normal Operation and Field-Weakening
In the normal operating range, the current torque-producing component isq can be set up to I_SDQ_MAX,
since isd = 0.
Due to the voltage limitation, the maximum speed in the normal motor operating range is limited for isd = 0,
to a nominal motor speed as shown in Figure 2-9 and (2-34).
22 Freescale Semiconductor
Digital Control of PM Synchronous Motor
One possibility to maintain the flux-producing current component isd for field weakening is to use a look-up
table.
A more-progressive method uses a Field-Weakening Controller, which generates a negative current
flux-producing component isq, whenever the absolute value of stator voltage exceeds u_S_max_FWLimit.
The field-weakening limit u_S_max_FWLimit is set to be close to the maximum voltage limit of the
3-phase power inverter u_sdq_max with some reserve for regulation. Since the DCBus voltage
determines the u_sdq_max limit, the u_S_max_FWLimit is set according to the DCBus. The
u_S_max_FWLimit can be a constant or it can be calculated from a measured DCBus voltage. The
Field-Weakening controller is described in 5.3.5.4 Field-Weakening Process.
Freescale Semiconductor 23
Control Theory
24 Freescale Semiconductor
Chapter 3
System Concept
Freescale Semiconductor 25
System Concept
U_Dc bus
AC
Line AC
PMSM
6
DC LOAD
Free Master UP DOWN START
STOP Quadrature
Temperature
Encoder
Faults Isa Isb Isc
PWM
SCI
GPIO ADC Quad
SCI GPIO PWM PWM Timer
Driver GPIO Driver
GPIO Driver ADC Driver QT Driver
PWM Driver PWM Driver
Break
Application Fault Protection Control Dutycycle a
Dutycycle b Is_a
Control Dutycycle c Is_b
U_dcb Is_c
Omega_ Req
Sinus Sector
waveform
Modulation
Is_q_Req
Omega_ Req Us_alpha_comp
Current q Us_beta_comp Position
(Back-EMF feedforward)
Speed PI &
Controller Controller Us_alpha
Speed
Decoupling
Sensing
Us_q
Inverse Park DC-bus U_dcb
Omega_ atual_mech
Transformation ripple
d,q->alpha,beta compensation
Weakening
Us_d
Controller
Us_beta
Field
Current d
PI
Controller sin theta_atual_el
cos
Omega_ atual_mech
DSP56F80x
26 Freescale Semiconductor
System Blocks Concept
When the Start command is accepted (using the Start/Stop Switch or PC master software command), the
required speed is calculated according to the Up/Down push buttons or PC master software commands.
The required speed proceeds through an acceleration/deceleration ramp, and a reference command is
put to the speed controller. The actual speed is calculated from the pulses of the quadrature encoder. The
comparison between the required speed command and the actual measured speed generates a speed
error. Based on the error, the speed controller generates a current, Is_qReq, which corresponds to torque.
A second part of stator current Is_dReq, which corresponds to flux, is given by the Field-Weakening
Controller. Simultaneously, the stator currents Is_a, Is_b, and Is_c are measured and transformed from
instantaneous values into the stationary reference frame α, β, and consecutively into the rotary reference
frame d-q (Park - Clarke transformation). Based on the errors between required and actual currents in the
rotary reference frame, the current controllers generate output voltages Us_q and Us_d (in the rotary
reference frame d-q). The voltages Us_q and Us_d are transformed back into the stationary reference
frame α, β, and, after DCBus ripple elimination, are recalculated to the 3-phase voltage system, which is
applied to the motor.
Beside the main control loop, the DCBus voltage, DCBus current and power stage temperature are
measured during the control process. They are used for overvoltage, undervoltage, overcurrent, and
overheating protection of the drive. The undervoltage and overheating protection is performed by
software, while the overcurrent and overvoltage fault signal utilizes a fault input of the DSP.
If any of the previously-mentioned faults occur, the motor control PWM outputs are disabled in order to
protect the drive, and the fault state of the system is displayed by the on-board LED.
A hardware error is also detected if the wrong power stage is used. Each power stage contains a simple
module generating a logic sequence unique for that type of power stage. During chip initialization, this
sequence is read and evaluated according to the decoding table. If the correct power stage is identified,
the program can continue. In the case of wrong hardware, the program stays in an infinite loop, displaying
the fault condition.
This means that the zero position is linked with the index pulse, but Vector Control requires the zero
position, where the rotor is aligned to the d axis; see 3.3.1.4 Position Reset with Rotor Alignment.
Therefore, using a quadrature decoder to decode the encoder’s signal requires either the calculation of
an offset which aligns the quadrature decoder position counter with the aligned rotor position (zero
position), or the coupling of the zero rotor position with the index pulse of a quadrature encoder. To avoid
Freescale Semiconductor 27
System Concept
the calculation of the rotor position offset, the quadrature decoder is not used in this application. The
decoder’s digital processing capabilities are then free to be used by another application.
In addition to the quadrature decoder, the input signals (Phase A, Phase B, and Index) are connected to
quad timer module A. The quad timer module consists of four quadrature timers. Due to the wide
variability of quad timer modules, it is possible to use this module to decode quadrature encoder signals,
sense position, and speed. A configuration of the quad timer module is shown in Figure 3.3.
28 Freescale Semiconductor
System Blocks Concept
Freescale Semiconductor 29
System Concept
where:
ωmin Minimum obtainable speed [rpm]
N Number of pulses per revolution [1/rev]
Tcalc Period of speed measurement (calculation period) [s]
In the application, the quadrature encoder has 1024 pulses per revolution and a calculation period of
900 µs was chosen on the basis of a motor mechanical constant. Thus, Equation 3-2 calculates the
minimum speed as 16.3 rpm.
The maximum speed can be expressed as:
60
ω max = ---------------------------- (3-3)
4NT clkT2
where:
ωmax Maximum obtainable speed [rpm]
N Number of pulses per revolution [1/rev]
TclkT2 Period of input clock to timer A2 [s]
Substitution in (3-3) for N and TclkT2 (timer A2 input clock = system clock 36 MHz/2) yields a maximum
speed of 263672 rpm. As demonstrated, the algorithm can measure speed across a wide range. Because
such high speed is not practical, the maximum speed can be reduced to a required range by the constant
k in (3-1). The constant k can be calculated as:
60
κ = −−−−−−−−−−−−−−−−−−−−−−−−−− (3-4)
4NT clkT2 ω µαξ
where:
k Scaling constant in (3-1)
ωmax Maximum of the speed range [rpm]
N Number of pulses per revolution [1/rev]
TclkT2 Period of input clock to timer A2 [s]
In this application, the maximum measurable speed is limited to 6000 rpm.
NOTE
To ensure an accurate speed calculation, you must choose the input clock
of timer A2 so that the calculation period of speed processing (in this case,
900 µs) is represented in timer A2 as a value lower than 0x7FFFH
(900.10-6/TclkT2<=0x7FFFH).
30 Freescale Semiconductor
System Blocks Concept
d α
Figure 3-5. Rotor Alignment
Alignment
Iq=0 Iq=0
Id=IAlignment Id=0
End
Freescale Semiconductor 31
System Concept
Q1 Q3 Q5
SKB04N60 SKB04N60 SKB04N60
Q2 Q4 Q6
SKB04N60 SKB04N60 SKB04N60
R318 75k-1%
R320 10k-1%
6 1.65V +/- 1.65V @ +/- Imax
I_sense_C1 -
7
I_sense_C
I_sense_C2 5 +
R321 10k-1%
R322 U301B
R323 390 75k-1% MC33502D
1.65V ref
+3.3V_A
+
R324
8
LM285M R325
U304 33k-1%
GNDA
4
GNDA
As shown in Figure 3-7, the currents cannot be measured at any moment. For example, the current flows
through Phase A (and shunt resistor R1) only if transistor Q2 is switched on. Likewise, the current in
Phase B can be measured if transistor Q4 is switched on, and the current in Phase C can be measured
if transistor Q6 is switched on. To get a moment of current sensing, a voltage shape analysis must be
done.
The voltage shapes of two different PWM periods are shown in Figure 3-11. The voltage shapes
correspond to center-aligned PWM sine wave modulation. As shown, the best moment of current
sampling is in the middle of the PWM period, where all bottom transistors are switched on.
To set the exact moment of sampling, the DSP56F805 family offers the ability to synchronize ADC and
PWM modules via the SYNC signal. This exceptional hardware feature, patented by Motorola, is used for
current sensing. The PWM outputs a synchronization pulse, which is connected as an input to the
synchronization module TC2 (Quad Timer C, counter/timer 2). A high-true pulse occurs for each reload
32 Freescale Semiconductor
System Blocks Concept
of the PWM, regardless of the state of the LDOK bit. The intended purpose of TC2 is to provide a
user-selectable delay between the PWM SYNC signal and the updating of the ADC values. A conversion
process can be initiated by the SYNC input, which is an output of TC2. The time diagram of the automatic
synchronization between PWM and ADC is shown in Figure 3-9.
PWM COUNTER
PWM SYNC
PWM
GENERATOR
OUTPUTS 0, 1
dead-time/2 dead-time/2
PWM
PINS 0, 1
POWER
STAGE dead-time dead-time
VOLTAGE
TC2
COUNTER
t1
TC2
OUTPUT
t2
ADC
CONVERSION
ADC
ISR
However, all three currents cannot be measured from one voltage shape. The PWM period II in
Figure 3-11 shows a moment when the bottom transistor of Phase A is switched on for a very short time.
If the on-time is shorter than a critical time, the current can not be accurately measured. The critical time
is given by hardware configuration (transistor commutation times, response delays of the processing
electronics, etc.). Therefore, only two currents are measured and a third current is calculated from the
following equation:
0 = iA + iB + iC
(3-5)
A decision must now be made about which phase current should be calculated. The simplest technique
is to calculate the current of the most positive voltage phase. For example, Phase A generates the most
positive voltage within section 0 - 60°, Phase B within section 60° - 120°, and so on; see Figure 3-11.
Freescale Semiconductor 33
System Concept
I. II.
PWM PERIOD PWM RELOAD
PHASE_A
PHASE_B
PHASE_C
0.8
duty cycle ratios
0.6
0.4
Phase A
0.2 Phase B
Phase C
0
0 60 120 180 240 300 360
angle
NOTE
The sector value is used for current calculation only, and has no other
meaning in the sine wave modulation. But if we use any type of space
vector modulation, we can get the sector value as part of space vector
calculation.
34 Freescale Semiconductor
System Blocks Concept
+3.3V_A
R1
2.2k - 1%
Temp_sense
D1 D2
BAV99LT1 BAV99LT1 C1
100nF
Freescale Semiconductor 35
System Concept
36 Freescale Semiconductor
Chapter 4
Hardware
U2 U1
40w flat ribbon cable
L
J11.1
N J11.2 3ph AC/BLDC
J30
High Voltage
PE J14 (P1) DSP5680xEVM
Power Stage J1
100 - 240VAC
49 - 61 Hz RS232 JTAG
J13.1 J13.2 J13.3
White
Black
Red
DSP56F803 P4 DSP56F803 J1
Red
Freescale Semiconductor 37
Hardware
38 Freescale Semiconductor
DSP56F805EVM Controller Board
enable the user to easily specify complex break conditions and to execute user-developed
software at full-speed, until the break conditions are satisfied. The ability to examine and modify all
user accessible registers, memory and peripherals through the OnCE port greatly facilitates the
task of the developer.
• Serving as a platform for hardware development. The hardware platform enables the user to
connect external hardware peripherals. The on-board peripherals can be disabled, providing the
user with the ability to reassign any and all of the DSP's peripherals. The OnCE port's unobtrusive
design means that all of the memory on the board and on the DSP chip are available to the user.
The DSP56F805EVM provides the features necessary for a user to write and debug software,
demonstrate the functionality of that software and interface with the customer's application-specific
device(s). The DSP56F805EVM is flexible enough to allow a user to fully exploit the DSP56F805's
features to optimize the performance of their product, as shown in Figure 4-2.
DSP56F805
RESET 4-Channel
RESET SPI
LOGIC 10-bit D/A
Freescale Semiconductor 39
Hardware
HV POWER
INPUT SWITCH MODE PFC CONTROL
POWER SUPPLY dc BUS BRAKE
3-PHASE IGBT
POWER MODULE
3-PHASE AC
SIGNALS GATE
TO
TO/FROM DRIVERS MOTOR
CONTROL PHASE CURRENT
BOARD PHASE VOLTAGE
BUS CURRENT
BUS VOLTAGE
MONITOR
BOARD
ID BLOCK
ZERO CROSS
BACK-EMF SENSE
40 Freescale Semiconductor
In-Line Optoisolation Box
The electrical characteristics in Table 4-1 apply to operation at 25°C with a 160-Vdc power supply voltage.
Freescale Semiconductor 41
Hardware
The electrical characteristics in Table 4-2 apply to operation at 25°C, and a 12-Vdc power supply voltage.
Min logic 1 input voltage (JTAG) VIH 2.0 — — V LVT logic (3.3 V)
Max Logic 0 input voltage (JTAG) VIL — — 0.8 V LVT logic (3.3 V)
42 Freescale Semiconductor
Chapter 5
Software Design
5.1 Introduction
This section describes the design of the drive’s software blocks. The software description comprises
these topics:
• Main Software Flow Chart
• Data Flow
• State Diagram
For more information on the system blocks used, refer to 3.2 Vector Control Drive Concept.
Freescale Semiconductor 43
Software Design
Reset
DSP Initialization
44 Freescale Semiconductor
Main Software Flow Chart
Interrupt Interrupt
ADC Complete Down Button
PMSM Control
-Current Processing:
proceeds according to pmsmCtrlStatus Interrupt
Up Button
sin cos generation:
get position from Position Mea-
surement Up Button — ISR part:
sin (theta_actual_el) if debounceCounterUp = 0:
cos (theta_actual_el) set UP_BUTTON, buttonStatus
debounceCounterUp =
= DEBOUNCE_VALUE
Current Control:
Currents Transformation (a,b,c to d-q)
(Field-Weakening Controller)
Return
Current d Regulator
Current q Regulator
Voltages Transformation (d-q to α,β)
DCBus Ripple Compensation
Space Vector Module sets pwmABC
Interrupt
PWM A Fault
PWM:
set duty cycles to pwmABC
Fault Control — PWM Fault ISR part:
if Overcurrent or Overvoltage:
Analog Sensing-ADC Phase Set {set appFaultStatus = Overvoltage /
set ADC converter phase current Overcurrent
samples - two (easily measured) triggers beginning of Fault State (disable PWM...)}
phases
Return
Return
Freescale Semiconductor 45
Software Design
Interrupt
D0 QTimer
PMSM Control
Speed, Alignment Processing:
proceeds according to its status
pmsmCtrlStatus?
AlignFlag RunFlag
others
Return
46 Freescale Semiconductor
Data Flow
Application LED
Indication
Control brakeCtrlStatus
faultCtrlStatus
theta_align_el_C i_Sd_Alignment
PMSM
Control
I_SDQ_MAX
reloadSWtmrSpeedControl
SVM_INV_INDEX,
reloadSWtmrAlignment pwmABC u_Reserve_FW
SVM_INV_INDEX,
u_OverMax
PWM Generation
coefBEMF, coefBEMFShift
PWM Outputs
Freescale Semiconductor 47
Software Design
PWM Faults
TEMPERATURE_MAX_F16 (Overvoltage/Overcurrent)
temperature_filt
u_dc_bus_min_fault_C i_Sabc_comp
Check Index
Position
u_dc_bus_filt
faultCtrlStatus
Fault Control
u_dc_bus_on_brake
brakeCtrlStatus
PWM Generation
PWM Outputs
IO_BRAKE
The data flows consist of the processes described in the following sections.
48 Freescale Semiconductor
Data Flow
coefBEMFShft (5-1)
u_SDQ.q_axis = coefBEMF ⋅ 2 ⋅ omega_actual_mech + u_SDQ_lin.q_axis
u_SDQ.d_axis = u_SDQ_lin.d_axis
(5-2)
The u_SDQ voltages are transformed into u_SAlphaBeta (see 2.3.4 PMSM Vector Control and
Field-Weakening Controller) by the Voltage Transformation process. The Scaling DCBus Ripple
Compensation block scales u_SAlphaBeta (according u_dc_bus_filt) to u_Salpha_RipElim, described in
the svmlimDcBusRip function in the Motor Control Library. The space vector modulation process
generates duty cycle pwmABC and svmSector according to u_Salpha_RipElim.
The u_LimitF16 is a voltage limit for current controllers. The u_OverMax constant is used to increase the
limitation of u_SDQ voltages over maximum SVM_INV_INDEX/2*u_dc_bus_filt determined by the DCBus
voltage and space vector modulation. Although the pwmABC will be limited by the space vector
modulation process functions, the reserve is used for field-weakening controller dynamics. In the stable
state, the u_SDQ voltages vector will not exceed u_S_max_FWLimit; see 5.3.5.4 Field-Weakening
Process.
Freescale Semiconductor 49
Software Design
omega_required_mech
Speed Ramp
reloadSWtmrAlignment Control reloadSWtmrSpeedControl
PIRegParams_omega_mech.
theta_align_el_C PositivePILimit
Speed, Align
Control Field-Weakening
theta_actual_el
u_SDQ
i_SDQ_desired i_SDQ_desired
Sin, Cos q_axis d_axis
Transformation
pmsmCtrlStatus u_dc_bus_filt
sinCos_theta_el
i_Sabc_comp
svmSector
50 Freescale Semiconductor
Data Flow
i_Sabc_comp sinCos_theta_el
Current Transformation
a,b,c -> d-q
u_LimitF16 I_SDQ_MAX_F16
Current q Current d
Regulator Regulator
omega_actual_mech
u_SDQ_lin.q_axis u_SDQ_lin.d_axis
pmsmCtrlStatus
coefBEMF, coefBEMFShift
Feed Forward
sinCos_theta_el u_SDQ
u_LimitF16
Voltage Transformation
d-q -> alpha, beta
SVM_INV_INDEX/2*
*u_dc_bus_filt +
+u_OverMax
u_SAlphaBeta
Scaling
DCBus Ripple
Compensation
u_dc_bus_filt SVM_INV_INDEX,
u_OverMax
u_Salpha_RipElim
Space Vector
Modulation
pwmABC svmSector
Freescale Semiconductor 51
Software Design
SVM_INV_INDEX/2*u_dc_bus_filt-u_Reserve_FW
0 - I_SDQ_MAX_F16
u_S_max_FWLimit
u_SD.d_axis +
max limit min limit i_SDQ_desired.d_axis
2 2 1/2 -
(d_axis +q_axis )
u_SD.q_axis PI regulator
2 2
PIRegParams_omega_mech.PositivePILimit = I_SDQ_MAX_F16 – i_SDQ_desired.d_axis (5-3)
2 2
PIRegParams_omega_mech.NegativePILimit = – I_SDQ_MAX_F16 – i_SDQ_desired.d_axis (5-4)
52 Freescale Semiconductor
State Diagram
Freescale Semiconductor 53
Software Design
Reset
DSP
Initialization
done
Application Control:
switchState = Stop &
Fault Control: faults cleared Init
Initializations proceeding
appState = APP_INIT
Init Fault Control (pcb identification)
set appOpMode
switchState = Stop
Fault Control: Begin Fault
After reset, the DSP Initialization state is entered. The peripherals and variables are initialized in this state,
and the application operating mode appOpMode is set to Manual Control.
When the state is finished, the Application Control Init state follows. As shown in Figure 5-9, appState =
APP_INIT; all subprocesses requiring initialization are proceeding; pcb identification is provided; the
PWM is disabled; and so no voltage is applied on motor phases.
If the appPcmCtrlStatus.RequestCtrl flag is set from PC master software, the application operating mode
appOpMode is toggled and the application operating mode can only be changed in this state. If the
switchState = Stop, the Application Control enters the Stop state.
The switchState is set according to the manual switch on the EVM or PC master software register
AppPcmCtrlStatus.StartStopCtrl, depending on the application operating mode.
In the Stop state, appState = APP_STOP and the PWM is disabled, so no voltage is applied on motor
phases. When switchState = Run, the Begin Run state is processed. If there is a request to change
application operating mode, appPcmCtrlStatus.RequestCtrl = 1, the application Init is entered and the
application operating mode request can only be accepted in the Init or Stop state by transition to the Init
state.
In the Begin Run state, all the processes provide settings to the Run state.
54 Freescale Semiconductor
State Diagram
In the Run state, the PWM is enabled, so voltage is applied on motor phases. The motor is running
according to the state of all subprocesses. If switchState = Stop, the Stop state is entered.
If and fault is detected during the Begin Fault state, which is a subprocess of Fault control, the Begin Fault
state is entered. It sets appState = APP_FAULT; the PWM is disabled; and the subprocess PMSM Control
is set to Stop. The Fault state can only move onto the Init state when switchState = Stop, and the Fault
Control subprocess has successfully cleared all faults.
PMSM Control:
Initialization
clear AlignInitDoneFlag
Application Control: Begin Running
done pmsmCtrlStatus.AlignInitDoneFlag = No
done
PMSM Control: PMSM Control:
Stop or Fault Begin Alignment
set Alignment current
PMSM Control: set Alignment timeout
Begin Running
Begin Stop or Fault set AlignFlag done
AlignInitDoneFlag = 1
clear RunFlag
clear AlignFlag
Application Control: Begin Stop/Fault PMSM Control:
Alignment
timeout search
Current ramp
done
PMSM Control:
PMSM Control: Alignment Timeout
Begin Run
Run set RunFlag PMSM Control:
End Alignment
done Set Zero Position
set AlignInitDoneFlag
clear AlignFlag
When Application Control initializes, the PMSM Control subprocess initialization state is entered. The
AlignInitDoneFlag is cleared, which means that alignment can proceed. The next PMSM Control state is
Begin Stop or Fault. RunFlag and AlignFlag are cleared and the Stop or Fault state is entered. When
Application Control: Begin Run, the PMSM Control subprocess enters the Begin Alignment or Begin Run
state, depending on whether or not the alignment initialization has already proceeded (flagged by
AlignInitDoneFlag). The alignment state is necessary for setting the zero position of position sensing; see
3.3.1.4 Position Reset with Rotor Alignment. In the state Begin Alignment, the Alignment current and
duration are set; the alignment is provided by setting desired current for d_axis to i_Sd_Alignment and q_axis
to 0. The alignment state provides current control and timeout search. When alignment timeout occurs,
Freescale Semiconductor 55
Software Design
End Alignment is entered. In that state, the Position Sensing Zero Position is set, so the position sensor
is aligned with the real vector of the rotor flux. When the End Alignment state ends, the PMSM Control
enters a regular Run state, where the motor is running at the required speed. If the Application Control
state is set to Begin Stop or Begin Fault, the PMSM Control enters the Begin Stop or Fault, then the Stop
or Fault.
Reset
Fault Control:
DSP Initialization
Fault Control:
Application Initialization
clear appFaultStatus
pcb identification
done
Fault Control:
No Fault
searching faults
Fault:
Undervoltage (filtered)
Overheating (filtered)
Overcurrent (fault pin)
Overvoltage (fault pin)
wrong PCB
Position Sensing fault
Fault Control:
Begin Fault
Application Control Begin Fault
setting of appFaultStatus
PWMEN bit = 0
done
Fault Control:
Fault
clear/test faults
56 Freescale Semiconductor
Implementation Notes
Analog Sensing
DSP Initialization
Analog Sensing
Analog Sensing
Init Finished:
Init Done,
samples average
normal operation:
set current offsets
done
set InitDoneFlag
Freescale Semiconductor 57
Software Design
The following equation shows the relationship between the real and fractional representations:
Real Value
Fractional Value = -------------------------------------------------------------------- (5-6)
Real Quantity Range Max
where:
Fractional Value is the fractional representation of the real value [Frac16]
Real Value is the real value of the quantity [V, A, RPM, etc.]
Real Quantity Range Max is the maximum of the quantity range, defined in the application
[V, A, RPM, etc.]
The C language standard does not have any fractional variable type defined. Therefore, fractional
operations are provided by CodeWarrior intrinsics functions (e.g. mult_r() ). As a substitution for the
fractional type variables, the application uses types Frac16 and Frac32. These are in fact defined as
integer 16-bit signed variables and integer 32-bit signed variables. The difference between Frac16 and
pure integer variables is that Frac16 and Frac32 declared variables should only be used with fractional
operations (intrinsics functions).
A recalculation from real to a fractional form and Frac16, Frac32 value is made with the following
equations:
Real Value
Frac16 Value = 32768 ⋅ -------------------------------------------------------------------- (5-7)
Real Quantity Range Max
for Frac16 16-bit signed value and:
31 Real Value
Frac32 Value = 2 ⋅ -------------------------------------------------------------------- (5-8)
Real Quantity Range Max
for Frac32 32-bit signed value.
Real Value
Fractional Value = -------------------------------------------------------------------- (5-9)
Real Quantity Range Max
Fractional form, a conversion from Fraction Value to Frac16 and Frac32 Value can be provided by the C
language macro.
58 Freescale Semiconductor
Implementation Notes
Freescale Semiconductor 59
Software Design
The relation between speed scaling and speed measurement with encoder is described in 3.3.1.2 Speed
Sensing. In the final software, the constant OMEGA_SCALE is identical with the scaling constant k in
equations (3-1) and (3-3), and OMEGA_RANGE_MAX is ωMax.
60 Freescale Semiconductor
Implementation Notes
replaced by a software flag. The following algorithm is used to check the state of the IRQ line and is
described for one interrupt.
The IRQ interrupt is set to be negative-level-sensitive. When the button is pressed, the logical level 0 is
applied on the IRQ line and the interrupt occurs; see Figure 5-13. To avoid multiple calls of ISR due to
contact bounces, the ISR disables the IRQ interrupt, sets the debounce counter to a predefined value and
sets the variable buttonStatus to 1. The variable buttonStatus represents the interrupt flag. Using the
DSP56F80x’s software timer, the ButtonProcessing function is periodically called, as shown in
Figure 5-13. The function ButtonProcessing decrements the debounce counter and if the counter is 0, the
IRQ interrupt is again enabled. The button press is checked by the ButtonEdge function; see Figure 5-14.
When the variable buttonStatus is set, the ButtonEdge function returns “1” and clears buttonStatus. When
the variable buttonStatus is not set, the ButtonEdge function returns “0”.
According to the ButtonProcessing calling period, the value of the debounce counter should be set close
to 180ms. This value is sufficient to prevent multiple IRQ ISR calls due to contact bounces.
Decrement debounce
Disable IRQ Interrupt
counter
Set buttonStatus
No
Debounce counter = 0
Return
Return
ButtonEdge
No
buttonStatus=1
Yes
Clear buttonStatus
Return 1 Return 0
Freescale Semiconductor 61
Software Design
62 Freescale Semiconductor
Chapter 6
Application Setup
NOTE
The application software is targeted for PM Synchronous motor with
sine-wave Back-EMF shape. In this particular demo application, the BLDC
motor is used instead, due to the availability of the BLDC motor-Brake
SM40V+SG40N, supplied as ECMTRHIVBLDC. Although the Back-EMF
shape of this motor is not ideally sine-wave, it can be controlled by the
application software. The drive parameters will be improved when a PMSM
motor with an exact sine-wave Back-EMF shape is used.
Freescale Semiconductor 63
Application Setup
64 Freescale Semiconductor
Application Description
When the Start command is accepted (using the RUN/STOP Switch or PC master software command),
the rotor position is aligned to a predefined position to obtain a known rotor position. The rotor alignment
is done at the first start command only. Required speed is then calculated according to UP/DOWN push
buttons or PC master software commands (if in PC master software remote mode). The required speed
goes through an acceleration/deceleration ramp. The comparison between the actual speed command
and the measured speed generates a speed error. Based on the error, the speed controller generates a
stator current Is_qReq, which corresponds to torque. A second part of the stator current Is_dReq, which
corresponds to flux, is given by the Field Weakening Controller. Simultaneously, the stator currents Is_a,
Is_b and Is_c are measured and transformed from instantaneous values to the stationary reference frame
α, β and consecutively to the rotary reference frame d-q (Clarke-Park transformation). Based on the errors
between required and actual currents in the rotary reference frame, the current controllers generate
output voltages Us_q and Us_d (in the rotary reference frame d-q). The voltages Us_q and Us_d are
transformed back to the stationary reference frame α, β and, after DC Bus ripple elimination, are
recalculated to the 3-phase voltage system which is applied on the motor.
Freescale Semiconductor 65
Application Setup
66 Freescale Semiconductor
Application Description
Freescale Semiconductor 67
Application Setup
NOTE
If the PC master software project (.pmp file) is unable to control the
application, it is possible that the wrong load map (.elf file) has been
selected. PC master software uses the load map to determine addresses
for global variables being monitored. Once the PC master software project
has been launched, this option may be selected in the PC master software
window under Project/Select Other Map FileReload.
68 Freescale Semiconductor
Application Set-Up
WARNING
Danger, high-voltage--risk of electric shock!
The application PCB modules and serial interface (connector, cable)
are not electrically isolated from the mains voltage--they are live.
Use the In-line Optoisolation Box (ECOPTINL) between the PC and
DSP56805 EVM as protection from dangerous voltage on the PC-user
side, and to prevent damage to the PC and other hardware.
Do not touch any part of the EVM or the serial cable between the EVM
and the In-line Optoisolation Box unless you are using an insulation
transformer. The application is designed to be fully controllable only
from PC master software.
To avoid inadvertently touching live parts, use plastic covers.
In the rest of this application, the description supposes use of the
insulation transformer.
The correct order of phases (phase A, phase B, phase C) for the PM Synchronous motor is:
• phase A = white wire
• phase B = red wire
• phase C = black wire
When facing a motor shaft, if the phase order is: phase A, phase B, phase C, the motor shaft should rotate
clockwise (i.e., positive direction, positive speed).
For detailed information, see the DSP56F805 Evaluation Module Hardware Reference Manual. The serial
cable is needed for the PC master software debugging/control.
The system consists of the following components:
• BLDC Motor Type SM 40 V, EM Brno s.r.o., Czech Republic
• Load Type SG 40N, EM Brno s.r.o., Czech RepublicDSP56F805 Board:
• Encoder BHK 16.05A1024-12-5, Baumer Electric, Switzerland
• 3-ph AC BLDC HiV Power Stage 180W
• In-line Optoisolation Box (ECOPTINL) + JTAG cable
• Two serial cables - needed for the PC master software debugging tool only.
• The parallel cable - needed for the Metrowerks Code Warrior debugging and s/w loading.
Freescale Semiconductor 69
Application Setup
9 7 3 3
2 8 7
1 6 4 2
JG6 3 1 1 1
3 JG14 JG12 JG13 1
JG10 2
JG4
3 1 USER
9
6
3
7
4
J23 J24
3 1
1 3 3
JG14 2 2
JG10
JG17 1 1
PWM
JG15 Y1
JG6
1
JG12 JG13
1 DSP56F805EVM JTAG
JG4
1
JG16
JG15 JG1 JG2 1
1 JG18
1 U1 JG16 J29
JG1 1
JG3 JG8 JG8
S/N
U15
3 S4 S5 S6
JG7
JG9 1
JG5
GP1 GP2 RUN/STOP U9 U10
S1 S2 S3
JG11
P1 P1 JG5
1 LED3
P3 IRQA IRQB RESET
JG2
3
70 Freescale Semiconductor
Projects Files
NOTE
When running the EVM target system in a stand-alone mode from Flash,
the JG5 jumper must be set in the 1-2 configuration to disable the command
converter parallel port interface.
Freescale Semiconductor 71
Application Setup
The project may now be built by executing the Make command, as shown in Figure 6-7. This will build
and link the Three-Phase PM Synchronous Motor Vector Control Application and all needed Metrowerks
and Quick_Start libraries.
72 Freescale Semiconductor
Application Build and Execute
To execute the Three-Phase PM Synchronous Motor Vector Control application, select Project\Debug in
the CodeWarrior IDE, followed by the Run command. For more help with these commands, refer to the
CodeWarrior tutorial documentation in the following file located in the CodeWarrior installation folder:
<...>\CodeWarrior Documentation\PDF\Targeting_DSP56800.pdf
If the Flash target is selected, CodeWarrior will automatically program the internal Flash of the DSP with
the executable generated during Build. If the External RAM target is selected, the executable will be
loaded to off-chip RAM.
Once Flash has been programmed with the executable, the EVM target system may be run in a
stand-alone mode from Flash. To do this, set the JG5 jumper in the 1-2 configuration to disable the
parallel port, and press the RESET button.
Once the application is running, move the RUN/STOP switch to the RUN position and set the required
speed using the UP/DOWN push buttons. Pressing the UP/DOWN buttons should incrementally increase
the motor speed until it reaches maximum speed. If successful, the motor will be spinning.
NOTE
If the RUN/STOP switch is set to the RUN position when the application
starts, toggle the RUN/STOP switch between the STOP and RUN positions
to enable motor spinning. This is a protection feature that prevents the
motor from starting when the application is executed from CodeWarrior.
You should also see a lighted green LED, which indicates that the application is running. If the application
is stopped, the green LED will blink at a 2 Hz frequency. If an Undervoltage fault occurs, the green LED
will blink at a frequency of 8 Hz.
Freescale Semiconductor 73
Application Setup
74 Freescale Semiconductor
Appendix A
References
1. Design of Brushless Permanent-magnet Motors, J.R. Hendershot JR and T.J.E. Miller, Magna
Physics Publishing and Clarendon Press, 1994
2. Brushless DC Motor Control using the MC68HC708MC4, AN1702/D, John Deatherage and Jeff
Hunsinger, Motorola
3. DSP56F805 Evaluation Module Hardware User’s Manual, DSP56F805EVMUM/D, Motorola
4. 3-Phase AC/BLDC High-Voltage Power Stage User’s Manual, MEMC3PBLDCPSUM/D, Motorola,
2000
5. DSP56F800 Family Manual, DSP56F800FM/D, Motorola
6. Evaluation Motor Board User’s Manual, MEMCEVMBUM/D, Motorola
7. Embedded Software Development Kit for 56800/56800E, MSW3SDK000AA, available on
Freescale SPS web page, Motorola, 2001
8. Sensorless Vector and Direct Torque Control, P. Vas (1998), Oxford University Press, ISBN
0-19-856465-1, New York.
9. Elektricke pohony, Caha, Z.; Cerny, M. (1990), SNTL, ISBN 80-03-00417-7, Praha.
10. Freescale SPS web page: http://www.freescale.com
11. CodeWarrior for Motorola DSP56800 Embedded Systems, CWDSP56800, Metrowerks 2001
12. DSP56F805 Evaluation Module Hardware User’s Manual, DSP56F805EVMUM/D, Motorola 2001
13. Motorola Embedded Motion Control 3-Phase AC BLDC High-Voltage Power Stage Stage User’s
Manual, ECOPTHIVACBLDC, Motorola 2000
14. Motorola Embedded Motion Control In-Line Optoisolation Box User’s Manual, MEMCILOBUM/D,
Motorola 2000
15. User Manual for PC master software, Motorola 2001
16. DSP56800_Quick_Start User’s Manual, MCSL 2002
17. Motor Control Algorithms Description, MCSL 2002
Freescale Semiconductor 75
3-Phase PMSM Vector Control Designer Reference Manual, Rev. 2
76 Freescale Semiconductor
Appendix B
Glossary
AC — Alternating Current
ADC — See “analogue-to-digital converter”
brush — A component transferring electrical power from non-rotational terminals, mounted on the stator,
to the rotor
BLDC — Brushless dc motor
commutation — A process providing the creation of a rotation field by switching of power transistor
(electronic replacement of brush and commutator)
commutator — A mechanical device alternating DC current in DC commutator motor and providing
rotation of DC commutator motor
COP — Computer Operating Properly timer
DC — Direct Current
DSP — Digital Signal Processor
DSP56F80x — A Freescale family of 16-bit DSPs dedicated for motor control
DT — see “Dead Time (DT)”
Dead Time (DT) — short time that must be inserted between the turning off of one transistor in the inverter
half bridge and turning on of the complementary transistor due to the limited switching speed of
the transistors
duty cycle — A ratio of the amount of time the signal is on versus the time it is off. Duty cycle is usually
represented by a percentage.
GPIO — General Purpose Input/Output
Hall Sensors — A position sensor giving six defined events (each 60 electrical degrees) per electrical
revolution (for 3-phase motor)
HV — High Voltage (115 V AC or 230 V AC)
interrupt — A temporary break in the sequential execution of a program to respond to signals from
peripheral devices by executing a subroutine
input/output (I/O) — Input/output interfaces between a computer system and the external world. A CPU
reads an input to sense the level of an external signal and writes to an output to change the level
on an external signal
JTAG — Interface allowing On-Chip Emulation and Programming
LED — Light Emitting Diode
Freescale Semiconductor 77
logic 1 — A voltage level approximately equal to the input power voltage (VDD)
logic 0 — A voltage level approximately equal to the ground voltage (VSS)
LV — Low Voltage (12 V DC)
PI controller — Proportional-Integral controller
phase-locked loop (PLL) — A clock generator circuit in which a voltage controlled oscillator produces
an oscillation which is synchronized to a reference signal
PM — Permanent Magnet
PMSM — Permanent Magnet Synchronous Motor
PWM — Pulse Width Modulation
Quadrature Decoder — A module providing decoding of position from a quadrature encoder mounted
on a motor shaft
Quad Timer — A module with four 16-bit timers
reset — To force a device to a known condition
RPM — Revolutions per minute
SCI — See “serial communication interface module (SCI)”
serial communications interface module (SCI) — A module that supports asynchronous
communication
serial peripheral interface module (SPI) — A module that supports synchronous communication
software — Instructions and data that control the operation of a microcontroller
software interrupt (SWI) — An instruction that causes an interrupt and its associated vector fetch
SPI — See “serial peripheral interface module (SPI)”
timer — A module used to relate events in a system to a point in time
78 Freescale Semiconductor
How to Reach Us: Information in this document is provided solely to enable system and software implementers to use
Freescale Semiconductor products. There are no express or implied copyright licenses granted
USA/Europe/Locations not listed: hereunder to design or fabricate any integrated circuits or integrated circuits based on the information
Freescale Semiconductor Literature Distribution in this document.
P.O. Box 5405, Denver, Colorado 80217
1-800-521-6274 or 480-768-2130 Freescale Semiconductor reserves the right to make changes without further notice to any products
herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the
Japan:
suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any
Freescale Semiconductor Japan Ltd.
SPS, Technical Information Center liability arising out of the application or use of any product or circuit, and specifically disclaims any
3-20-1, Minami-Azabu and all liability, including without limitation consequential or incidental damages. “Typical” parameters
Minato-ku
which may be provided in Freescale Semiconductor data sheets and/or specifications can and do
Tokyo 106-8573, Japan
81-3-3440-3569 vary in different applications and actual performance may vary over time. All operating parameters,
including “Typicals” must be validated for each customer application by customer’s technical experts.
Asia/Pacific:
Freescale Semiconductor does not convey any license under its patent rights nor the rights of others.
Freescale Semiconductor H.K. Ltd.
2 Dai King Street Freescale Semiconductor products are not designed, intended, or authorized for use as components
Tai Po Industrial Estate in systems intended for surgical implant into the body, or other applications intended to support or
Tai Po, N.T. Hong Kong
sustain life, or for any other application in which the failure of the Freescale Semiconductor product
852-26668334
could create a situation where personal injury or death may occur. Should Buyer purchase or use
Learn More: Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall
For more information about Freescale
indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and
Semiconductor products, please visit
http://www.freescale.com 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.
Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other
product or service names are the property of their respective owners.
© Freescale Semiconductor, Inc. 2004.
DRM063
Rev. 2, 08/2004