Sensorless FOC on XC878

XC 8 0 0 Fa m i l y
AP 0 8 0 9 0
S e ns or l es s F i el d O ri en t ed C on t ro l ( F O C ) on X C 87 8
Ap p l i c a ti o n No te
V 1 . 0, 2 00 9- 04
M i c ro c o n t ro l l e rs
Edition 2009-04
Published by
Infineon Technologies AG
81726 Munich, Germany
© 2009 Infineon Technologies AG
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 the 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 the nearest Infineon Technologies Office.
Infineon Technologies components may be used in life-support devices or systems only 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.
AP08090
Sensorless Field Oriented Control (FOC) on XC878
XC878
Revision History: V 1.0 2009-04
Previous Version(s):
Page
Subjects (major changes since last revision)
–
This is the first release
Trademarks
TriCore® is a trademark of Infineon Technologies AG.
We Listen to Your Comments
Is there any information in this document that you feel is wrong, unclear or missing? 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
3
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Table of Contents
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1
Target Market and Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2
2.1
2.1.1
2.1.2
2.1.3
2.1.4
2.2
2.2.1
2.3
2.3.1
2.4
2.4.1
2.4.2
Theory of Sensorless Field Oriented Control (FOC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
DC Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Open Loop Voltage Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Closed Loop Torque Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Closed Loop Speed and Torque Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
List of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Space Vector Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Reference Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Phase Current Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Limitations of Phase Current Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
FOC Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Stationary and Rotating Reference Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Sensorless FOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.3
3.3.1
3.3.2
3.3.3
3.3.4
3.3.5
3.3.6
3.3.7
3.4
3.5
3.5.1
3.5.2
3.5.3
3.5.4
3.5.5
FOC Implementation on XC878 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Initialization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CC6 Timer Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
T21 Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scheduler State Machine - T21 Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State IDLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State BOOTST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State STARTUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State FOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State RAMPDWN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State STOP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
State EMERGENCY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CAN Communication - CAN Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOC Control Loop - T13 Interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Shadow Transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
FOC Calculation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flux Estimator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
PI-Controller with Anti Wind-Up Limitation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Speed Ramp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
20
21
21
21
22
22
22
23
23
23
24
25
25
26
26
26
27
27
27
29
30
31
4
4.1
4.2
4.3
4.4
4.4.1
4.4.2
4.4.3
4.4.4
How to Use the Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Excel Sheet and FOC_Defines.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Project Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DriveMonitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Monitoring the Startup Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Monitoring the Runtime Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Special Tricks - Field Weakening . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
32
32
33
34
35
35
35
37
38
Application Note
4
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
5
FOC Building Blocks Overview Drawing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Application Note
5
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Target Market and Motivation
1
Target Market and Motivation
The Field Oriented Control (FOC) method is focussed on cost sensitive consumer drives, such as fans, pumps,
compressors or geared motors.
One driving factor for a sensorless FOC on BLDC (Brush Less DC motor) or PMSM (Permanent Magnet
Synchronous Motors) is decreasing the system cost: sensors can generate problems in manufacturing and
reliability, and they require special wiring harnesses and connectors which increase the overall system cost.
The other driving factor is the significant improvement of energy efficiency of a motor. With FOC, efficiency can
be raised up to 95%. This has a big impact on power consumption, motor dynamics, heat dissipation and noise.
Fans and pumps in many applications must operate very silently, otherwise any sound produced distributes in
water or air pipes within the whole building. Usually this leads to concepts with sinusoidal currents in the motor
coils. The zero-crossing technique for position detection of BLDC motors does not work, because block-type
currents generate audible noise.
The FOC method described here solves the two obstacles at once:
- no need for a hall sensor or any other sensor type
- sinusoidal current shape for very efficient and quiet operation
Figure 1
Target Applications for Sensorless Field Oriented Control (FOC)
The limitation of the methods described in this application note is the single shunt current measurement which
cannot guarantee a steady control under all circumstances. This method is therefore not suitable for high dynamic
loads and positioning systems. However the algorithm can be adapted to 3-phase-shunt measurement which does
not have this limitation.
Application Note
6
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
2
Theory of Sensorless Field Oriented Control (FOC)
This chapter is intended to give an overview about the theory of sensorless Field Oriented Control (FOC) of
Permanent Magnet Synchronous Motors (PMSM). The control scheme which has been implemented for the
XC878 and XE164 is based on this theory. The implementation details are described in Chapter 3.
Before the FOC theory is described in detail, this chapter starts with some background motor control description.
2.1
DC Motor Control
The DC motor consists of a permanent magnet which builds the stator and a coil mounted at the rotor. A
mechanical commutator is needed in order to feed the current to the coils. This commutator will cause the current
to be oriented according to the field of the permanent magnets at the stator.
Figure 2
DC Motor
The DC Motor is controlled by the voltage at the rotor coils and the current is proportional to the torque of the motor.
The speed of the motor depends on the voltage and the torque.
The nominal speed (ωnom) and torque (mnom) are defined in the following equations:
– i ⋅ Rω nom = v-----------------Kc
(1)
m nom = K c ⋅ i
(2)
The time constants of speed and current control are very different, but a control cascade structure for speed and
current control can be utilized.
Application Note
7
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
2.1.1
Open Loop Voltage Control
In an open loop voltage control there is simply a reference voltage which will cause the power inverter to generate
a given voltage at the motor. The mechanical load influences the speed and the current of the DC motor.
DC Motor
Vref
Figure 3
V
Power
Stage
Open Loop Voltage Control
In steady state, the torque can be described as follows:
v – K c ω stat
m stat = K c ⋅ -------------------------R
2.1.2
(3)
Closed Loop Torque Control
The torque control loop requires the measurement of the motor current with a current sensor; e.g. a shunt resistor.
In general, the torque is proportional to the current:
mm = Kc ⋅ i
(4)
As a result, a PI controller can be used for current control. The actual current measured by the current sensor, will
be controlled to converge to the reference current. This can only be done by changing the reference Voltage (Vref)
of the power stage. See the following figure:
DC Motor
Iref
+
-
eI
Current
Control
Vref
Power
Stage
V
I
mload
Iact
Figure 4
Current
Sensor
Closed Loop Torque Control
Application Note
8
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
2.1.3
Closed Loop Speed and Torque Control
For a speed controlled DC motor, a cascaded control structure can be used. A cascade control structure is used
because the speed change requirement is much slower than the the current requirement.
The speed control requires a speed sensor, such as a tachometer, and the current control requires a current
sensor. The output of the speed control is the reference current for the current control. Usually a PI controller is
used for speed and current control.
DC Motor
ωref
+
-
eω
Speed
Control
Iref
+
-
eI
Current
Vref
Control
Power
Stage
V
ω
I
mload
Iact
ω act
Current
Sensor
Speed
Sensor
Figure 5
Cascaded Speed and Current Control
2.1.4
List of Equations
The mechanical and electrical equations of the DC motor are also valid for the PMSM.
Note: These equations are referred to again later in this application note.
Voltage Equation:
L ⋅ di + R ⋅ i = v – v bemf
dt
(5)
v bemf = K c ⋅ Ψ ⋅ ω
(6)
m Friction = r Friction ⋅ ω
(7)
Induced Voltage:
Mechanical Friction:
Mechanical Equation:
J⋅
Application Note
dω
= m m – m Load – m Friction
dt
9
(8)
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
Angle:
∫ ω dt
(9)
ω
n = 60 ⋅ -----2π
(10)
ϕ =
Speed in revolutions per minute (rpm):
2.2
Space Vector Modulation
In this section, the modulation of a three leg voltage source inverter is described.
A three leg voltage source inverter contains six MOSFETs or IGBTs which act as switches. The switches
connected to the positive supply rail are called high side switches (hs) and the switches connected to the negative
rail of the power supply are called low side switches (ls).
In the following figure, a block diagram of a three leg voltage source inverter is shown:
U
+
V
W
V
hs
VDC
U
ls
N -
Figure 6
W
Three Leg Voltage Source Inverter
By switching the high side and low side switches on and off, there are eight possible states. These states do not
cause cross currents inside the leg itself, but allow a current flowing to and from the motor.
State
Uhs
Uls
Vhs
Vls
Whs
Wls
000 (passive)
OFF
ON
OFF
ON
OFF
ON
100 (active)
ON
OFF
OFF
ON
OFF
ON
110 (active)
ON
OFF
ON
OFF
OFF
ON
010 (active)
OFF
ON
ON
OFF
OFF
ON
011 (active)
OFF
ON
ON
OFF
ON
OFF
001 (active)
OFF
ON
OFF
ON
ON
OFF
101 (active)
ON
OFF
OFF
ON
ON
OFF
111 (passive)
ON
OFF
ON
OFF
ON
OFF
The states can be seen as vectors in the space vector diagram of the coordinates U, V and W. There are six active
and two passive vectors.
Application Note
10
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
The space vector diagram of a U-V-W system contains six sectors (A, B, C, D, E, F) (see Figure 7).
N
S
S
N
0]
[11
0]
[01
N
C
[011]
D
B
S
A
[100]
F
E
N
S
S
N
1]
[0 0
[10
1]
N
S
Figure 7
Space Vector Diagram of a U-V-W System
The magnetic field (flux) of a three phase PMSM can be represented in a U-V-W space vector diagram.
In Figure 7, the flux is simplified by a magnetic dipole. Whereas the stator coils are fixed in their position, the flux
rotates dependent on the sector of the hexagon.
The voltages at the three coils correspond to the values of U, V and W. The resulting vector corresponds to the
flux of the stator coils.
V
Scaling:
V = VU + VV + VW
VU = vU ⋅ e
VV = vV ⋅ e
U
j 2π
3
VW = vW ⋅ e
V = vU ⋅ e
W
j0
+ vV ⋅ e
vU = 2/3 VU
vV = 2/3 VV
vW = 2/3 VW
j0
j 4π
3
j 2π
3
The maximum length of the space vector is:
+ vW ⋅ e
j 4π
3
Figure 8
Space Vectors in Complex Numbers
2.2.1
Reference Vector
|V|max = VDC
The reference vector Vref represents the resulting magnetic stator field (flux).
It is defined by the equation:
V ref = V ref ⋅ e
jϕ
(11)
It is rotating in space with the speed ω :
ω = 2π ⋅ f
Application Note
11
(12)
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
The reference vector can be approximated by two active vectors (for example V1 and V2) and one zero vector
(V0). The plane is dissected into six sectors and the angle ϕ is transformed into the relative angle γrel.
[1 1
0]
Sampling Period Ts:
Ts = T1 + T2 + T0
V2
(13)
Volt-Second Balancing:
T2
⋅ V2
Ts
C
D
B
E
Figure 9
Vref
A
V ref ⋅ Ts = V 1 ⋅ T 1 + V 2 ⋅ T 2 + V 0 ⋅ T 0
γrel
[100]
T1
⋅ V1
Ts
F
(14)
V1
Reference Vector Approximation
Taking into account the scaling of the reference vector and expressing the complex numbers in polar coordinates,
the following equations are valid for the PWM on-time of a space vector modulation:
3 ⋅ T s ⋅ V ref
T1 = ------------------------------- sin  π
--- – γ rel


V DC
3
(15)
3 ⋅ T s ⋅ V ref
T2 = ------------------------------- sin ( γ rel )
V DC
(16)
T0 = T s – T 1 – T 2
(17)
The design of the switching sequence depends on the application requirements, but in order to reduce switching
losses to a minimum the total number of a switching sequence is also usually minimized.
Figure 10 shows a seven segment switching sequence:
TPWM
VU
t
VV
t
VW
Figure 10
[000]
[100]
[110]
[111]
[110]
[100]
[000]
T0 /4
T1/ 2
T 2/2
T 0/2
T2 /2
T 1/2
T 0 /4
PWM Pattern of a Seven Segment Switching Sequence
The pattern is symmetric at TPWM and TPWM/2. As a result, the PWM generation should be based on an up/down
counter providing a center aligned pattern.
The CAPCOM6 unit provides a center aligned mode for timer T12 and the period value is adjusted with the special
function register T12PR.
Application Note
12
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
For the calculation of the compare values for the three phase signals, the following scaling is used:
ˆ
T s,1,2 = T s,1,2 ⋅ 2 ⋅ T12 clock = T12PR ⋅ 2 ⋅ T12 clock
(18)
The compare values are calculated as follows:
ˆ
ˆ
Tˆ
Tˆ Tˆ Tˆ
T12PR T 1 + T 2
CMP 0 = -----0- = -----s – -----1- – -----2- = ------------------ – ----------------2
2
2
2
2
2
(19)
CMP 1 ( A,C,E )
ˆ
T0 ˆ
ˆ
= ------ + T1 = CMP 0 + T 1
2
(20)
CMP 1 ( B,D,F )
Tˆ0 ˆ
= ------ + T 2 = CMP 0 + Tˆ2
2
(21)
Tˆs Tˆ1 Tˆ2 ˆ
Tˆ1 + Tˆ2
Tˆ0 ˆ
ˆ
ˆ
T12PR
CMP 2 = ------ + T 1 + T 2 = ----- – ------ – ------ + T 1 + T 2 = ------------------ + -----------------2
2
2
2
2
2
(22)
The sector of the hexagon defines which compare value CMP0, CMP1 and CMP2 is used for phase U, V and W.
This is detailed in the following table:
Sector
A
B
C
phase U
CMP0
CMP1(B,D,F) CMP2
phase V
CMP1(A,C,E) CMP0
CMP0
phase W
CMP2
CMP1(A,C,E) CMP0
CMP2
D
E
CMP2
CMP1(A,C,E) CMP0
CMP1(B,D,F) CMP2
CMP0
F
CMP2
CMP1(B,D,F)
The output voltage of each leg to neutral is shown in Figure 11:
A
B
VU
[100]
Figure 11
C
D
VV
[110]
E
F
VW
[010]
[011]
[001]
[101]
[100]
Output Voltage of Space Vector Modulation
The voltages VUV, VUW and VVW at the motor are sinusoidal.
Application Note
13
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
2.3
Phase Current Measurement
For many motor control schemes, the phase currents are required as input values. A cost efficient method requires
only one shunt in the DClink.
Two phase currents can be reconstructed from the DClink current (IDClink) during one PWM period (TPWM).
The third phase current can be calculated by IU + IV + IW = 0, but is redundant for the control.
T PWM
VU
VV
t
VW
t
IDClin
a
k
T 0/4
Figure 12
b
c
IU
I-W
T1/2
T 2/2
d
T0/2
e
f
I-W
IU
T 2/2
T 1/2
g
t
T 0/4
t
Phase Current Measurement within the PWM Pattern
In order to realize this method, the ADC trigger points must be adjusted according to the PWM pattern.
Two different currents can be measured at PWM time, T1 and T2. Depending on the actual sector, the measured
currents have a different meaning.
The following table shows these combinations and the calculation for phase current IA and IB:
Sector
A
B
C
D
E
F
T1
U
V
V
W
W
U
T2
-W
-W
-U
-U
-V
-V
IA = IU
U
(-W) - V
-(-U)
-(-U)
(-V) - W
U
IB = IV
(-W) - U
V
V
(-U) - W
-(-V)
-(-V)
2.3.1
Limitations of Phase Current Reconstruction
When T1 or T2 equals 0, only one phase current can be reconstructed. To avoid this situation the PWM times T1
and T2 have to be limited to a minimum value. This causes a ripple in the phase-phase voltage and also in the
phase current as well. A very fast ADC is required in order to maximize the performance of phase current
reconstruction.
The following figure (Figure 13) shows the output voltage and phase voltage of a T1-T2-limited space vector
modulation.
Application Note
14
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
800
800
700
600
600
400
500
200
V_UN
400
V_UN - V_VN
V_VN
V_VN - V_WN
0
V_WN
0
300
60
120
180
240
300
V_WN - V_UN
-200
200
-400
100
-600
0
0
60
Figure 13
120
180
240
300
-800
Distortion in Output and Motor Voltage
Although the output signal is slightly distorted, the most cost efficient method of phase current measuring is the
reconstruction from the DClink current via a single shunt. A very fast ADC is required to optimize the system
performance. A direct trigger from the PWM Unit to the ADC reduces the CPU load significantly.
2.4
FOC Calculations
FOC is a method to generate a three phase sinusoidal signal which can be easily controlled in frequency and
amplitude in order to minimize the current and to maximize the efficiency. The essential idea is the transform of
three phase signals into two rotor-fix signals, and vice-versa. In the rotor-fix reference frame, the currents are
stationary and easy to control. The inverse vector rotation causes the controlled voltages to rotate.
2.4.1
Stationary and Rotating Reference Frames
Rotating reference frame
Two phase reference frame
Three phase 120° reference frame
IV
Iq
Iβ
Id
ϕ
IU
Iα
A
B
C
Iq
D
E
A
F
Iα
B
C
D
E
A
F
B
IU
Iβ
C
D
E
IV
F
IW
Id
IW
Figure 14
Stationary and Rotating Reference Frames
The transform from the three phase system to the two phase system is called a ‘Clarke transform’.
The transform from two phase system to the rotating system is called a ‘Park transform’.
The Clarke, Park and Inverse Park transforms are expressed in the following equations.
Application Note
15
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
Clarke Transform:
iα = iU
(23)
1
i β = ------- ⋅ ( i U + 2i V )
3
(24)
iU + iV + iW = 0
(25)
i d = i α cos ϕ + i β sin ϕ
(26)
i q = – i α sin ϕ + i β cos ϕ
(27)
i α = i d cos ϕ – i q sin ϕ
(28)
i β = i d sin ϕ + i q cos ϕ
(29)
Park Transform:
Inverse Park Transform:
Summary Transformations
IV
•
Iq
•
Iβ
•
•
Id
θ
Iα
Clarke transformation is used to remove the
redundancy of the 3 phase system
Park transform provides a rotating d-q-reference
frame
The currents Id and Iq are stationary and easy to
control
The inverse Park transform makes the controlled
voltages rotating
IU
IW
Figure 15
Summary of Transformations
Application Note
16
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
2.4.2
Sensorless FOC
When the exact position of the rotor is not required, the costs for an encoder or other position sensor can be saved.
The motor’s back EMF is utilized in order to calculate the rotation angle and rotor position.
The back EMF is calculated in the flux estimator, which is based on the voltage model of the system in the two
phase reference frame. A single shunt is enough to reconstruct the phase currents.
Figure 16 shows the block diagram of the sensorless FOC algorithm. The flux estimator’s input signals are taken
from the orthogonal two phase stator system with the index α and β. The output signal represents the rotor angle.
0
+
-
reference
speed
speed
+
PI-controller
-
ω
+
-
Id
Vd
inverse
Park
transform
PI-controller
Iq
PI-controller
Vq
speed
calculation
Id
Figure 16
Vβ
cartesian θ
to
|V|
polar
transform
PWM-Unit
U
Modulator
V
W
Two-level
Voltage Source
Inverter
(VSI)
with
integrated
deadtime
control
Flux
estimator
ϕ
Iq
Vα
Iα
Park
transform
Iβ
Clarke
transform
Current
Calculation
ADC
IDClink
shunt
Block Diagram of Sensorless Field Oriented Control (FOC)
The motor signals in the two phase stator system (α-β-system) are equivalent to the three phase system. As a
result, an ideal two phase motor can be assumed in the α-β-system. Then there are only two equations to
calculate. Figure 17 shows the voltage equations of the motor in the α-β-system:
Flux of stator ψs:
β
ω
S
N
ϕ
i sα
Rs
α
(30)
ψ sβ = L ⋅ i sβ + ψ pβ = L ⋅ i sβ + ψ p sin ( ϕ )
(31)
Stator Voltage Equation:
Ls
v sα = R ⋅ i sα +
dψ sα
di
dϕ
= R ⋅ i sα + L ⋅ sα – ψ p sin ( ϕ )
dt
dt
dt
(32)
v sβ = R ⋅ i sβ +
dψ sβ
di
dϕ
= R ⋅ i sβ + L ⋅ sβ + ψ p cos ( ϕ )
dt
dt
dt
(33)
-ψp ω sin(ϕ)
vsα
isβ
ψ sα = L ⋅ i sα + ψ pα = L ⋅ i sα + ψ p cos ( ϕ )
Rs
Ls
-ψp ω cos(ϕ )
vsβ
Figure 17
Voltage Equations of Ideal 2-phase Motor
The flux of the stator (Equation (30), Equation (31)) contain the mutual inductance
with the permanent magnet ψ p .
Application Note
17
L ⋅ i s and the flux of the rotor
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
Theory of Sensorless Field Oriented Control (FOC)
The stator voltage equations (Equation (32), Equation (33)) contains the resistance of the coil
derivative of the flux of the stator (Faraday’s Law).
R ⋅ i s and the
Integrating the voltage equations, the stator flux is calculated as:
ψ sα =
∫ ( vsα – R ⋅ isα ) dt
(34)
ψ sβ =
∫ ( vsβ – R ⋅ isβ ) dt
(35)
The flux of the rotor and the orientation (angle ϕ) of the permanent magnet of the rotor is calculated by insertion
of Equation (34) in Equation (30), and Equation (35) in Equation (31).
ψ pα = ψ sα – L ⋅ i sα =
∫ ( vsα – R ⋅ isα ) dt – L ⋅ isα
(36)
ψ pβ = ψ sβ – L ⋅ i sβ =
∫ ( vsβ – R ⋅ isβ ) dt – L ⋅ isβ
(37)
ψ pβ
ϕ = atan  ---------
 ψ pα
(38)
Finally, the position of the rotor can be calculated by knowing the resistance R and inductance L of the motor. The
stator voltage vs is known by the algorithm. The current is needs to be measured in real-time.
Application Note
18
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3
FOC Implementation on XC878
Infineon’s FOC Drive Application Kit (ordering code: KIT_AK_FOCDRIVE_V1) comes with the following hardware:
•
•
•
•
•
•
DriveCard XC878
DriveCard XE164
Low Voltage Inverter (23V-55V, 7.5A)
PMSM motor (15W)
DriveMonitor stick
Power supply (24V)
Figure 18
FOC Drive Application Kit
This section describes the FOC implementation on the 8-bit device XC878.
The project setup is available for two 8051 toolchains:
1. Keil Compiler, µVision IDE with Debugger and Simulator.
– A Keil PK51 license is required as the code size has ~5kBytes in total.
– An internet connection is needed for the license key. Please refer to Infineon Free Toolchain program:
www.infineon.com/Freetools
2. SDCC Compiler, MiniIDE, Hitop Debugger.
– This toolchain is free of charge and the user can start immediately.
The project is DAvE compliant; i.e. the peripheral settings can be changed or added to using the DAvE code
generator, and can then be recompiled afterwards.
A Microsoft Office Excel® worksheet is used as a user friendly interface for entering data on scaling and motor
parameter adaptation. The Excel sheet is then used to generate the contents for a C header file.
The DriveMonitor is used for real-time monitoring of some interesting application variables, and also offers a
control interface to the application itself. Data is exchanged via a CAN bus.
Note: The description which follows is intended for the advanced user; i.e. some basic knowledge of the Infineon
toolchain is a prerequisite. There are several application notes which explain this in detail (see Chapter 6),
and hands-on-training is also available. For the less advanced user it is recommended to start with the
DaveDrive autocode generator.
Application Note
19
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.1
Program Flow
Timer T21 operates as system timer and overflows every 500us. With this system tick the scheduler state machine
switches to the application states and communicates to the host via CAN messages.
The FOC algorithm is calculated with every T13 interrupt at highest interrupt priority.
The emergency state is triggered by the CTRAP interrupt.
CAN – REC
ID5 / ID55
RESET
low
CAN – TRX
ID7 / ID77 / ID57
low
CAN – ERR
low
Initialize
Application
copy message
to buffers
set NewCMDx
clear message
pending flags of
sent objects
handle errors
MAIN
reti
reti
reti
Scheduler
T21
every 0.5 ms
CTRAP
interrupt
T13
interrupt
send
CAN messages
mid
high
low
set emergency
state
Scheduler
switch states upon
command exec.
CC6 Shadow
Transfers
FOC_Calculation
reti
reti
Speed Ramp
ret
reti
Figure 19
Overview of Main Functions and Interrupts for the Sensorless FOC Application
Application Note
20
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.2
Initialization
The peripherals of the XC878 are initialized in separate files, before the application itself is initialized in the file
main.c.
3.2.1
CC6 Timer Unit
The PWM is generated with the CC6 timer unit. Both timers T12 and T13 are used.
•
•
T12 generates the signals for the Space Vector Modulation (SVM).
T13 generates the two trigger events (compare and period match) for the ADC.
T13 runs in single shot mode and starts automatically with a zero-match of the T12.
The compare values for T12 and T13 and the period value for T13 is calculated within the function
FOC_calculation().
The period-match T13PM generates an interrupt. This is described in detail in Chapter 3.5.
The passive level selection of the CC6 compare output signals fits to the Infineon 3 phase gate driver 6ED003L06F. To avoid spikes and dangerous transitions at startup the CC6 has a special feature which is used for the
initialization and for the Start/Stop/Emergency states. The CC6 trap state is forced by software. At the very
beginning of CC6_vInit() the flag TRPF is set. This ensures that the output signals always show the defined
passive level during initialization, until the flag TRPF is cleared.
Note: DAvE does not set the TRPF flag.
There are two application specific constants which have to be defined before compilation in the Excel sheet
(foc_defines.h):
• CCU6_DEADTIME
• T12PERIODE
3.2.2
ADC
The ADC measures the DC-link current signal, the DC-link voltage and the potentiometer voltage. Two alternate
analog signals can additionally be measured with this setup.
The ADC is triggered by the two T13 events, T13CM and T13PM.
The compare match (T13CM) triggers the sequential request source while the period match (T13PM) triggers the
parallel request source.
The sequential source has a queue stage of three inputs: channels ch3, ch7 and one of either ch0, ch1, or ch6 in
time-multiplex. The parallel source samples ch4.
Signal
Channel
Result
Source
Remark
Phase current IU
ch3
RESR0
sequential
time critical
Phase current IV
ch4
RESR1
parallel
time critical
Potentiometer
ch0
RESR3
sequential
time multiplex
RESR2
sequential
DC link voltage VDC ch1
alternate signal
ch6
alternate signal
ch7
-
The function FOC_calculation() reads the result registers and handles the software switched time-multiplexing of
the three channels.
The ADC timing (sample and conversion time) influences the minimum duty cycles of the SVM. This is reflected
in the Excel sheet (FOC_defines.h) value T_MIN.
Application Note
21
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.2.3
CAN
The MultiCAN module is used with one node, 5 message objects, a receive, a transmit and an error interrupt.
The CAN bus offers a fast and safe data exchange with a host computer.
Via the CAN module the FOC values can be monitored in real-time using the DriveMonitor, although the CAN
module is not needed for the FOC algorithm itself. The scheduler routine handles the CAN interrupts and
messages.
The big advantage of using CAN is very efficient message handling with very little CPU load, and without error
handling. For additional information, please refer the DriveMonitor application note (See Chapter 6).
3.2.4
T21 Timer
Timer T21 is configured in 16-bit auto-reload mode, providing the system tick which triggers the scheduler
interrupt. The timebase can be adjusted, but by default it is set to 500us.
3.2.5
Application
The application specific settings are performed in the following functions:
•
•
•
Scheduler_vInit()
– Resets the global variables for the command handling.
Scope_vInit()
– Initializes the CAN transmit buffers with the pointers for the monitoring data.
MotorControl_vInit()
– Sets up the startup values for the open and closed loop controllers. Here the parameters entered in the
Excel sheet (FOC_defines.h) are read and the CTRAP pin is polled in order to detect a static fault. The state
machine is then initialized to the DEFAULT_STATE. The default state is another parameter on the Excel
sheet, and is either the Idle or the Boostrap state.
Application Note
22
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.3
Scheduler State Machine - T21 Interrupt
This state machine runs cyclic at every 500us. Here the application states are switched.
The entry into the state machine is the IDLE state after power-up. This is dependent on the Excel sheet parameter
(FOC_defines.h) and is either STATEBOOTST or DEFAULT_STATE.
Power up
CC6_vInit();
MotorControl_vInit();
EMERGENCYSTOP:
MotorStop();
reset trapstate
EMCY
Off
On
closed_loop
Trap
CTRAP:
IDLE
Off
On
closed_loop
Trap
Start
BOOTST
low level at
pin CTRAP
Off
On
closed_loop
Trap
BootStrap()
reset trapstate
all lowside switches ON
wait BOOTSTRAPTIME loops
Stop
MotorStop()
disable power stage
enter trapstate
disable T 13-FOC interrupt
reset & stop T12 & T13
STOP
STARTUP
Off
On
closed_loop
Trap
Stop
∆ϕ > threshold
reference _speed < threshold
Stop
Stop
RAMPDN
RAMPDOWN:
reference_speed_user
= threshold;
FOC
Off
On
closed_loop
Trap
Figure 20
Application State Machine
3.3.1
State IDLE
•
Off
On
closed_loop
Trap
MotorStart( )
set startup speed
enable power stage
enable T13-FOC interrupt
Ramp Down
Off
On
closed_loop
Trap
Interrupt: T13
FOC_Calculation()
Speed ramp
Wait on Start-command from host.
3.3.2
State BOOTST
This is the first state where the CC6 drive active states on it’s output pins. The bootstrap capacitors are charged
by switching all lowside switches ON and the highside switches OFF. This is performed with the following
sequence:
•
•
•
•
•
•
Enable CTRAP emergency feature (falling edge on pin CTRAP will cause a trap state) and CTRAP interrupt if
set in Excel sheet (FOC_defines.h): CTRAP_Enable and CTRAP_PIN (pinselection).
Enable the POWER_STAGE; i.e. switch the ENABLE_PIN of the gate driver IC. The polarity and pin can be
selected via the setting ENABLE_PIN.
Switch on all lowside switches by programming the CC6 shadow registers.
Start timer T12 and generate PWM (constant 100% duty cycle).
Release the trap state by resetting the TRPF.
Stay in Bootstrap state until the global variable guc_SpeedControlCounter has counted down. This
variable is defined in the Excel sheet (FOC_defines.h):
– BOOTSTRAPTIME
Application Note
23
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.3.3
State STARTUP
The startup mechanism is quite complex but has the following flow (see also Figure 21 which follows):
•
•
•
•
•
•
Switch on the PWM modulator by calling MotorStart().
– Here the global variables are initialized, bit gb_On is set.
– The startup speed and direction as well as the offset phase voltage are set in case of a “cold-start”. The
global bit gb_Once is used to distinguish between a “cold-start” and a “warm-start”. This bit is set if it was
zero before.
– The timer T13 interrupt is enabled which allows the FOC_calculation() with the next system tick.
There is a switch CLOSEDLOOP, which is another Excel sheet parameter (FOC_defines.h). If not defined, the
algorithm will stay in an open loop V/f control and will never enter the FOC. The difference between these two
is that the V/f control takes the rotor position (∆ϕ) from a fixed relationship between voltage and frequency
regardless of the real position, whereas the FOC determines the angle in the flux estimator. The FOC therefore
operates with the real rotor position.
At startup, the flux estimator cannot calculate the correct angle as the input signals (current measurement) are
not accurate enough. This means that the motor has to start in an open loop V/f control. As the V/f constant
depends on the motor and load characteristic there are a few parameters which can be adjusted in the Excel
sheet (FOC_functions.h)
– Startup speed (Figure 21, SpeedT0) DELTA_ANGLE_START_T0
– Threshold speed (Figure 21, Threshold) DELTA_ANGLE_THRESHOLD
The SpeedUser (DEFAULT_SPEED_REFERENCE in FOC_defines.h) is the reference speed the user has to
set. If this is below the threshold speed, the algorithm will stay in V/f control.
The slew rate of the V/f is defined by Excel parameters SPEEDRAMPSTEP and SPEEDRAMPTIME. The steps
are counted in T13 interrupt (See Chapter 3.5.5); i.e. the timebase for the speedramp is the T13 period.
This Startup control block ramps with every system tick of the V/f ramp. If the threshold speed is reached, the
global bit gb_closed_loop is set and the state variable is switched to the state FOC.
The state Startup can be left by an emergency event or by command Stop.
Application Note
24
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
Vd
Inverse
Park Transform
1
0
0
gi_V_d
Vq
1
0
gi_V_q
Speed
Calculation
Speed
Control
∆ϕ
ϕ
∆ϕ
ω=
∆t
gi_angle
gi_angle_mem
gi_Flux_Angle
gi_Angle
1
0
1
ϕ
Flux
Estimation
0
gb_closed_loop
Startup control
1
∆ϕ ≥ threshold
ϕ + ∆ϕ ⇒ ϕ
0
CLOSEDLOOP
n
startup
Threshold
SpeedUser
DeltaAngleT 0
V/f control
∆ϕ * slew * 256 + offset
gi_V_q_vf_slew
gi_V_q_vf_offset
Figure 21
Startup Algorithm
3.3.4
State FOC
t
∆ϕ =
gi_delta_angle
gi_delta_angle_T0
DELTA_ANGLE_THRESHOLD
This state does nothing but run the sensorless FOC algorithm. The only input parameter is the speed reference
(gi_Speed_reference_user). The algorithm tries to keep the speed constant even under load changes.
The speed reference information comes either from the DriveMonitor (via CAN) or from the onboard
potentiometer. This can be configured in the Excel sheet (FOC_functions.h) parameter SPEED_POTI.
In state FOC, global bit gb_closed_loop is one.
The state FOC can be left by an emergency event or by the commands Stop or Rampdown.
3.3.5
State RAMPDWN
After receiving a Rampdown command, the state FOC is left and the speed is ramped down. This is done by simply
setting the reference speed to the startup speed. The speed controller will reduce the Iq reference but limits it to
a positive value; i.e. it does not actively brake. The motor will therefore slow down with it’s own inertia.
Application Note
25
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
For active braking the Iq limitation can be changed in FOC_Calculation() at section “Speed Control”. In this
instance it is recommended to supervise the DC link voltage VDC and limit the Iq amplitude.
On reaching the startup speed the state Stop is set for the next system tick.
3.3.6
State STOP
The state Stop is entered upon receipt of the command Stop. The function MotorStop() is called. Here the
powerstage is switched off by the ENABLE_PIN and the interrupts T13 and CTRAP are disabled.
The trapstate is forced by software, and the timers T12 and T13 are stopped and reset.
The speed is reset to the default and the global bits gb_On and gb_Off are respectively reset and set.
The state variable is set to IDLE for the next state.
3.3.7
State EMERGENCY
In the case of a falling edge at the CTRAP pin due to a fault situation such as an over-current, the CTRAP interrupt
is vectorized. This sets the state Emergency.
The MotorStop() function is called (see Chapter 3.3.6), the trapstate is released by clearing bit TRPF, and bit
gb_Trap is set in order to signal a locked emergency situation. The Emergency state can only be left by the
receipt of a Stop command or a RESET. A Start command has no effect.
If the Stop command is received, the next state is set to Stop. Then a Start command will restart the state machine.
In the case of a static low level at pin CTRAP, due for example to the none resolved fault situation, the Emergency
state is entered in the bootstrap phase.
3.4
CAN Communication - CAN Interrupts
The CAN controller is configured to three interrupt vectors for receive, transmit and error handling.
The CAN Message Objects have the following IDs:
•
•
•
•
•
ID5
ID55
ID7
ID77
ID57
- receive object
- receive object
- transmit object
- transmit object
- transmit object
- MO 0:
- MO 2:
- MO1:
- MO 3:
- MO 4:
SET/GET command and Buttons
Unused
Slow data for status flags and display field
Fast data for oscilloscope and progress bar
Respond to GET command
On receipt of a CAN message object the receive interrupt is vectorized. The corresponding message object is
copied into the 8-byte wide receive buffer in case there is no command pending. The global command variable is
updated and a bit indicating a new command is set.
At every system timer tick the scheduler state machine is executed and the bit indicating a new command is polled.
If set, the corresponding command is executed and the bit is cleared afterwards in order to accept new commands.
This handshaking mechanism with the receive interrupt ensures that an incoming command has to be served first
before a new command is accepted.
The three transmit message objects are configured for sending data from the target to the host. The transmit
interrupt service routine is vectorized once the CAN message is completed. The corresponding transmit pending
flag is cleared. Each transmit message object has a different trigger event.
The transmit messages have to be initialized. The transmit buffers CANTrxBuf0[8] and CANTrxBuf1[8] are written
with the address of the data to be transmitted. This is performed in the function Scope_vInit().
A detailed description of the command handling and the communication protocol can be found in the DriveMonitor
application note (See Chapter 6).
Application Note
26
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.5
FOC Control Loop - T13 Interrupt
The following figure (Figure 22) shows the timing diagram for the sensorless FOC algorithm.
This figure is a zoom into two PWM periods of the space vector modulation. It shows the resulting ADC trigger
points for the single shunt current measurement. These trigger points are pre-calculated for the next cycle within
the FOC routine. The speed ramp function is also called here. The hard real-time condition is that the FOC
algorithm must fit into 1.5 - 2*TPWM cycles.
TPWM
T12
TPWM
T12PR
CC60SR
CC61SR
CC62SR
T13PM
t
T13
T13PR
hardware
start
CC63SR
period match
compare match
t
IDClink
Event (ETR01):
T13CM
start ADch3
store in RESR0
start ADch1,6,0
store in RESR3
Event (ETR10): t
T13PM
start ADch4
store in RESR1
ISR – T13PM:
CCU6_viNode3
Figure 22
Timing of T12 PWM and T13 ADC Trigger Events for Current Measurement at the DC Link
Shunt
3.5.1
Shadow Transfer
First, the shadow transfer request bits for timer T12 and T13 are set. This ensures that the actual calculated
compare values for the SVM and the current measurement are updated with the next period match event.
3.5.2
FOC Calculation
After the shadow transfer, the FOC calculation routine is called.
The whole FOC algorithm is summarised in Figure 23 (see also Chapter 5 for a larger version of this diagram).
The building blocks shown are exactly implemented, mostly in the file FOC_Functions.c.
The FOC calculation has the following flow (starting from the bottom right corner of the diagram, moving in a
clockwise direction):
•
•
•
•
•
ADC result register control
Current calculation and phase current extraction
Clark transformation
Flux estimation
Park transformation
Application Note
27
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
•
•
•
•
•
Speed calculation and speed control
Current control
Inverse park transformation
Cartesian to polar transformation
Space vector modulation
The block startup control is described in Chapter 3.3.3.
The FOC calculations are performed in fixed point number format Q15.
Multiplying two Q15 numbers will result in a Q30 number. The 16-bit Multiply and Divide Unit (MDU) as part of the
vector computer is well suited for these calculations. The result holds a 32-bit value whose two most significant
bytes represent the Q14 result. In order to get the Q15 result, this number has to be shifted left by one bit.
PI
1
0]
Inverter
+
TPWM
gi_V_alpha
CORDZ
CC60 SR
gi_V_d
8
PI
CCU6E
TPWM
T12
T12 PR
0
0
Modulator
Θ
N
0
1
F0
gt_Id_control
Carthesian
to Polar
Transform
Vα
[11
y Vd
y m in
*K:4
*K:4
[: s3]
PI
B
[011]
[: s4]
S
KP
yma x
N
+
128
S
y n min
S
Inverse
Park Transform
yn ma x
N
1
s 2TI
]
x
0
[01
+
-
gi_Id_reference
C
A
D
F
E
[100]
CC62 SR
N
pm
LS
Driver
T13 PR
0
8
gi_Iq_reference
+
-
x
1
s 2TI
yn ma x
y n min
+
128
KP
yma x
y Vq
0
1
Ts
+
-
Speed
Calculation
x
∆ϕ
ϕ
ω=
1
T
Speed Ramp
∆ϕ
∆t
gi_Angle
∆n
∆t
+
-
:2
+
K
Ts
1
T
0
gb_closed_loop
t
K ⋅L
T ⋅2
PT1_32
0
1
SpeedRefUser
RampSlew =
16 ⋅ R
vα +
1
gi_Flux_Angle
SpeedStartup
Flux Estimation
iα
gi_angle
gi_angle_mem
gi_Speed
gc_Speed1
n
K = Z1/Z2
T = 1/Z2
gi_Flux_alpha
x
 y ϕ
arctan 
 x
gi2_Integrator_alpha[0:1]
guc_RampSlew
gi_Speed_startup
gi_Speed_reference_user
Startup control
iβ
ϕ + ∆ϕ ⇒ ϕ
0
n
CLOSEDLOOP
16 ⋅ R
vβ +
s tartup
Threshold
K ⋅L
T ⋅2
PT1_32
+
-
:2
SpeedUser
DeltaAngleT 0
K = Z1/Z2
T = 1/Z2
t
gi_V_q_vf_slew
gi_V_q_vf_offset
∆ϕ =
CORDY
+
K
Ts
1
T
V/f control
∆ϕ * slew * 256 + offset
CORDZ
y
∆ϕ ≥ threshold
1
gi2_Integrator_beta
gi_delta_angle
gi_delta_angle_T0
DELTA_ANGLE_THRESHOLD
Id
Park Transform
gi_I_d
Iq
gi_I_q
Clarke Transform
Iα
gi_I_alpha
*K:2
[: s2]
Iβ
Iα = 12 ⋅ I phaseA
Iβ =
1
2 3
⋅ (2 I phaseB
*0.5
[s1]
+ I phaseA )
I phaseA
gi_I_phaseA
Current
calc.
RESULT 0
ADC
CH3
:4
I phaseB
[: s0]
*G
RESULT 1
CH4
RESULT 2
CH7:
Rshunt
gi_I_phaseB
gi_I_beta
VDC
Ch6
POT
Figure 23
3-phase motor
t
gi_V_q
8
y
CC63 SR
C
0
gi_Amplitude
PT1_24
gi_Speed
y ma x
gi_V_beta
0
1
F0
gt_Iq_control
|V |
Vβ
1
y m in
1]
1
F0
gt_speed_control
y
1]
y min
[10
KP
ym a x
[00
+
128
N
y n m in
S
yn ma x
1
s 2 TI
S
x
N
+
-
L
t
T13
cm
gi_Speed_reference
R
HS
Driver
CC61 SR
S
Result3
Control
CH1: VDC
RESULT 3
CH6:
CH0: POT
FOC Building Blocks
Phase Current Calculation
The ADC is configured to measure phase currents via the DClink current within one PWM period. The result of the
measurement is stored in result register 0 and result register 1. The current calculation block takes the values from
these result registers and calculates the phase currents IU and IV, which are IphaseA and IphaseB in the diagram,
respectively. They are signed integer values which are scaled by a quarter full scale. The scale factor is called s0
in the Excel file.
Clarke Transform
The Clarke Transform is calculated according to Equation (23), Equation (24) and Equation (25). The result is
divided by 2, due to calculation time optimization with the MDU. As a result, the Clarke transform scales the current
by 0.5, which is the scale factor s1 in the Excel file.
Application Note
28
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
Park and Inverse Park Transform
The Park and inverse Park transform is calculated by the CORDIC module of the vector computer. The CORDIC
can be used in six different modes. Here the circular rotation mode is selected, which scales the result by a factor
K ≈ 1.64676. The additional scale down by dividing with 2 (Park transform, s2) and 4 (inverse Park transform, s3)
is an optimization of the FOC algorithm.
Carthesian to Polar Transform
The Carthesian to Polar transform is calculated with the CORDIC module in circular vectoring mode. The scale
factor K ≈ 1.64676 results in the approximation scheme. Together with the additional division by 4 the scale value
s4 is defined.
3.5.3
Flux Estimator
The flux estimator has been discussed in Section 2.4.2. The final equations (Equation (36) and Equation (37))
require an integrator which is implemented as PT1 controller. See Figure 24 for details.
The differential equation of a PT1 is defined as follows:
PT1
x
+
-
K
Ts
1
T
y
T ⋅ d y(t) + y(t) = K ⋅ x(t)
dt
When Equation (39) is divided by T, the term
values of T.
(39)
--1- ⋅ y ( t ) can be neglected for large
T
The remaining equation can be integrated:
K
y ( t ) = ---- ∫ x ( t ) dt
T
(40)
K
As a result, the PT1 can be used as integrator with a gain of --T . This gain has to be
considered in the overall scaling and the calculation of the parameters.
Figure 24
PT1 Controller
The implementation of the flux estimator makes use of the vector computer wherever possible, and the parallel
use of CORDIC and MDU provides the highest performance.
The CORDIC is used for calculation of v sα – R ⋅ i sα in linear rotation mode. In this mode, the Z data of CORDIC
is handled as a number in signed 4Q11 format. Because the calculation of all other values is in signed Q15 format,
the resistance R appears with a gain of 16 in Figure 23.
KAs shown in Figure 24, the PT1 controller provides a gain of --T . Using this gain, the inductance L of the motor can
be adjusted to a reasonable resolution in the algorithm.
The Excel file provides the adjustment of both K and T. It is recommended to adjust K in order to increase the
resolution of the inductance L. Low inductive motors in particular will require an adjustment of this value. The
integration window, represented by the T value, can be adjusted according to the application’s needs. Small
values of T will cause the flux estimator to act very fast. As a result noise in the current measurement does not
accumulate too much due to the integration. Large values of T will result in a high accuracy of the integrator, but
the dynamic of the system is reduced.
Application Note
29
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.5.4
PI-Controller with Anti Wind-Up Limitation
The speed control and the current control of the implemented FOC utilize the same PI controller. This PI controller
has an additional adjustable gain for the constant Kp and a separate limitation for the integral part. The additional
gain is necessary to support a wide range of Kp values with the same controller.
The additional gain can be selected by the flag F0:
•
•
F0 = 0: Gain = 8
F0 = 1: Gain = 128
PI Controller
x
1
s 2TI
ynma x
y nmin
+
128
KP
y
y min
1
0
8
F0
Figure 25
yma x
PI Controller with Anti Wind-Up Limitation yn
The limitation ynmax and ynmin of the integral part provides an anti wind-up limitation.
A PI controller can wind-up when the Ki value is small and the difference between the given value and actual value
can not be compensated by the whole system. Then the integral part continues to increase, but there is no effect
due to the output limitation of the PI controller. When the given or actual value changes and the PI controller should
compensate in the opposite direction, the integral part has to reduce by the small Ki value. As a result, the output
of the PI controller is misaligned. In order to reduce the duration of this misalignment, the integral part can be
limited independently to the output of the PI controller.
Application Note
30
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Implementation on XC878
3.5.5
Speed Ramp
The speed ramp is dependent on the slew rate. The slew rate is defined by the Excel parameters SPEEDRAMPSTEP
and SPEEDRAMPTIME.
The speed steps are counted in T13 interrupt, which is triggered by a T12 zero match event; i.e. the timebase for
the speedramp is the T12 period.
The speed formula is:
•
Speed slew rate = ∆n / ∆t with ∆n = SPEEDRAMPSTEP and ∆t = SPEEDRAMPTIME * T12period
Speed Ramp
n
SpeedUser
Speed
RampSlew =
∆n
∆t
t
guc_RampSlew
gi_Speed_reference
gi_Speed_reference_user
Figure 26
Speed Ramp
The speed ramp handles three cases:
•
•
•
V/f open loop at startup
FOC
FOC in case of rampdown
In the latter two cases the global bit gb_ramp is set to indicate that reference has not yet been reached.
Application Note
31
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
4
How to Use the Setup
4.1
Excel Sheet and FOC_Defines.h
The parameterization of the application is performed via a header file (FOC_Defines.h). For ease of use, an Excel
sheet (see Figure 27) is used to generate the header file contents. The algorithm itself (FOC_functions.c and
scheduler.c) can be left untouched.
The Excel sheet has two pages: the input page Input Parameter, and the output page FOC_defines.h.
The Input Parameters are set in the yellow shaded fields. These are the most relevant parameters and have the
following structure:
•
•
•
•
•
•
•
•
Motor Parameter - The resistance and inductance of the motor windings. The input value refers to one phase;
i.e. phase-to-start and not phase-to-phase.
Startup Parameter - Values which are used in the startup block.
Inverter Parameter - When a customized inverter is used, it can be adapted here.
Current Measurement - For adjustment of the current amplification or the shunt.
Speed and Current Controller - Sets the integral and proportional factor for the PI-controllers.
Flux Integration Scaling - Sets the PT1 filter for the flux estimator (integration window time and gain).
Speed Filter - For adjustment of the PT1 filter for the speed filter.
Speed Ramp - For adjustment of the speedramp time. If the Speed Ramp time in the startup parameters is not
fast enough, the incremental steps can be increased.
XC878 sensorless FOC
Parameter Calculation
v1.0.00
Motor Parameter:
R
L
Pole Pairs
MAXON EC32-flat
6,85 ohm
3865 µH
4
Startup Parameter:
Startup Speed T0
Startup Speed Threshold
Startup V/f offset (f = 0)
Startup V/f slew rate
Reference Speed User
Speed Ramp
0
800
1
0,307692308
2000
5000
Inverter Parameter:
DC link voltage
dead time
switch delay (max)
PWM frequency
Bootstrap precharge time
ENABLE pin logic level
24
1
0,7
15000
1,5
1
Scale Factors for Drive Monitor
rpm
rpm
V
V/Hz
rpm
rpm/s
V
µs
µs
Hz
ms
Startup:
Startup V/f offset (f = 0)
Startup V/f slew rate
0,000410 V
0,000056 V/Hz
Speed:
speed
1,716614 rpm
Voltages:
V(d,q)
V(α,β)
V(svm amplitude)
0,000410 V
0,000997 V
0,018008 V
Currents:
I(d,q)
I(α,β)
I(u,v,w)
0,001478 A
0,001795 A
0,000898 A
PI Controller:
Speed kp
0,003906
Speed ki
0,000031
Current kp
Current ki
0,000244
0,000031
1: high active
-1: low active
ENABLE_PIN
CTRAP Enable
CTRAP_PIN
Autostart enable
Use poti for speed
Current Measurement:
R_shunt
R_IN
R_feedback (R14)
maximum Voltage at ADC
0,02
1
33
5
Speed PI Controller:
Ki
Kp
0,01 ( < 0,5 )
10 ( <128 )
Current PI Controller:
scale
Figure 27
P5 0
1
P3 6
1
1
ohm
kOhm
kOhm
V
0,1 (<= 0,1)
Excel Sheet Input Page (The Most Relevant Values for FOC and DriveMonitor)
CPU Parameter
CPU Frequency
24 MHz
ApplicationCPU
Note
Parameter
CCU6 Frequency
CCU6 - T12 Prescaler
Algorithm Specific Parameter
32
48 MHz
1
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
It should be noted that the parameters influence each other. For example, a very low inductance value L will scale
to a very low value L’, which is used for the flux estimator. In this instance the input parameter K in the Flux
Integrator Scaling should be increased.
Note: If the Excel sheet shows cells marked in red, then the scaling parameters have to be changed accordingly.
After changing the Input Parameter the contents of the output page have to be copied to the file FOC_defines.h,
and the C-project has to be re-complied and downloaded to the target.
The Excel file also creates the scaling factors for the DriveMonitor. For instance the speed scaling changes when
the number of pole pairs changes. These values have to be adapted inside the DriveMonitor configuration (CAN
control editor).
4.2
Project Settings
The complete C-project is DAvE compliant; i.e. the peripheral configuration is performed with DAvE. This has the
advantage that the initialization is visible on a user friendly interface and re-configuration or add-on’s are
straightforward. For example, adding UART or SPI, or removing CAN, is possible with DAvE, and a re-generation
will not destroy the existing code.
The setup is done for two different 8051 compilers (Keil and SDCC). Most files are in the C-language but the
algorithm in FOC_functions.c is in Assembler (ASM).
As the endianess of Keil (big endian) and SDCC (little endian) are different, the interfacing between C and the
ASM must be adapted. For the FOC project this is mainly the 16-bit data variables and the structures for the PI
controllers. These variables are used in both ASM and C, hence the ASM code is different. Please refer to the
following examples:
Table 1
Reading a 16-bit Variable in Keil / SDCC
Keil
mov
mov
r7,gi_Id_reference
r6,gi_Id_reference+1
SDCC
mov
mov
r7,_gi_Id_reference+1
r6,_gi_Id_reference
Table 2
Accessing struct Yn[ ] in Keil / SDCC
Keil
inc
mov
mov
dec
r0
a,@r0 ; store yn_max in R2
r2,a
r0
SDCC
inc
inc
mov
mov
dec
dec
r0
r0
a,@r0 ; store yn_max in R2
r2,a
r0
r0
The C-code for Keil and SDCC is identical except for some declarations.
Because of the DriveMonitor communication, the monitoring variables must have dedicated addresses. These
addresses are set in main.c:
Application Note
33
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
Table 3
Variable at fixed Address in Keil / SDCC
Keil
data int gi_angle _at_ (0x0030);
SDCC
data at 0x0030 int gi_angle;
4.3
Toolchain
The two compilers Keil and SDCC use different toolchains. Where Keil offers with the µVision IDE one tool which
serves all aspects, the SDCC compiler needs a separate IDE (MiniIDE) and a debugger (Hitop).
Keil offers a free evaluation version which is limited to 2kByte codesize. There is a free toolchain program at IFX
(a registration link is given in Chapter 6). The SDCC based toolchain is completely free of charge.
Code Generator
DAVE
Mini
IDE
IDE
Device Connect
Flash Loader
SDCC
Hitop
Keil uVision
Compiler
Debugger
Simulator
Drive
Monitor
Monitor
Figure 28
Toolchain for 8051 for Compiler Keil and SDCC
Application Note
34
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
4.4
DriveMonitor
The DriveMonitor is a hardware tool which bridges USB to CAN. With the DriveMonitor it is possible to monitor
data of the target on a host PC, in real-time.
For more information please refer to the DriveMonitor application note (see Chapter 6 [1]).
4.4.1
Configuration
The configuration of the DriveMonitor setup is described in the DriveMonitor application note (see Chapter 6 [1]).
4.4.2
Monitoring the Startup Behavior
Different motors have different startup behavior. Starting up a synchronous motor is always quite tricky. The first
revolutions have to be in an open loop mode before the FOC algorithm can take over.
There are some values which primarily influence the startup behavior. These values are to be found in the Excel
sheet under Startup Parameter, and are discussed here.
After setting the correct R and L values, compilation and downloading the DriveMonitor can be started and used
in Setting 1 | Startup.
After connecting to the target, the button Scope Start should be pressed and then the button Start.
The motor should start turning and after a few seconds the Stop button can be pressed. The scope shows in this
setting two interesting signals:
•
pink:
•
yellow:
gi_angle from the Startup Control block which is the given angle following the V/f ramp depending
on the slew rate.
gi_Flux_angle from the Flux Estimator block, which is the estimated (calculated) angle based on
the current measurement.
Example Fan:
After a few revolutions the estimated angle (yellow) and
the given angle (pink) are quite similar. The FOC takes
over at the speed threshold point.
DriveMonitor:
Speed ref
FOC_functions.h:
DELTA_ANGLE_START
Figure 29
Startup Behavior of a Fan Before Optimization
Application Note
35
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
Example Fan:
After optimization of
Vq_Offset and Vq_slew
the startup behavior is
much better (less ripples
on the estimated angle).
Figure 30
Startup Behavior of a Fan After Optimization
The point where the FOC takes over from the V/f control is of special interest. The V/f algorithm increases the
speed continuously until the threshold value is reached (Excel: Startup Speed Threshold, FOC_Functions.h:
DELTA_ANGLE_THRESHOLD). At this point the current and speed controllers cannot deliver the correct output as
they start here. The algorithm can only prepare the controllers accordingly.
Therefore the current controller’s integral part is preset with current amplitude (gi_V_q) based on the V/f
calculation, otherwise the amplitude would drop immediately. This is accomplished in Scheduler.c by pre-loading
gt_Iq_control.yn[0:1]:
case STATESTARTUP:
MotorStart();
#ifdef CLOSEDLOOP
if( (gi_delta_angle > 0? gi_delta_angle : -gi_delta_angle) > DELTA_ANGLE_THRESHOLD)
{
gb_closed_loop = 1;
//**************************************
//*
preload integral part of PI controller
//**************************************
gt_Iq_control.yn[0] = (gi_V_q>>8) & 0x00ff;
gt_Iq_control.yn[1] = (gi_V_q) & 0x00ff;
guc_Scheduler = STATEFOC;
}
#endif //CLOSEDLOOP
break;
The speed controller must adjust at runtime. Therefore it is advisable that the speed controller is started with an
input step; i.e. the difference between the DELTA_ANGLE_THRESHOLD and the DEFAULT_SPEED_STARTUP.
This can be accomplished by making the Startup Speed Threshold smaller than the Speed Ramp in the
Excel sheet.
In DriveMonitor, the value Speed Ramp can be adjusted by Speed_ref; i.e. the user can play with this value.
Application Note
36
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
reference speed
actual speed
Output of speed
controller:
Iq_reference
a)
Figure 31
b)
c)
Switching Point from V/f to FOC with Different Speed_ref Settings
In Figure 31 different threshold conditions can be observed:
a) Speed_ref = DELTA_ANGLE_THRESHOLD
b) Speed_ref >DELTA_ANGLE_THRESHOLD
c) Speed_ref >>DELTA_ANGLE_THRESHOLD.
4.4.3
Monitoring the Runtime Behavior
The Runtime behavior can be influenced by the PI parameter settings of the speed and controllers. The
DriveMonitor offers the window Setting 2 | Control, where the ki and kp parameters can be easily adjusted.
I_uvq can be used for monitoring the Scope Speed or Scope.
Pink: reference speed
green: actual speed
yellow: output of current
regulator (Iq_reference)
small Kp
Figure 32
large Kp
Speed Controller Adjustment, Reaction on a Reference Speed Step
Application Note
37
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
How to Use the Setup
4.4.4
Special Tricks - Field Weakening
The nominal speed of a motor is reached when the phase amplitude is at its maximum value under zero load. This
is because the BEMF (Back-Electro-Magnetic-Force) generated voltage increases with the speed and acts against
the phase voltage. Therefore the speed saturates. In the FOC algorithm there are two components:
•
•
The torque building current Iq
The field building current Id
The latter Id is controlled to zero because a PMSM motor generates the field by its magnet. This field component
can be easily controlled to a negative value which weakens the magnetic field. With this trick the motor must turn
faster than its nominal rated speed.
DriveMonitor allows the field weakening to be applied easily in the Setting 2 | Control. The third Group Entry shows
Id Ref. A negative value here will let the motor turn faster.
Other interesting observations that can be made in this mode are:
•
•
The overall current consumption will increase - watch the power supply current.
The torque will decrease in field weakening - this is obvious as the resulting stator flux vector is no longer
rectangular to the rotor flux vector.
Id = -100
Figure 33
Field Weakening: With Negative Field Building Component Id the Speed Increases Above the
Nominal Speed.
Application Note
38
V 1.0, 2009-04
+
-
Speed_reference
KP
0
1
y n m in
yn ma x
SpeedStartup
KP
y min
yma x
1
T
1
Ts
39
0
1
gi_V_q_vf_slew
gi_V_q_vf_offset
Id
gi_I_q
Iq
gi_I_d
ϕ
startup
gi_delta_angle
[: s2]
*K:2
0
0
1
1
Iα
gi_I_beta
Iβ
gi_I_alpha
t
ϕ + ∆ϕ ⇒ ϕ
gi_delta_angle_T0
DELTA_ANGLE_THRESHOLD
∆ϕ =
DeltaAngleT 0
SpeedUser
Threshold
n
∆ϕ ≥ threshold
Startup control
gi_Angle
gi_Flux_Angle
Park Transform
CLOSEDLOOP
0
1
∆ϕ
∆t
gi_angle
gi_angle_mem
ω=
Speed
Calculation
∆ϕ
gi_V_beta
16 ⋅ R
+
:2
:2
1
2 3
⋅ (2 I phaseB
F
1
T
K
Ts
K = Z1/Z2
T = 1/Z2
+
K ⋅L
T ⋅2
1
T
K
Ts
[s1]
+ I phaseA )
POT
Ch6
VDC
gi_I_phaseB
I phaseB
gi_I_phaseA
I phaseA
+
K ⋅L
T ⋅2
K = Z1/Z2
T = 1/Z2
gi2_Integrator_beta
+
-
PT1_32
gi2_Integrator_alpha[0:1]
+
-
A
D
E
C
B
S
N
Result3
Control
[: s0]
:4
Current
calc.
CORDY
[100]
RESULT 3
RESULT 2
RESULT 1
RESULT 0
T12 PR
T12
CC63 SR
T13 PR
T13
CC62 SR
CC61 SR
CC60 SR
 y ϕ
arctan 
x
y
x
gi_Flux_alpha
Modulator
Flux Estimation
PT1_32
C
[011]
*0.5
Clarke Transform
Iα = 12 ⋅ I phaseA
Iβ =
0
y ma x
gi_Amplitude
|V |
CORDZ
Θ
16 ⋅ R
vβ +
iβ
vα
iα
*K:4
[: s4]
Carthesian
to Polar
Transform
[: s3]
Vβ
gi_V_alpha
Vα
*K:4
Inverse
Park Transform
gb_closed_loop
gi_V_q
gi_V_d
V/f control
x
y Vq
0
1
1]
∆ϕ * slew * 256 + offset
+
-
PT1_24
+
gi_Speed
gc_Speed1
y
8
128
PI
gi_Speed
0
1
y n m in
yn ma x
F0
gt_Iq_control
x
1
s 2TI
0
y Vd
N
S
∆n
t
RampSlew =
∆t
guc_RampSlew
gi_Speed_startup
gi_Speed_reference_user
+
-
gi_Iq_reference
8
128
y min
yma x
S
N
SpeedRefUser
y min
y
0
1
+
N
n
+
yma x
KP
F0
gt_Id_control
x
N
S
Speed Ramp
8
128
PI
+
-
PI
[10
F0
gt_speed_control
x
1
s 2TI
gi_Id_reference
y n m in
1]
0]
[11
Application Note
]
[00
yn ma x
0
[01
S
Figure 34
S
CORDZ
ADC
cm
T PWM
CCU6E
TPWM
pm
t
t
CH0: POT
CH6:
CH1: VDC
CH7:
CH4
CH3
LS
Driver
HS
Driver
*G
+
Inverter
Rshunt
5
N
1
s 2TI
AP08090
Sensorless Field Oriented Control (FOC) on XC878
FOC Building Blocks Overview Drawing
FOC Building Blocks Overview Drawing
FOC Building Blocks
V 1.0, 2009-04
AP08090
Sensorless Field Oriented Control (FOC) on XC878
References
6
References
[1]
Application note - AP0807120_DriveMonitor
[2]
Application note - AP0808810_XC878DriveCard
[3]
Application note - AP9000110_LVinverter
[4]
Application note - AP1616010_DriveCard_XE164
[5]
Application note - AP0805910_Sensorless_FOC
[6]
Application note - AP16165_XE164_Sensorless_FOC
[7]
Link to XC878 Starter-kit CD download for getting started with XC800 toolchain - www.infineon.com/XC878
[8]
Link to free toolchain program - www.infineon.com/Freetools
[9]
Link to FOC Drive page - www.infineon.com/FOCDRIVE
Application Note
40
V 1.0, 2009-04
w w w . i n f i n e o n . c o m
Published by Infineon Technologies AG