Sensorless Field Oriented Control for PMSM Motors

Application Note, V1.0, May 2007
AP08059
XC886/888 CM/CLM
8-Bit Flash Microcontroller
Sensorless Field Oriented Control for
PMSM Motors
Microcontrollers
Edition 2007-05
Published by
Infineon Technologies AG
81726 München, Germany
© Infineon Technologies AG 2007.
All Rights Reserved.
LEGAL DISCLAIMER
THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION
OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY
DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY, CONDITION OR QUALITY OF THE
INFINEON TECHNOLOGIES COMPONENT. THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY
ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION. INFINEON TECHNOLOGIES HEREBY
DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND (INCLUDING WITHOUT
LIMITATION WARRANTIES OF NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY
THIRD PARTY) WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE.
Information
For further information on technology, delivery terms and conditions and prices please contact your nearest
Infineon Technologies Office (www.infineon.com).
Warnings
Due to technical requirements components may contain dangerous substances. For information on the types in
question please contact your nearest Infineon Technologies Office.
Infineon Technologies Components may only be used in life-support devices or systems with the express written
approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure
of that life-support device or system, or to affect the safety or effectiveness of that device or system. Life support
devices or systems are intended to be implanted in the human body, or to support and/or maintain and sustain
and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may
be endangered.
AP08059
Sensorless Field Oriented Control for PMSM Motors
XC886/888 CM/CLM
Revision History: V1.0, 2007-05
Previous Version(s):
none
Page
Subjects (major changes since last revision)
We Listen to Your Comments
Any information within this document that you feel is wrong, unclear or missing at all?
Your feedback will help us to continuously improve the quality of this document.
Please send your proposal (including a reference to this document) to:
[email protected]
Application Note
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
1
1.1
1.2
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Motor Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Three Phase Inverter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2
2.1
2.2
2.3
2.3.1
2.3.2
2.3.3
2.4
Sensorless Field Oriented Control (FOC) . . . . . . . . . . . . . . . . . . . . . . . .
Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Space Vector Pulse Width Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Acquisition of Actual Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Current Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Estimation of the Rotor Position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Rotational Speed Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Key Features of XC886/888 which enable Field Oriented Control . . . . . . .
5
5
6
7
8
8
8
9
3
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.2.7
3.2.8
3.2.9
3.2.10
3.2.11
3.2.12
3.2.13
3.2.14
3.3
FOC Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Timer2 Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CCU6 Timer12 Period Match Interrupt (CCU6_viNode2) . . . . . . . . . . . . .
Node2 Interrupt Disabled . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Current Measurement and Calculation . . . . . . . . . . . . . . . . . . . . . . . . .
Phase Current Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Clark Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flux Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Vector Rotation e-jj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Speed Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Speed Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Current Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Vector Rotation e+jj . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transformation Carthesian to Polar Coordinates . . . . . . . . . . . . . . . . .
Space Vector Modulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Update of CapCom6 and ADC Configuration . . . . . . . . . . . . . . . . . . . .
Release Shadow Transfer T13 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CCU6 Timer13 Period Match Interrupt (CCU6_viNode3) . . . . . . . . . . . . .
10
11
11
12
12
14
14
14
18
18
19
20
21
21
22
24
25
25
Application Note
1
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Introduction
1
Introduction
Field Oriented Control (FOC) is increasingly being used in consumer and industrial
motor control owing to the higher efficiency, better dynamic response and less torque
ripple. Typically a 16 or 32-bit MCU or DSP is required to handle the complex
trigonometric equations. Infineon’s XC886/888 offers the full benefits of FOC at a fraction
of the cost compared to a DSP/DSC solution.
Compared to today’s solution on the market, where FOC execution engages the whole
central processing unit‘s (CPU) load, FOC execution on Infineon’s XC886 and XC888
microcontrollers only requires 58% of the CPU’s performance providing ample
headroom for other applications. Unlike most hard-coded competitive FOC
implementations, Infineon provides the additional benefit of software reprogrammability
adding flexibility and potential for differentiation to the application. Field Oriented Control
implemented on an 8-bit MCU is the perfect answer to energy related regulations and
pricing pressure for appliance manufacturers.
1.1
Motor Theory
Motors rotate due to the torque produced by two interacting magnetic fields. On the one
hand, there is the magnetic field from the permanent magnets mounted to the rotor. On
the other hand, there is the magnetic field generated by the coils of the stator. The
force F , exerted on a current I carrying conductor with length l in the magnetic field B ,
which is called Lorentz force, is defined as F = – ( B × l ) ⋅ I .
When a force is given to a rotating system, it is called torque. It is defined by a linear
force multiplied by a radius: τ = r × F . The maximum torque is produced when the
magnetic vector of the rotor is at 90° to the magnetic vector of the stator, because the
poles of the rotor are forced to rotate in the direction of the stator field. The mechanical
power Pmech is proportional to the angular speed ω. It is the torque which defines the
ratio: P mech = τ ⋅ ω . On the other hand, the mechanical force is proportional to the
current though the coils and the back EMF (electromotive force): Pelec = I * Vbemf.
IU
S
-IW
N
Torque_BC.emf
Figure 1
Magnetic Vectors in Block Commutation
Application Note
2
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Introduction
See Figure 1 for an illustration of the different vectors. The blue and red arrows
represent the magnetic field caused by the stator coils. The big white arrow is the
resulting stator field. The magnetic dipole represents the rotor field and the arrows at the
poles (light red and green) represent the torque at the rotor.
In block commutation mode, the stator field is generated by a current flow through
alternately two of the tree coils. The remaining third coil can be used to monitor the
voltage of the connection point of the coils. By this information, the back EMF, a
sensorless control can be achieved by moving the magnetic field blockwise sector by
sector. As a result the stator magnetic vector is almost always misaligned with the rotor,
causing an inconsistency in the amount of applied torque (torque ripple). Torque ripple
can cause many problems, including mechanical wear, vibration, noise, and deficiencies
in drive performance.
With sinusoidal commutation all three coils are used. As a result, the stator field will be
stronger than in block commutation. See Figure 2 for an illustration of the different
vectors at sinusoidal commutation.
IU
-IW
S
N
-I V
Torque_SC.emf
Figure 2
Magnetic Vectors at Sinusoidal Commutation
With sinusoidal commutation, the currents in the three coils follow a sine-wave which is
phase shifted by an angle of 120°. As a result, the force created by the electromagnetic
space vector is smoothly rotated along, so that the stator vector remains at a 90-degree
angle from the rotor vector. An ideal motor with a sinusoidal drive does not show any
torque ripple.
Application Note
3
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Introduction
1.2
Three Phase Inverter
An inverter is an electronic circuit for converting direct current (DC) to alternating current
(AC). A basic three-phase inverter consists of three single-phase inverter switches each
connected to one of the three load terminals.
+
DC
-
Figure 3
Inverter.emf
Three Phase Inverter with Motor
Figure 3 shows an inverter realized with MOSFETs which are preferred for low voltage
drives. At high voltages, IGBTs are the common choice. In the current path of the DC
terminals (+ and -) a shunt is available to measure the DC link current IDClink.
The inputs of the power devices are connected via a driver circuit to the PWM outputs of
the microcontroller. In order to avoid destruction of the devices, the switching and delay
times of the system (driver and power switch) have to be considered. The time which is
needed to delay the activation of one side after deactivation of the other side is called
the deadtime of the inverter. Please refer to Figure 4 for details.
IN_H
TdH(off )
TdH(on)
Tdeadtime
IN_L
TdL(on)
Tdeadtime
TdL(off )
Tris eH
IOUT
TfallL
t
TdL(on)
t
TfallH
Tris eL
TfallL
Tdriv erdelay(ris e)
Tdriverdelay(fall )
t
driverdelay.emf
Figure 4
Timings During Switching
The timings can vary for the high-side and low-side switches as well as for switching on
and off the power stages. When the dead time of the system is undercut, the high-side
and the low-side switch is conducting current at the same time and a cross current
begins to flow. The cross current bypasses the load and short-circuits the DC terminals.
The PWM unit of XC886/888 CM/CLM provides an integrated deadtime control which
ensures proper control of the power stages at minimum software effort.
Application Note
4
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Sensorless Field Oriented Control (FOC)
2
Sensorless Field Oriented Control (FOC)
A sensorless field oriented control (FOC) satisfies the advantages of a sinusoidal
commutation by a minimum of system cost. Next to the inverter, there is just one shunt
in the DC link necessary to acquire the phase currents.
2.1
Block Diagram
2Φ Rotor System
2Φ Stator System
3Φ Stator System
3Φ PMSM
Motor
0
Reference
Speed
+
-
ω
Speed
Controller
+
+
-
Id
Controller
Iq
Controller
Vd
ejϕ
Vector
Rotation
Vq
ϕ
Speed
Calculation
Space
Vector
Modulator
Vβ
V
W
with
integrated
deadtime
control
Flux
Estimator
Id
Iq
PWM-Unit
U
Vα
Iα
e-jϕ
Vector
Rotation
Iβ
Current
Calculation
&
3Φ to 2Φ
IDClink
shunt
FOC_Blockdiagram .emf
Figure 5
Block Diagram of Sensorless FOC
Figure 5 shows the block diagram of the sensorless speed control with field oriented
control (FOC) of a permanent magnet synchronous motor (PMSM). From a control point
of view, the FOC is comparable with that of a dc motor. The basic concept is a cascade
control with the important difference that the electrical variables (Vd, Id, Vq and Iq) are
turning with the rotor. Thus the currents measured at the stator (Iα and Iβ) have to be
transformed into the rotor coordinates (Id and Iq). The PI-controller for the currents is
realized in the rotating system, whereas the field exciting d-component and the torque
exciting q-component is controlled separately.
The speed controller adjusts - as for a dc motor - the reference value for the torque
exciting current Iq. Due to the permanent magnets at the rotor, the reference value for
the field exciting current Id is set to zero.
The output of the current controllers represents the reference voltages (Vd and Vq) in the
rotor coordinates. These values are transformed into the stator coordinates (Vα and Vβ)
in order to calculate the polar coordinates (norm and angle).
Using space vector pulse width modulation, the norm and angle values are converted to
three phase currents by modulating the high-side and low-side switches of the power
inverter.
Application Note
5
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Sensorless Field Oriented Control (FOC)
2.2
Space Vector Pulse Width Modulation
In order to drive a three phase EC-motor with sinusoidal phase currents using a power
inverter, the phase angle and norm of the torque vector can be generated by space
vector pulse with modulation.
A
B
C
IU
[100]
D
IV
[110]
E
F
IW
[010]
[011]
[001]
[100]
0]
[0 1
N
S
S
N
[1 1
0]
[101]
N
C
[011]
D
B
E
S
A
[100]
F
N
S
S
N
N
S
1]
[0 0
1]
[1 0
Motor.emf
Figure 6
Space Vector Pulse With Modulation - Sectors
In a three-phase inverter, the three outputs can supply voltage at the motor to create one
of six active states (100, 110, 010, 011, 001, 101). In addition, two inactive states that
produce no voltage to the motor are possible (000, 111).
Application Note
6
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Sensorless Field Oriented Control (FOC)
A space vector is a sinusoid whose center is able to "float" in space. The inactive states
are used as an off time during the switching period when creating the space vector.
A three-phase space vector are represented by a hexagon which can be divided in six
sectors. Any desired voltage-space vector will consist of a "real" voltage from one of the
phases and an "imaginary" right-angle voltage created from the other two phases.
The space-vector algorithm will determine the time required at a first active state, a
second active state, and an inactive state to produce the desired magnitude and angle
of the space vector. See Figure 7 for an example in sector A. The first active state (b&f)
is TU, the second active state (c&e) is T-W, the inactive state is T0 which appears twice,
first as (000) vector (a&f), second as (111) vector (d).
TPWM
VU
t
VV
t
VW
a
b
c
d
e
f
g
T0/2
TU
T-W
T0
T-W
TU
T0/2
t
IDClink
t
SVPWM .emf
Figure 7
Voltage Space Vector - Sector A
If we translate the voltage waveform to the phasor diagram, we can see that the spacevector-modulation technique has a maximum predictable voltage of V DC ⋅ 3 . A spacevector-modulation system does not constrain the phasor center, yielding a 15% increase
in available motor voltage.
For a smooth rotation, it is the control of the sinusoidal current, not the shape of the
voltage waveform that generates the magnetomotive force.
2.3
Acquisition of Actual Values
In order to estimate the rotor position by a single shunt measurement, the PWM pattern
generation and the triggering of the ADC for current measurement must be very fast and
accurate. Any jitter in the triggerpoint will influence the actual rotor’s angle estimation. As
a result, the total harmonic distortion of the sinusoidal current signals will increase.
Application Note
7
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Sensorless Field Oriented Control (FOC)
2.3.1
Current Measurement
The XC886/888 CM/CLM offers an event based hardware trigger from CapCom6E unit,
used for generating the inverter signals, towards the ADC. The ADC provides in total four
result registers, from which two are used to hold the appropriate DC-link current values
IDClink. The ADC sample time is as low as 250 ns. As the current is measured in time slot
(b) and (e) of Figure 7, there is always enough time for conversion available.
2.3.2
Estimation of the Rotor Position
The voltage model is a simple model for rotating field motors which is based on
dedicated differential equations. In order to determine the actual angle, the flux vector
can be calculated by integrating the voltage. The integration can be simplified by
replacing the integration by a lowpass filter with a very low cut-off frequency.
Ψ = ∫ ( v s – i s ⋅ R ) dt – ( i s ⋅ L )
A detailed description of the rotor position estimator can be found in Section 3.2.5.
2.3.3
Rotational Speed Calculation
The angular speed is calculated by the derivative of the angle with respect to time. The
deviation by a difference quotient causes an amplification of high frequency signals.
These high frequency signals are noise and other disturbances in the current
measurement. As a result, the derivative needs to be lowpass filtered.
dϕ
ω = -----dt
Application Note
8
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
Sensorless Field Oriented Control (FOC)
2.4
•
•
•
Key Features of XC886/888 which enable Field Oriented Control
High performance 16-bit vector computer (CORDIC + MDU)
– Vector rotation and transformations like Park transform
– Normalizing and scaling
– Interrupt based operation with minimum CPU load
PWM unit for advanced motor control (CapCom6E)
– 16-bit resolution for high precision space vector PWM generation
– Dead time control for minimum hardware effort (direct control of MOSFET/IGBT)
– CTRAP provides hardware overload protection
A fast 10-bit A/D Converter (sample time of 0.200 µs)
– Hardware synchronization to PWM unit reduce CPU load
– Two result registers to maximize sampling performance
– Enables single shunt current measurement
– Fast ADC reduces torque ripple due to minimized blind angle in sensorless FOC
Figure 8
Block Diagram of XC886 / XC888
Application Note
9
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
3
FOC Implementation
In this chapter, the field oriented control for PMSM motors is discussed in detail. The
implementation of the FOC diagram can be seen in Figure 9. The yellow blocks
implemented in hardware, the blue blocks are calculated by CORDIC, MDU and CPU.
Space Vector Pulse Width Modulation
Reference
Speed
+
ω
0
Speed
Controller
+
+
-
Id
Controller
Iq
Controller
Vd
Vq
ϕ
Speed
calculation
Vα
CAPCOM 6E
|V|
timer12
jϕ
Id
Iq
e
vector
rotation
Vβ
KP
-j
Iβ
Current
Calculation
&
3Φ to 2Φ
W
Events:
T13CM
T13PM
ISR:
CC6_ivNode3
Iα
V
output
control
timer13
ISR :
CC6_ivNode2
Flux
Estimation
e ϕ
vector
rotation
ϕ
U
compare
register
dead- time insertion
ADC
IDClink
ADC
Result0
Result0
Result
0
result0
control
FOC_Implementation.emf
Figure 9
Implementation of FOC in XC886/888 CM/CLM
Figure 10 shows the timing diagram of timer12 and timer13 as well as the interaction of
timer interrupts and the event trigger for start of ADC measurement.
TPWM
T12
T12PR
CC60SR
TPWM
period match
period match
CC61SR
CC62SR
t
T13
T13PR
compare match
period match
CC63SR
t
IDClink
ISR:
CCU6_viNode2
Event (ETR01):
T13CM
start ADch 3
store in RESR0
Event (ETR10): t
T13PM
start ADch 4
store in RESR1
Timers.emf
Figure 10
Timing Diagram: Timer12 and Timer13
Application Note
10
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
Timer 12 is utilized to generate the control signals for the inverter. The compare registers
CC60SR, CC61SR and CC62SR are responsible for the behavior of the output signals
CC60, COUT60, CC61, COUT61, CC62 and COUT62.
The timer13 is configured in single shot mode. It starts synchronous with timer12 zero
match. The period register of timer13 (CCU6_T13PR) is updated every second PWM
period (TPWM). The update value depends on the modulation, but is always greater than
1.5 * TPWM.
The interrupt channel Node3 (timer12 period match interrupt) is locked in timer12 ISR
and released in timer13 ISR. As a result of this setup, the timer 12 ISR is triggered every
second PWM period.
The 10 bit ADC is configured in that way that the measurement result of channel 3 and
4 is stored in result register 2 and 3, respectively. This requires the DC-link current
(IDClink) to be available at both channels. As a result, the ADC conversion result is stored
in separate result registers and can be used for calculations at any time independent of
the modulation angle.
3.1
Timer2 Interrupt
The timer2 interrupt triggers every 1.6 ms. The interrupt service routine (ISR) handles
the startup and the speed reference value for the speed control.
At startup of the motor, the space vector PWM angle is set to 0°. 100 interrupts after start,
the voltage angle is changed stepwise with +/-90° and the control is enabled
immediately.
After startup, any change in the user speed reference causes a linear ramp with +/1430 rpm per second at the internal speed reference.
3.2
CCU6 Timer12 Period Match Interrupt (CCU6_viNode2)
This interrupt contains all calculations necessary for the field oriented control. It starts
with the current calculation and transformation in the orthogonal system (Va, Ia, Vb and
Ib). After that all calculations are executed necessary for the motor control. In the end,
the update for the modulation is prepared in the shadow registers.
Application Note
11
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
CC6_viNode2
Node2 interrupt disabled
speed control
Current calculation
current control
phase current assignment
vector rotation
clark transform
cartesian to polar transform
flux estimation
sv modulation
inverse vector rotation
update CC6 & ADC
speed calculation
release shadow transfer T13
return
CCU6_viNode2.emf
Figure 11
Flow Chart T12 Period Match Interrupt
In the following subsections all steps are discussed in detail.
3.2.1
Node2 Interrupt Disabled
The execution of all FOC calculations takes longer than one PWM period. As a result,
the PWM period interrupt (T12 period match) has to be disabled during calculation. It is
enabled after measuring the DC-link currents by node3 interrupt (T13 period match). As
the interrupt priority of node2 is the highest possible, the enabling of the interrupt in node
3 is always after all steps of node2.
3.2.2
Current Measurement and Calculation
According to Section 2.3.1, there are four time slots where the DC-link current IDClink is
not zero and two different phase currents can be measured. In order to trigger the current
measurement very accurately, two ADC channels are connected to the amplified voltage
of the shunt.
Application Note
12
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
The ADC conversions are consecutively started every second period of the modulation.
The first measurement is triggered by the compare match of CC63 and sampled by ACD
channel 3. The second measurement by ADC channel 4 is triggered by the period match
of T13. ADC channel 3 is used to measure the positive currents (segment b of
Section 2.3.1), channel 4 measures the negative ones (segment e). Sampling is
triggered in the center of each segment. Please refer to Figure 10 for detailed timing of
the current measurement.
This method requires very fast switching and sampling times in order to ensure a proper
current measurement. The time slot for the phase current measurement is limited by the
sum of sampling time Tsample and deadtime Tdeadtime.
Due to this restriction, the current can not be measured at the crossing of two sectors of
the space vector modulation. Therefore the minimum time for the voltage space vector
is limited to the minimum time for current measurement.
Here, the measurements of ADC channel 3 and 4 are evaluated by reading the result
register 0 and 1. The values are right-shifted three bits by the MDU in order to remove
the channel information and to multiply the 10-bit ADC value by 8.
Current Range and Scaling
The maximum current is defined as follows:
V aref
I max = ------------------------------R shunt ⋅ G OP
Rshunt = Shunt Resistor, GOP = Amplification in opamp, Imax = maximum current,
Varef = reference voltage for ADC
The scaling is the equivalent to the maximum physical value represented in a signed
integer value.
15
NI
( U, V , W )
I max ⋅ 2
= ---------------------10
8⋅2
Imax = maximum measurable current
Application Note
13
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
3.2.3
Phase Current Assignment
The phase currents are assigned according to the sectors of the space vector.
Sector
A 0° - 60°
B 60° - 120°
C 120° - 180°
D 180° - 240°
E 240° - 300°
F 300° - 360°
3.2.4
IDClink(a) IDClink(b)
0
IU
0
IV
0
IV
0
IW
0
IW
0
IU
IDClink(c)
-IW
-IW
-IU
-IU
-IV
-IV
IDClink(d) IDClink(e) IDClink(f)
-IW
-IW
-IU
-IU
-IV
-IV
0
0
0
0
0
0
IU
IV
IV
IW
IW
IU
IDClink(g)
0
0
0
0
0
0
Clark Transform
The transformation from three stator phase currents (IU, IV, IW) into two orthogonal rotor
phase currents (Id, Iq) is realized in two steps. In the first step, the transformation into a
two phase stator system (Iα, Iβ) is calculated. The second step rotates the coordinates
into the rotor system.
The two measured motor phase currents (Ia, Ib) are represented as vector in an
orthogonal stator α/β-coordinate system. The vector is built by the currents (Iα, Iβ). After
startup, the α/β-coordinate system rotates synchronously with the rotor.
Following transformation, also known as Clarke Transform, is used to represent a three
phase system by an orthogonal two phase system:
Iα = Ia
1
I β = ------- ⋅ ( I a + 2I b )
3
Both components are calculated by the MDU. A factor of 0.5 simplifies both equations.
Because of this, the scaling in the α/β-system is twice the scaling of the u/v/w-system.
NI
3.2.5
( α, β )
= 2 ⋅ NI
( U, V , W )
Flux Estimation
The vector in the α/β-system is rotated by an angular transformation into d/q-system of
the rotor. Here, the angle ϕ must be available, which is calculated from the rotor flux Ψ
by following equations. During startup, the angle is not taken from the flux estimation.
Application Note
14
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
Ψα =
∫ ( Vα – Iα ⋅ R ) dt – Iα ⋅ L
Ψβ =
∫ ( Vβ – Iβ ⋅ R ) dt
– Iβ ⋅ L
 Ψβ 
ϕ = atan  ------- 
 Ψα 
R = stator resistance, L = stator inductance, Vα,β = stator voltage, Iα,β = stator current
The calculation of the induced voltage is realized with the CORDIC module.
CORDIC configuration
Linear rotation mode
X X final = -----------MPS
2
Y + X ⋅ Z ⋅ 16Y final = -----------------------------MPS
2
Z final = 0
X = R'
Y = V' α, β
Z = I' α, β
MPS = 0
keep bit = 0
Interrupt disabled
The physical values Vα,β and Iα,β are represented in internal microcontroller values V’α,β
and I’α,β as follows:
15
V α, β ⋅ 2
V' α, β = -----------------------NV
15
,
( α, β )
I α, β ⋅ 2
I' α, β = ---------------------NI
( α, β )
NV and NI are the scale factors for voltage and current. The resistance R is scaled by NV
and NI as well.
V
R = --I
15
,
NI
⋅2
V' 15
( α, β )
R' = – ---- ⋅ 2 = R ⋅ ------------------------I'
⋅ 16
NV
( α, β )
Finally, the two’s complement of the value R’ must be taken to get the correct calculation
of the induced voltage.
Note: In the code, the resistance R’ is defined by STATOR_R
The integration of the induced voltage during the calculation of the flux Ψ is calculated
by a low pass filter of first order which is realized by a PT1 controller. See following figure
for details:
Application Note
15
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
1
G ( p ) = ---------------1 + pT
Figure 12
Transfer Function of a PT1 Controller
It is important for the accuracy at low speed that the cut-off frequency is low. It comes
clear in Figure 12 that the output value of a PT1 controller decreases at high
frequencies. As a result, an additional gain is inserted in order to increase the resolution.
function call: void PT1_MDU( void )
Following equation is used for the PT1 algorithm:
Y( k ) = Y( k – 1 ) + Z( k ) ( X( k ) – Y( k – 1 ) )
Y ( k – 1 ) : stored
X ( k ) : Input Value
∆t 16
Z = ----- ⋅ 2 ⋅ G Z
T
value of Y ( k )
The sampling time is ∆t. The time constant for the filter is T.
The PT1 controller is calculated by the MDU. The implementation provides two gain
factors GZ selected by global flag F0.
•
•
F0 = 0: Z(k) = Z(k) / 256 , GZ = 256
F0 = 1: Z(k) = Z(k) , GZ = 1
The interface to the PT1 algorithm is defined as follows:
Parameter
Format
Code
global flag F0
1 bit
F0
Input X
16 bit
R7 = H, R6 = L
time constant Zk
16 bit
MDU_MD5 = H,
MDU_MD4 = L
Application Note
16
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
Parameter
Format
Code
storage for Y(k)
32 bit
@r0 = L
Output Y
16 bit
@r0 = H, @r1 = L
In the calculation of the rotor flux estimation, the PT1 algorithm is used with following
parameters: T = 1 s, F0 = 0 (GZ = 256) , ∆t = 2*TPWM = 133.33 µs.
Note: In the code, the time constant Zk is defined by FLUX_PT1_TIME
Stator Flux Calculation (Iα,β * L)
A signed multiplication is performed by the MDU in order to calculate the stator flux.
The inductance L has to be scaled similar to the resistance R.
Ψ
L = ---I
15
,
⋅ 2 ⋅ 2 ⋅ GZ
NI
Ψ' 15
( α, β )
L' = – ----- ⋅ 2 ⋅ 2 ⋅ G Z = – L ⋅ --------------------------------------------NΨ
I'
,
NΨ
( α, β )
= NV
( α, β )
( α, β )
The factor “2” in the calculation is added, because the result of the MDU is half of the
expected value. The inductance L’ is negative, because all flux components are added
afterwards. The calculation of the rotor flux was performed with a gain GZ = 256. That’s
why the stator flux must be scaled by 256 as well. This is done by scaling the inductance.
The inductance value L’ has to be provided as two’s-complement
Note: In the code, the resistance L’ is defined by STATOR_L
Rotor Angle Calculation
The rotor angle is calculated from the flux-components Ψα and Ψβ. The calculation is
performed by the CORDIC.
CORDIC configuration
2
2
Circular vectoring mode
K ≈ 1,64676
K ⋅ X + YX final = -----------------------------MPS
2
Y final = 0
Y
Z final = Z + atan  ---
 X
X = Ψα
Y = Ψβ
Z = 0
MPS = 0
keep bit = 0
Interrupt disabled
For speed calculation, the angle is stored in the variable Winkel_mem.
Application Note
17
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
3.2.6
Vector Rotation e-jϕ
The space vector is rotated by the angle ϕ from the stator-fix α/β coordinates into the
rotor-fix d/q coordinates by an angular transformation, also known as Park Transform. In
the rotor-fix system, the current vector Id represents the flux inducing component of the
motor current. The current vector Iq represents the torque component.
The angular transformation is calculated in the CORDIC:
CORDIC configuration
Circular rotation mode
– I α sin ϕ + I β cos ϕ
X final = K ⋅ ------------------------------------------MPS
2
I α cos ϕ + I β sin ϕ
Y final = K ⋅ ---------------------------------------MPS
2
I q = X final
I d = Y final
X = Iβ
Y = Iα
MPS = 0
keep bit = 0
K ≈ 1,64676
Z final = 0
Z = ϕ
Interrupt disabled
The scaling in the stator and rotor systems differs as follows.
NI
3.2.7
( d, q )
= NI
( α, β )
2
⋅ ---K
,
K = 1,64676
Speed Calculation
The speed is calculated every third call of timer12 interrupt. At a PWM frequency of
15 kHz, the speed calculation and control is performed every 400 µs. The speed control
can be adjusted ti the application’s needs by changing the parameter
SPEED_CONTROL_RATE.
This function calculates the speed from the derivative of the angle. The calculation is
performed by using the difference quotient and smoothing of the result by a PT1 filter.
∆ϕ
ω = ------∆t
In the algorithm, just the difference between the current angle and the stored angle is
calculated. The division by the time is not performed. The result is filtered by the PT1
algorithm without additional gain (F0 = 1) with a time constant of 25.6 ms.
Application Note
18
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
The scaling for the mechanical rotational speed is calculated as follows:
15
2 ⋅ 60
N ω = ---------------------------[ rpm ]
16
∆t ⋅ 2 ⋅ P p
Pp is the number of pole pairs.
3.2.8
Speed Control
The PI controller for speed control is called in the same timing with the speed calculation.
The output of the speed controller provides the torque building current component Iq.
1
y ( t ) = K P  x ( t ) + ------ ⋅ ∫ x ( t ) dt
TN
or
y ( t ) = [ K P ⋅ x ( t ) ] + [ K I ⋅ ∫ x ( t ) dt ]
function call: void PI_controller( void )
The implemented PI controller represents following transfer function.
KI
1
G R = K P ⋅  1 + --------  = K P + ----

pT I
p
,
KP
K I = ------TI
KP and KI are the control parameters. KP corresponds to the proportional gain of the
controller and KI influences the reset time TI together with the gain KP.
The implementation for the microcontroller is as follows:
∆t
Y ( k ) = [ K' P ⋅ X ( k ) ] + Y ( k – 1 ) + K' P ⋅ ----- ⋅ X ( k ) = [ K' P ⋅ X ( k ) ] + [ Y( k – 1 ) + K' I ⋅ X ( k ) ]
TI
X(k):
Y(k-1):
∆t:
TI:
control deviation (reference value - actual value)
stored value of Y(k)
sample time
Time constant for integral component
∆t
K' I = ----- ⋅ K' P
T
Application Note
19
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
The PI algorithm is calculated by the CORDIC and MDU. The function provides following
interface:
Parameter
Format
Code
reference value
16 bit
R7 = H, R6 = L
actual value
16 bit
R5 = H, R4 = L
struct {
stored value Y(k)
24 bit
KP (scale: NKp = 16)
KI (scale: NKI = 128)
16 bit
16 bit
@R0 = L
16 bit
R7 = L, R6 = H
}
outputY
In this algorithm following calculations are executed:
1. The control deviation e (reference value - actual value) is calculated and limited to
16 bit
2. The control deviation is multiplied by the MDU with the KI value and integrated. After
calculation, the result is limited to 16 bit
3. The control deviation is multiplied by the CORDIC with the KI value
4. The sum of proportional and integral component is taken and limited to 16 bit
CORDIC configuration
X X final = -----------MPS
2
Y + X ⋅ Z ⋅ 16Y final = -----------------------------MPS
2
Z final = 0
X = KP
Y = 0
Z = e
MPS = 0
3.2.9
Linear rotation mode
keep bit = 0
Interrupt disabled
Current Control
Both current components Id and Iq are controlled independently by PI controller. For
PMSM motors, the reference value for the field building component Id is zero, because
the field is available due to the permanent magnets. However, a variation of Id can be
used for field weakening techniques. The reference value for the torque building
component is given by the output of the speed controller.
Application Note
20
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
function call: void PI_controller( void )
The same function is used as for the speed controller. The outputs of the controller are
the set values Vd and Vq in rotor-fix coordinates. This voltage space vector is used by the
space vector modulator.
Vector Rotation e+jϕ
3.2.10
This angular transformation is performed with the CORDIC.
CORDIC configuration
Circular rotation mode
V q cos ϕ + V d sin ϕ
– V q sin ϕ + V d cos ϕ
Y final = K ⋅ -----------------------------------------X final = K ⋅ ---------------------------------------------MPS
MPS
2
2
V α = X final
V β = Y final
X = Vd
Y = Vq
MPS = 2
3.2.11
keep bit = 0
K ≈ 1,64676
Z final = 0
Z = ϕ
Interrupt disabled
Transformation Carthesian to Polar Coordinates
Now, the voltage space vector (Vα, Vβ) is transformed into a polar representation (ϕ,|V|).
The transformation is calculated in the CORDIC:
CORDIC configuration
2
2
K ⋅ X + YX final = -----------------------------MPS
2
Circular vectoring mode
Y final = 0
MPS = 2
Application Note
Y
Z final = Z + atan  ---
 X
ϕ = Z final
V = X final
X = Vα
K ≈ 1,64676
Y = Vβ
keep bit = 0
Z = 0
Interrupt disabled
21
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
The scaling is determined by the dead time of the driver and the sample time of the ADC:
16
NV
( d, q )
V z, max ⋅ 2
= -------------------------------------------------------------------------T sample + T deadtime
15
2 ⋅  1 – -----------------------------------------------


T PWM
Due to use of CORDIC and MDU for the transformations, the scaling for the stator-fix
coordinates is as follows:
NV
( α, β )
NV
⋅2
( d, q )
= --------------------K
,
K = 1.64676
This voltage scale factor is used in the flux estimation module.
3.2.12
Space Vector Modulator
The inverter is driven by pulse with modulated signals. By this method, at frequencies
higher than the electrical time constant of the motor, a smooth and sinusoidal current can
be generated that features very little harmonic content. As a result, the motor is driven
by constant rotating fields.
Calculation of the PWM Duty Cycles from the Space Vector
In the subroutine for the calculation of the PWM duty cycle, first the sector is acquired.
Afterwards, the angle within in the sector (ϕrel) is calculated. By using the angle ϕrel and
the norm | V |, the components VT1 and VT2 are calculated.
2
V T1 = ------- ( V ⋅ sin ϕ rel )
3
Application Note
,
2
V T2 = ------- ( V ⋅ sin ( 60° – ϕ rel ) )
3
22
0° < ϕ rel < 60°
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
[1 1
0]
FOC Implementation
V
VT2
C
D
B
E
A
γrel
F
VT1
[100]
PWM _DC.emf
Figure 13
Space Vector V in Sector A
Now, the duty cycle for the inverter have to be calculated. This is done by calculating the
corresponding compare values within a PWM-period (see Figure 10).
Following intermediate calculation is performed:
T T12 + V T1 + V T2
T T12 V T1 + V T2
V TA = ----------- + ------------------------- = ------------------------------------------2
2
2
T T12 – V T1 – V T2
T T12 V T1 + V T2
V TB = ----------- – ------------------------- = -----------------------------------------2
2
2
T T12 + V T1 – V T2
V TC = V TB + V T1 = -----------------------------------------2
The calculation VT2 / 2 and (VT1 + VT2) /2 is performed by the CORDIC.
CORDIC configuration
Linear rotation mode
X X final = -----------MPS
2
Y + X ⋅ Z ⋅ 16Y final = -----------------------------MPS
2
Z final = 0
X = V T2
Y = V T1
1
Z = -----16
MPS = 1
Application Note
keep bit = 0
Interrupt disabled
23
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
The norm of vector V is scaled according to the maximum duty cycle of the pulse width
modulation which is defined by the time TPWM in timer12 representation and a
combination of ADC sample time and driver delay time.
Note: In the code, the time TT12 is defined by T12PERIODE
T sample + T driverdelay
V ( T1,T2 )max = T T12 ⋅  1 – --------------------------------------------------- = K S ⋅ V max
T T12
In consideration of the previous calculations with the CORDIC and MDU, following
scaling is used:
2 ⋅ V ( T1,T2 )max
K S = -----------------------------------V max
,
V max = 2
11
2
⋅K = 2
11
2
⋅ ( 1.64676 ) = 5553.8
( T T12 – ( T sample + T driverdelay ) )
K S = -----------------------------------------------------------------------------2776.9
The scale factor 1/KS is used for the calculation of the sin(ϕ) table:
1 15
sin ( 30° ) = --- ⋅ 2 ⋅ K
2
S
Note: In the code, the sin(ϕ) table is stored in file “modultab.h”
Additionally to the scaling of V(T1,T2) under consideration of the maximum duty cycle, it is
necessary to limit V(T1,T2) to the minimum time required for current measurement Tsample.
Note: In the code, the time Tdriverdelay is defined as DRIVER_DELAY and
(Tsample + Tdriverdelay) by T_MIN.
3.2.13
Update of CapCom6 and ADC Configuration
Depending on the direction of the space vector, different combinations of the
intermediate values VTA to VTD have to be moved to the shadow registers of CapCom6Unit. See following table for details.
The time D corresponds to the delay of the ADC trigger in order to take care about the
delay time and switching time of the driver.
Note: In the code, the delay D is defined by DRIVER_DELAY.
Application Note
24
V1.0, 2007-05
AP08059
Sensorless Field Oriented Control for PMSM Motors
FOC Implementation
Sector
A
B
C
D
E
F
PWM Generation
ADC Trigger
CC60SR CC61SR CC62SR CC63SR
T13PR
VTB
VTC
VTA
VTA
VTC
VTB
D + (3TT12+ VT1) / 2
D + (5TT12 + VT2) / 2
D + (3TT12 + VT2) / 2
D + (5TT12 + VT1) / 2
D + (3TT12 + VT1) / 2
D + (5TT12 + VT2) / 2
D + (3TT12 + VT2) / 2
D + (5TT12 + VT1) / 2
D + (3TT12 + VT1) / 2
D + (5TT12 + VT2) / 2
D + (3TT12 + VT2) / 2
D + (5TT12 + VT1) / 2
3.2.14
VTC
VTB
VTB
VTC
VTA
VTA
VTA
VTA
VTC
VTB
VTB
VTC
Release Shadow Transfer T13
For a glitch free current measurement the update of the PWM registers must be set at a
given time. That’s why in the next step the shadow registers for the current measurement
triggers (timer13) are released. The new PWM values are transferred after current
measurement.
3.3
CCU6 Timer13 Period Match Interrupt (CCU6_viNode3)
Although the timer13 is used to trigger the ADC, the timer13 ISR contains the sequence
to enable the interrupt of Node2 (see Figure 14) and to release the shadow transfer for
timer T12.
CC6_viNode3
release shadow transfer T12
Node2 interrupt enabled
return
CCU6_viNode3.emf
Figure 14
Flow Chart T13 Period Match Interrupt
The timer13 is configured to trigger the ADC measurement by compare match (T13CM)
and period match (T13PM) hardware events.
Application Note
25
V1.0, 2007-05
w w w . i n f i n e o n . c o m
Published by Infineon Technologies AG