XC2000 Sensorless Fieldoriented Control

XC2000 Family
AP16180
XC2000 Sensorless Fieldoriented Control
Application Note
V 1.0, 2010-09
Microcontrollers
Edition 2010-09
Published by
Infineon Technologies AG
81726 Munich, Germany
© 2010 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.
AP16180
XC2000 Sensorless Fieldoriented Control
XC2000
Revision History: V 1.0 2010-09
Previous Version(s):
Page
Subjects (major changes since last revision)
–
This is the first release …
Trademarks
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, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
1
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2
2.1
2.1.1
2.1.2
2.1.3
2.1.4
Theory of Sensorless Field Oriented Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
DC Motor Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Open Loop Voltage Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Closed Loop Torque Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Closed Loop Speed and Torque Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
List of Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Voltage Equation: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Induced Voltage: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Mechanical Friction: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Mechanical Equation: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Angle: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Speed in revolutions per minute (rpm): . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Space Vector Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Scaling: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Reference Vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Sampling Period Ts: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Volt-Second Balancing: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Phase Current Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Limitations of Phase Current Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
FOC Calculations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Stationary and Rotating Reference Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Clarke Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Park Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Inverse Park Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Summary Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Sensorless FOC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Flux of stator ψs: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Stator Voltage Equation: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2
2.2.1
2.3
2.3.1
2.4
2.4.1
2.4.2
3
3.1
3.2
3.2.1
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.3
3.4
3.5
3.6
3.6.1
3.6.2
3.6.3
3.6.4
3.7
3.8
3.8.1
3.8.2
Implementation of a Sensorless FOC using the XC2236N . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Software/Hardware Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scheduler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Statemachine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IDLE State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STOP State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Ramp-down State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Emergency Stop State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CAPCOM6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
CAPCOM2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Misc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
VDC and Poti . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Interrupt Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Variable Definition and Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
DAvE Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
System IC TLE7184F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Application States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Motor Ramp-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Running state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Application Note
1
15
17
18
18
19
21
21
21
22
22
23
24
25
25
25
25
25
26
27
27
28
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
3.8.3
3.9
Motor RAMP-down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
CPU Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4
4.1
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.6
4.1.7
4.1.8
4.1.9
4.1.10
Communication Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MultiCAN Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Program Flow XC2236N . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Receiving a CAN Message and Command Execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transmitting a CAN Message . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Command GET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Button Start, Stop, Ramp Down . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Scope Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Oscilloscope and Progress Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Status Flags and Display Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
29
29
29
30
30
30
30
31
32
32
32
33
5
5.1
5.2
5.2.1
5.2.2
5.2.3
Configuration and Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Excel Sheet and defines.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Drive Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Monitoring the Startup Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example Fan: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Example Fan: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Monitoring the Runtime Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
34
34
35
35
35
36
36
38
6
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Application Note
2
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Introduction
1
Introduction
The Field Oriented Control (FOC) method described in this document is aimed at the target market for cost
sensitive drives, such as fans, pumps, compressors and geared motors.
In automotive solutions the sensorless FOC is used as redundant substitution if the sensor driven system fails.
One other driving factor for a sensorless FOC on BLDC or PMSM is decreasing the system cost: sensors can
generate problems in manufacturing and reliability, 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. The FOC methode allows
to bring the efficiency up to 95%. This has a big impact on power consumption, motor dynamics, heat dissipation
and noise. As an example fans and pumps in a lot of applications must operate very silently, otherwise the
produced solid-borne sound distributes in water or air pipes within the whole environment.
Usually this leads to concepts with sinusoidal currents in the motor coils.
The limitation of the described methods is the single shunt current measurement which cannot guarantee a steady
control under all circumstances. Thus the method is not suitable for high dynamic loads and positioning systems.
Of course the algorithm can be adapted to 3-phase-shunt measurement which does not have this limitation.
Application Note
3
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
2
Theory of Sensorless Field Oriented Control
This chapter is intended to give an overview about the theory of the sensorless Field Oriented Control (FOC) of
permanent magnet syncronuous motors (PMSM). The control scheme which has been implemented at XC878 and
XE164 is based on this theory. The implementation details are described in Chapter 3.
Before describing the FOC theory in detail, we begin some background information on motor control.
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 1
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:
v–i⋅R
ω nom = ------------------Kc
(1)
m nom = K c ⋅ i
(2)
The time constants of speed and current control are very different. A control cascade structure for speed and
current control can be utilized.
2.1.1
Open Loop Voltage Control
In an open loop voltage control, there is just 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 2
V
Power
Stage
Open Loop Voltage Control
Application Note
4
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented 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 be done only by changing the reference Voltage (Vref)
of the power stage. Please see following figure for details:
DC Motor
Iref
+
-
eI
Current
Control
Vref
V
Power
Stage
I
mload
Iact
Current
Sensor
Figure 3
Closed Loop Torque Control
2.1.3
Closed Loop Speed and Torque Control
For a speed controlled DC motor, a cascaded control structure can be used, because the speed change
requirement is much slower than the one for the current. The speed control requires a speed sensor; e.g. 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
Control
Vref
Power
Stage
V
ω
I
mload
Iact
ω act
Figure 4
Current
Sensor
Speed
Sensor
Cascaded Speed and Current Control
Application Note
5
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
2.1.4
List of Equations
The mechanical and electrical equations of the DC motor are valid for the Permanent Magnet Synchronous Motor
(PMSM) as well. In the following, a set of equations is listed, which will be used later in this application note.
Voltage Equation:
di
+ R ⋅ i = v – v bemf
dt
(5)
v bemf = K c ⋅ Ψ ⋅ ω
(6)
m Friction = r Friction ⋅ ω
(7)
L⋅
Induced Voltage:
Mechanical Friction:
Mechanical Equation:
J⋅
dω
= m m – m Load – m Friction
dt
(8)
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. This type of 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 can be seen:
U
+
V
W
V
hs
VDC
U
ls
N -
Figure 5
W
Three Leg Voltage Source Inverter
By switching the high side and low side switches on and off, there are eight states possible, which do not cause
cross currents inside the leg itself, but allow a current flowing to and back from the motor.
Application Note
6
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
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. The space vector diagram of a U-V-W system contains six sectors (A, B, C, D, E, F).
N
S
S
N
0]
[1 1
0]
[01
N
C
[011]
D
B
[100]
F
E
N
S
S
N
1]
[0 0
[10
1]
N
S
Figure 6
S
A
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 6, 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.
In this case, 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
VU = vU ⋅ e
U
VV = vV ⋅ e
V = vU ⋅ e
W
j0
+ vV ⋅ e
vU = 2/3 VU
vV = 2/3 VV
vW = 2/3 VW
j0
j 2π
3
VW = vW ⋅ e
Figure 7
Scaling:
V = VU + VV + VW
j 4π
3
j 2π
3
The maximum length of the space vector is:
+ vW ⋅ e
j 4π
3
|V|max = VDC
Space Vectors in Complex Numbers
Application Note
7
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
2.2.1
Reference Vector
The reference vector Vref represents the resulting magnetic stator field (flux). It is defined by the following equation:
V ref = V ref ⋅ e
jϕ
(11)
It is rotating in space with the speed ω :
ω = 2π ⋅ f
(12)
The reference vector can be approximated by two active vectors (e.g. 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 8
V ref ⋅ T s = V 1 ⋅ T 1 + V 2 ⋅ T 2 + V 0 ⋅ T 0
Vref
A
γrel
F
(14)
[100]
T1
⋅ V1
Ts
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
π
T 1 = ------------------------------- sin  --- – γ rel
V DC
3
(15)
3 ⋅ T s ⋅ V ref
T 2 = ------------------------------- sin ( γ rel )
V DC
(16)
T0 = Ts – T1 – T2
(17)
The design of the switching sequence depends on the application requirements. Usually the number of switchings
is minimized, in order to reduce switching losses to a minimum.
The following figure shows a seven segment switching sequence:
TPWM
VU
t
VV
t
VW
Figure 9
[000]
[100]
[ 110]
[111]
[110]
[100]
[000]
T0/ 4
T1 /2
T2 /2
T0 /2
T2 /2
T1 /2
T0 /4
PWM Pattern of a Seven Segment Switching Sequence
Application Note
8
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
The output voltage of each leg to neutral is shown in Figure 10.
A
B
VU
[100]
Figure 10
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.
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 11
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)
Application Note
9
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
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 the phase
current as well. A very fast ADC is required in order to maximize the performance of phase current reconstruction.
The following figure shows the output voltage and phase voltage of a T1-T2-limited space vector modulation.
800
800
700
600
600
400
500
200
V_UN
400
V_UN - V_VN
V_VN
0
V_WN
300
V_VN - V_WN
0
60
120
180
240
300
V_WN - V_UN
-200
200
-400
100
-600
0
0
Figure 12
60
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 CPU load significantly.
Application Note
10
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
2.4
FOC Calculations
FOC is a method to generate a three phase sinusoidal signal, which can easily be controlled in frequency and
amplitude in order to minimize the current and therefore 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 contolled 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
IU
Iβ
B
C
IV
D
E
F
IW
Id
IW
Figure 13
Stationary and Rotating Reference Frames
The transform from the three phase system to the two phase system is called the Clarke transform. The one from
Two phase system to the rotating system is called the Park transform.
These transfroms are expressed in the following equations.
Clarke Transform
iα = iU
(18)
1
i β = ------- ⋅ ( i U + 2i V )
3
(19)
iU + iV + iW = 0
(20)
i d = i α cos ϕ + i β sin ϕ
(21)
i q = – i α sin ϕ + i β cos ϕ
(22)
Park Transform
Application Note
11
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
Inverse Park Transform
i α = i d cos ϕ – i q sin ϕ
(23)
i β = i d sin ϕ + i q cos ϕ
(24)
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 14
Summary of Transformations
Application Note
12
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
2.4.2
Sensorless FOC
The costs for an encoder or other position sensor can be saved, when the exact position of the rotor is not required.
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.
0
reference
speed
speed
+
PI-controller
-
ω
Id
+
-
Vd
inverse
Park
transform
PI-controller
Iq
PI-controller
+
-
Vq
ϕ
speed
calculation
Figure 15
Vβ
cartesian θ
to
|V|
polar
transform
PWM-Unit
U
Modulator
V
W
Two-level
Voltage Source
Inverter
(VSI)
with
integrated
deadtime
control
Flux
estimator
Id
Iq
Vα
Park
transform
Iα
Iβ
Clarke
transform
Current
Calculation
ADC
IDClink
shunt
Block Diagram of Sensorless Field Oriented Control
Figure 15 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.
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. The following figure shows the voltage equations of the motor in the α-β-system.
Flux of stator ψs:
β
ω
S
N
ϕ
i sα
Rs
α
(25)
ψ sβ = L ⋅ i sβ + ψ pβ = L ⋅ i sβ + ψ p sin ( ϕ )
(26)
Stator Voltage Equation:
Ls
v sα = R ⋅ i sα +
dψ sα
di sα
dϕ
= R ⋅ i sα + L ⋅
– ψ p sin ( ϕ )
dt
dt
dt
(27)
v sβ = R ⋅ i sβ +
dψ sβ
di sβ
dϕ
= R ⋅ i sβ + L ⋅
+ ψ p cos ( ϕ )
dt
dt
dt
(28)
-ψp ω sin(ϕ)
vsα
isβ
ψ sα = L ⋅ i sα + ψ pα = L ⋅ i sα + ψ p cos ( ϕ )
Rs
Ls
-ψp ω cos(ϕ )
vsβ
Figure 16
Voltage Equations of Ideal 2-phase Motor
The flux of the stator (Equation (25), Equation (26)) contain the mutual inductance
with the permanent magnet ψ p .
L ⋅ i s and the flux of the rotor
The stator voltage equations (Equation (27), Equation (28)) contains the resistance of the coil
derivative of the flux of the stator (Faraday’s Law).
R ⋅ i s and the
Application Note
V 1.0, 2010-09
13
AP16180
XC2000 Sensorless Fieldoriented Control
Theory of Sensorless Field Oriented Control
Integrating the voltage equations, we calculate the stator flux as follows:
ψ sα =
∫ ( vsα – R ⋅ isα ) dt
(29)
ψ sβ =
∫ ( vsβ – R ⋅ isβ ) dt
(30)
The flux of the rotor and hereby the orientation (angle ϕ) of the permanent magnet of the rotor is calculated by
insertion of Equation (29) in Equation (25) and Equation (30) in Equation (26).
ψ pα = ψ sα – L ⋅ i sα =
∫ ( vsα – R ⋅ isα ) dt – L ⋅ isα
(31)
ψ pβ = ψ sβ – L ⋅ i sβ =
∫ ( vsβ – R ⋅ isβ ) dt – L ⋅ isβ
(32)
ψ pβ
ϕ = atan  ---------
 ψ pα
(33)
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 derived from the algorithm, and the current is needs to be measured in real-time.
Application Note
14
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3
Implementation of a Sensorless FOC using the XC2236N
Field Oriented Control or vector control is a math technique for controlling brushless dc and ac induction motors
that reduces motor size, cost and power consumption and is a cousin of flux vector control.
This Chapter describes the implementation of a sensorless Field Oriented Control using the Infineon XC2236N
microcontroller. The XC2236N microcontroller is a new 64-pin device, part of the XC2000 family. Based on the
enhanced C166S V2 architecture, it outperforms existing 16-bit solutions.
The 3 PWM units, several timer and two very fast and powerful ADC’s make the XC2236N a perfect fit for a variety
of motor control applications.
PSRAM
16 KB
DPRAM
2KB
OCDS
Debug Support
DSRAM
16KB
SCU:
Voltage,
Reset,
EBC
PMU
MAC
DMU
Flash
64 KB
XBUS Control
External Bus
Control
CPU
MPU
Flash
256 KB
C 166 SV2 - Core
XTAL
Osc / PLL
Clock
Generation
RTC
WDT
Interrupt
& PEC
MCHK
Interrupt Bus
Peripheral Data Bus
LX BUS
8/10 – Bit
2
Channels
GPT
CC 60
CC 61
T7
T2
T12
T12
T8
T3
T13
T13
USIC 0
64 entry
buffer
RS232,
SPI, LIN,
I²C, I²S,
RS232,
SPI, LIN,
I²C, I²S,
Channel
0
T4
USIC 1
64 entry
buffer
T5
T6
Channel
1
8/10 – Bit
7
Channels
CC 2
Channel
1
ADC 1
Channel
0
ADC 0
MULTI
CAN
1 Channels
GPIO Ports
Figure 17
Block Diagram XC2236N
This application note makes reference to Infineon's FOC Drive Application Kit (ordering code:
KIT_AK_TLE71184_V1). This kit comes with the following hardware:
•
•
•
•
•
•
DriveCard XC886
DriveCard XC2236N
Low Voltage Inverter TLE 7184F (12V...24V, 20A)
PMSM motor (15W)
DriveMonitor USB stick
Power supply (12V)
Figure 18
FOC Drive Application Kit
Application Note
15
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
The sections which follow describe the FOC implementation on the 16-bit device XC2236N. The project setup is
available for the Tasking Vx Tool chain.The project is DAvE compliant; i.e. the peripheral settings can be changed
or added using DAvE code generator and recompiled afterwards.
A MicroSoft Excel sheet can be used for scaling and motor parameter adaptation. The Excel sheet generates the
contents for a header file.
The DriveMonitor is used for real-time monitoring of those application variables that are of interest. The
DriveMonitor also offers a control interface to the application. The CAN bus is used for exchanging of data.
Note: The descriptions in the sections which follow are intended for the advanced user; i.e. some basic knowledge
of the Infineon tool-chain is a prerequisite. Several application notes are available to aid understanding (see
Chapter 6), and 'hands-on' training is also offered. Less advanced users are recommended to begin with
the DaveDrive auto-code generator.
Application Note
16
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.1
System Overview
The Field Oriented Control Application Software uses the Drive Card XC2236N.
LV inverter
Drive Card
GPT12
T6
CAPCOM2
of
T7
of
of
CCU60
of
of
pm
pm
T12PR
t
M0 Ramp
t
Scheduler
+
TPWM
T12
T7PR
T6PR
Inverter
CC60SR
HS Driver
CC61SR
CC62SR
t
T5
of
of
of
of
of
LS Driver
of
T13
T5PR
pm
pm
T13PR
t
CAN Oscilloscope
t
XC2236N
MultiCAN
ADC0
ResReg0
CH8
Node0
Rshunt
*G
MO0
ResReg1
MO1
MO2
MO3
MO4
CH15: VDC
ResReg7
CH13: POT
ResReg6
System Block
0
+
ymax
y
ymin
+
-
x
ymax
KP
*64
ymin
+
ymax
y Vq
D
B
E
0]
HS Driver
S
A
[100]
F
CC61SR
~3 phase
motor
CC62SR
N
t
T13
LS Driver
C
pm
pm
T13PR
svm.Amplitude
t
foc.Vq
y
1
Ts
+
-
Speed
Calculation
x
=
1
T
Flux Estimation
i
R
+
v
n
+
-
0
foc.Fluxalpha
x x
 y
arctan 
 x
K = Z1/Z2
T = 1/Z2
y
foc.IntegratorA
status.
control
foc.FluxAngle
i
x
Startup control
R
≥ threshold
+
v
⇒
0
control.
ControlSwitch
+
K
Ts
1
T
1
foc.Angle
K⋅L
T
PT1
Speed
1
Carthesian
to Polar
Transform
t
foc.Angle
foc.AngleStore
control.Filter
SpeedUser
t
n
Slew =
t
control.ReferenceSpeedT0
control.SpeedRampTime
control.ReferenceSpeedUser
S
N
ymax
0
foc.Vbeta
0
PT1
Speed Ramp
|V
V
1
ymin
control.Iq
control.
ActualSpeed
C
[011]
]
control.Speed
1
sTI
:1
[: s4]
1
[10
*64
control.
ReferenceIq
+
pm
CC60SR
:4
[: s3]
N
KP
PI
ymin
pm
S
x
ymax
Inverter
TPWM
T12PR
foc.Vd
S
+
-
1
sTI
svm.Angle
N
control.
ReferenceSpeed
foc.Valpha
CCU6E
T12
0
control.Id
PI
Modulator
N
1
ymin
*64
Carthesian to
Polar
Transform
V
[00
1]
KP
y Vd
S
+
ymax
S
ymin
[11
Inverse
Park Transform
ymax
1
sTI
0]
+
-
x
[01
PI
control.
ReferenceId
N
Figure 19
DELTA_ANGLE_START
foc.AngleSpeed
K⋅L
T
PT1
+
-
+
K
Ts
y
foc.Fluxbeta
1
T
V/f control
x + y2
2
y
|V|
foc.FluxAmplitude
K = Z1/Z2
T = 1/Z2
foc.IntegratorB
* slew * 256 + offset
gi_V_q_vf_slew ???
gi_V_q_vf_offset ??
Id
Park Transform
foc.Id
I
foc.Ialpha
Clarke Transform
Iα = 12 ⋅ I phaseA
:1
Iq
foc.Iq
[: s2]
I
Iβ =
1
2 3
*16
[* s1]
⋅ (2 I phaseB + I phaseA )
IphaseA
svm.IphaseA
Current
calc.
RESULT0
IphaseB
[: s0]
ADC0
CH8
:4
*G
Rshunt
RESULT1
svm.IphaseB
foc.Ibeta
handled in the ADC Interrupts (ADC.c)
Figure 20
RESULT6
CH15: VDC
RESULT7
CH13: POT
XC2000 Sensorless FOC Block Diagram
Application Note
17
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.2
Software/Hardware Components
The implemetation of the FOC is interrupt driven. Most of all calculations are realized in the interrupt routines of
the CAPCOM6 and the ADC0.
ADC0:
–
–
–
–
Initialization
ADC result register control
current calculation and phase current extraction
clark transformation
CAPCOM2:
– Initialization
– Bootstrap for TLE 7184F
– Ramp-up time V/f for motor
CAPCOM6:
–
–
–
–
–
–
–
–
Initialization
flux estimation
park transformation
speed calculation and speed control
current control
inverse park transformation
cartesian to polar transformation
space vector modulation
GPT12:
– Initialization
– Generation of time base for oscilloscope data, scheduler
CAN:
– Interface for motor communication
The modulator and the DSP routines for the FOC routines are optimized for the MAC unit.
Modulator.c:
– Space Vector Modulation
Subroutines_FOC.c, Subroutines_FOC.h:
–
–
–
–
Several DSP routines
PI/PT1 routines
FLUX estimation
(Inverse) Clarke/Park transformation
Scheduler.c
– Scheduler
3.2.1
Scheduler
The program flow of the target microcontroller is an embedded realtime code which runs in several interrupt
service routines. There is GPT Timer 6 providing a system tick of 1ms which calls a scheduler. The scheduler
statemachine controls the application and reacts on host commands.
The Timer 5 of the GPT module send the Oscilloscope data every 0.5 millisecond via an interrupt. One message
object is used to send the complete data. The structure is shown in Chapter 4.1.9. The Timer 5 interrupt uses the
lowest priority in the system. The transfer rate of the data can be adapted to the application needs.
Application Note
18
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
The GPT Timer 6 is configured as a Timer and generates a interrupt every millisecond, which executes the
scheduler. The scheduler can be divided into a CAN handler and a statemachine part which handles the whole
FOC application Software. For the FOC implementation a statemachines for Motor 0 is integrated. The scheduler
handles the CAN commands and switches or reset's Statemachine states. Some Statemachine states are
triggered from the CAN handler part of the Scheduler, while some are triggered/switched by other events or
mechanisms. Figure 21 show the structure of the scheduler. The Figure 22 show the Statemachine for a single
Motor application.
After handling a new CAN command, information is sent to the drive monitor, such as the motor states and some
control values such as Vdc, the temperature on the inverter.
Scheduler Start
no
New Command?
yes
Handle Command
Handle State M0
Send parameter
Scheduler End
Figure 21
Scheduler Sensorless FOC
3.2.2
Statemachine
The FOC Software handles 8 different states for the Motor in a seperate global 16 bit word (STATE_M0). The
dedicated states are listed for Motor 0 in the register view below.
STATE_M0
Short Description
Reset value: 0001H
15
14
13
12
11
10
9
8
7
6
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
5
4
3
2
1
0
M0 States
-
rw
rw
rw
rw
rw
The bits of the variable are described in a table that follows.
Application Note
19
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
Field
Bits
Type Description
M0 States
[0:3]
rw
Statemachine States
0001 STATEIDLE_M0(Default)
0010 STATESTARTUP_M0
0011 STATESTOP_M0
0100 STATEFOC_M0
0101 STATERAMPDN_M0
0101 STATEEMCY_M0
0111 STATEBOOTST_M0
1000 STATEPOTI_M0
...
...
Note: Some states are triggered by the Drive Monitor, while other
states are entered automatically and can not be influenced by
the Communication Software.
Power up
ÆMain init
Poti:
Waits for a Poti
value < 10 before
start the motor
POTI
Off
On
closed_loop
Trap
CPU
Trap
EMERGENCYSTOP:
MotorStop();
IDLE
EMCY
CTRAP:
Off
On
closed_loop
Trap
low level at
pin CTRAP
Off
On
closed _loop
Trap
Start
BOOTST
Off
On
closed_loop
Trap
Stop
Bootstrap:
Switch on low sides
wait n loops
Power up
STOP:
MotorStop();
disable T12_INT
disable TRAP_INT
STOP
STARTUP
Off
On
closed_ loop
Trap
Stop
Off
On
closed_loop
Trap
STARTUP:
enable T12_INT
MotorStart();
enable TRAP_INT
∆ϕ > threshold
reference _speed < threshold
RAMPDOWN:
reference_speed_user
= threshold;
Stop
Stop
RAMPDN
FOC
Off
On
closed_ loop
Trap
Ramp Down
Off
On
closed_loop
Trap
S chedulerS tateMachine_2009-04-09.emf
Figure 22
Statemachine for Single Motor FOC
On power-up the Statemachine normally enters the IDLE state. In IDLE state the Motor is stopped by Software
and the CCU6 interrupts are disabled. To start the Motor, the BOOTST state is entered. BOOTST can also be
entered directly after power-up, instead of IDLE. Whether IDLE or BOOTST mode is entered on power-up is
defined by the DEFAULT_STATE setting in the define.h file.
#define DEFAULT_STATE
STATEBOOTST_M0
In the Bootstrap state the low side MOASFETs will be switched on for the dedicated number of the ramp-up timer
interrupts.
Application Note
20
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
#define BOOTSTRAP_M0
2
After this the STARTUP state is entered, which means the Motor will start to ramp-up. The FOC state is entered
after a selected speed of the Motor when the sensor less FOC algorithm starts to handle the Motor. A CTRAP can
cause an Emergency Stop as well a CPU TRAP. For more information about the Emergency handling refer to
Chapter 3.2.6.
3.2.3
IDLE State
IDLE is the default state entered on system power-up. In this state the CPU waits for new commands and for a
trigger to start the motor. Status flags will be reset and the values for the CAPCOM2 ramp timer 7 can be
configured. To change the timer value, DAvE generated functions are used.
case STATEIDLE_M0:
status0.on = 0;
status0.control = 0;
status0.off = 1;
CC2_vStopTmr(CC2_TIMER_7);
CC2_vLoadTmr(CC2_TIMER_7,control0.SpeedRampSlew);
CC2_T7REL = control0.SpeedRampSlew;
CC2_vStartTmr(CC2_TIMER_7);
break;
3.2.4
STOP State
The STOP state can be entered with a command from the DriveMonitor, or after the ramp-down state is finished.
The STOP function disables the ENABLE signal for the driver IC, and also sets the status flags and FOC variables
to their defaults. The CAPCOM60 Timer 12 is stopped and the interrupt nodes for Timer 12 and the Emergency
interrup are disabled.
3.2.5
Ramp-down State
The Ramp-down state can be entered by a command direct from the DriveMonitor. The user reference speed is
set to the REFSPEED_STARTUP_M0. Once the reference speed matches the user reference speed, the state
machine automatically enters the STOP state.
The following shows a code extract from the scheduler function:
case STATERAMPDN_M0:
//This ramps down the Motor 0 -> the switch to idle will be
done on the CCU2 T7 interrupt
status0.on = 0;
control0.ReferenceSpeedUser = REFSPEED_STARTUP_M0;
break;
Application Note
21
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.2.6
Emergency Stop State
The Emergency State can be entered from two different event triggers:
– CCU60/CTRAP - this switches off the power devices if the trap input becomes active.
– CPU TRAPS - Trap functions are activated in response to special conditions that occur during the execution
of instructions.
Motor enable = OFF
Emergency STOP
CPU TRAP
Figure 23
CCU60 CTRAP
Emergency Stop
There are nine hardware trap functions for the XC2236N divided into 2 classes. Class A traps are:
–
–
–
–
System Request 0 (SR0)
Stack Overflow
Stack Underflow trap
Software Break.
The second Class B traps are:
–
–
–
–
–
System Request 1 (SR1)
Undefined Opcode
Memory Access Error
Protection Fault
Illegal Word Operand Access.
All this TRAP call the same Emergency_Stop_M0() function.
An Emergency State can only be left with a STOP command from the Drive Monitor.
3.3
CAPCOM6
The PWM is generated with the CCU60 timer unit. Both timers T12 and T13 are used. T12 generates the signals
for the Space Vector Modulation (SVM). T13 generates the trigger events for the ADC0. T13 runs in single shot
mode and starts automatically on one defined compare match of one of the 3 compare channels. The generated
trigger starts the conversion of the ADC0 channel which generates an interrupt after the channel is converted.
Details of the ADC0 handling can be found in Chapter 3.4.
The passive level selection of the CCU60 compare output signals fits to the Infineon system IC TLE7184F, see
Chapter 3.7. To avoid spikes and dangerous transitions at startup the CCU60 has a special feature which is used
for the initialization and for the Start/Stop/Emergency states. Therefore the CCU60’s trap state is forced by
software. This is done at the very beginning of CC6_vInit() by setting the flag TRPF (note: DAvE does not set this
flag). By this it is ensured that the output signals always show the defined passive level during initialization until
the flag TRPF is cleared.
There are two application specific constants which have to be defined before compilation in defines.h. They will
be initialized accordingly:
Application Note
22
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
T12PERIODE_M0
DEADTIME_M0
The T12 period needs to be setup according to the PWM frequency. The deadtime counter needs to be setup
according to the Hardware setup. DAvE settings will be overwritten in this instance.
The FOC algorithm can be explained by Figure 20. The shown building blocks are exactly implemented, mainly
in the file Subroutines_FOC.c and Subroutines_FOC.h for inline functions. The FOC calculation is divided into two
parts. The first part is located in the ADC0 Result event interrupt and executes the following calculations:
– ADC result register control
– current calculation and phase current extraction
– clark transformation
The second, larger part is located in the CCU6 Timer 12 period match of the Interrupt Service Routine, and
executes the following calculations:
–
–
–
–
–
–
–
flux estimation
park transformation
speed calculation and speed control
current control
inverse park transformation
cartesian to polar transformation
space vector modulation
The Timer 12 one match of the Interrupt Service triggers the shadow transfer for the compare channels.
3.4
ADC
The current implementation uses several channels of the ADC0. Nevertheless a customer specific setup of the
free and used ADC channels can be easily created within the DAvE project.
CAPCOM60
Motor 0
ADC0
ResReg0
CH8
*G
Rshunt
ResReg1
ResReg7
ResReg6
Figure 24
CH15: VDC
CH13: POT
ADC0 Structure for Single Motor FOC
The sensorless Field Oriented Control works with a single Shunt measurement. It is possible to economize one
current sensor when the current measurement is not performed in the phases but in the dc-link. To effect this
phase current acquisition through the dc link current it is necessary to know the actual switching pattern.
In this way, during one PWM, two times, two different phase currents can be measured through a dc-link current
measurement. The third phase current can be calculated by the equation iU+iV+iW=0. (see Chapter 2.3 for
details).
In order to get a maximum time between the current conversions with the ADC, the measurement will be started
on the edge of the phase with the middle “on time” (Figure 25).
Application Note
23
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
TPWM
T12
T12PR
CC60SR
CC61SR
CC62SR
T13
hardware
start
T13PM
hardware
start
T13PM
T13PR
IDClink
Event (ADC0_INT0):
Event (ADC0_INT1):
Result Event 0
Result Event 1
Assign Result Register for
DC Link channel
T12 count down -> Result
Register 1 selected
Calculate new T 13 values
T13 Shadow transfer
enable
Assign Result Register for
DC Link channel
Result Register 0 selected
Figure 25
ADC Measurement
3.5
CAPCOM2
Calculate new T 13 values
T13 Shadow transfer
enable
Calculate currents Ialpha
and Ibeta
Calculate currents Id and Iq
The CAPCOM2 Timer 7 is base for all ramp-up and ramp-down functions of the sensorless FOC software. The
speed ramp is dependent on three Excel parameters in the define.h file.
REF_RAMPUP_T7_M0
T7_PRESCALER
RAMP_STEP_M0
The REF_RAMPUP_T7_M0 defines the Timer ticks and T7_PRESCALER selects a pre scaler for Timer 7. The
Ramp Step is also defined. This influences the slope of the ramp behaviour.
The Timer 7 interrupt handles the following functions:
–
–
–
–
–
Bootstrapping time
Ramp-up in V/f
Ramp-up in closed loop FOC
Ramp in case of user reference speed changes during run time
Ramp-down in closed loop FOC
Application Note
24
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.6
Misc
3.6.1
VDC and Poti
VDC and the Poti are connected to ADC0 CH13 and ADC0 CH15. Both channels will be converted with the parallel
source which is basically a channel scan. The conversion request tigger is set in software in the GPT Timer 6
interrupt. Both results are stored into global variables.
If the #define SPEED_POTI is set in the defines.h file, the poti on the XC2236N Drive Card will be used to control
the speed of the Motor. The control function is located in the scheduler.
3.6.2
Interrupt Level
The XC2236N provides 96 separate interrupt nodes assignable to 16 priority levels, with 8 sub-levels (group
priority) on each level.
The used interrupt level in this project are selected carefully. With the help of DAvE these levels can be adapted
to application needs in case new peripherals like a USIC channel is added into the project.
Figure 26
Interrupt Setup
3.6.3
Variable Definition and Administration
The variables used for the FOC algorithm and control of the whole software are separated into 4 structs located
in the Controls_FOC.h file. These structs are:
–
–
–
–
tSVM svm0;
tFOC foc0;
tStatus status0;
tControl control0;
Each struct has associated variables. These structs are preloaded in the Main.c file variable declaration with the
define values coming from the define.h file. These variables can be changed and monitored as required, via the
DriveMonitor.
3.6.4
DAvE Support
The project is based on DAvE with the DIP file for XC22xxN_Series V0.2. Setting changes can be made there,
such as the GPT timer values to change the scheduler frequency for example, as well as adding new peripherals
such as a USIC for example.
Application Note
25
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.7
System IC TLE7184F
The TLE7184 is a system IC for Brushless Motor Control. It incorporates a voltage supply for a µC, a bridge driver
for a B6 configuration, an application typical PWM interface and some other smaller features. Target is to reduce
the number of discrete components in typical BLDC automotive applications and give enough flexibility for custom
specific adaptations.
The TLE7184F can be reset by the enable pin RGS. If the RGS pin is pulled to low for a specified minimum time
(min. 3µs / max < 20µs) the error registers are cleared. If the error is still existing when the RGS pin is pulled to
low, no reset will be performed and the ERR pin stays low.
Figure 27
Enable / Disable Timing
A MOSFET is a voltage controlled device which, in theory, will not have any gate current. This makes it possible
to utilize the charge inside the capacitor for control purposes. However, eventually the capacitor will lose its charge
(due to parasitic gate current), so this scheme is only used where there is a steady pulse present. This is because
the pulsing action allows for the capacitor to discharge (at least partially if not completely). Most control schemes
that use a bootstrap capacitor force the high side driver (N-MOSFET) off for a minimum time to allow for the
capacitor to refill. This means that the duty cycle will always need to be less than 100% to accommodate for the
parasitic discharge unless the leakage is accommodated for in another manner.
The TLE184F provides a bootstrap based supply for its high side output stages. The benefit of this principle is a
fast switching off the high side switches - supporting active freewheeling in high side. The bootstrap capacitors are
charged by switching on the external low side MOSFETs connecting the bootstrap capacitor to GND. Under this
condition the bootstrap capacitor will be charged from the VREG capacitor. If the low side MOSFET is switched
off and the high side MOSFET is switched on, the bootstrap capacitor will float together with the SHx voltage to
the supply voltage of the bridge. Under this condition the supply current of the high side output stage will discharge
the bootstrap capacitor. This current is specified. The size of the capacitor together with this current will determine
how long the high side MOSFET can be kept on without recharging the bootstrap capacitor.
When all external MOSFETs are switched off, the SHx voltage can be undefined. Under this condition, the
bootstrap capacitors can be discharged, dependent on the SHx voltage.
Application Note
26
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.8
Application States
The startup mechanism to turn the motor can be divided into two parts. First the Motor will start to turn by a V/f to
a dedicated user defined speed. From this point on the Field Oriented Control will handle the Motor.
3.8.1
Motor Ramp-up
Motor
rpm
Startup control
REFSPEEDUSER_
STARTUP_M0
∆ϕ ≥ threshold
ϕ + ∆ϕ ⇒ ϕ
n
Threshold
ANGLESPEED_THRE
SHOLD_M0
SpeedT 0
status . 1
control 0
∆ϕ =
t
t
foc.AngleSpeed
foc.AngleSpeedT0
foc.AngleSpeedThreshold
Bootstrap
Figure 28
V/f
Time in CCU2
T7 overruns
FOC
Motor Ramp-Up
A #define in the define.h file is used to switch selection between the V/f control and FOC.
#define CONTROL_SWITCH_M0
1 // Motor switches to FOC mode
If this control switch is set to 0 the motor ramps-up to the angle speed threshold in the V/f control. The motor will
run with that speed without switching to the FOC algorithm. This method can be use to check the calculated angle
of the motor with the angle used in the V/f control.
#define CONTROL_SWITCH_M0
3.8.2
0 // Motor stays in V/f control mode
Running state
After the motor ramps up to the defined threshold speed, the user can change the User reference speed with the
DriveMonitor. In case the #define SPEED_POTI is active in the define.h file, the Poti of the DriveCard is used to
change the speed of the Motor.
3.8.3
Motor RAMP-down
After the scheduler receives the command for ramp-down (Chapter 3.2.5) , the reference speed will be rampeddown to the REFSPEED_STARTUP_M0. Once the speed ramp-down is complete, the scheduler state is
automatically changed to the STOP state.
The following shows a code extract from the CAMCOM2 Timer 7 interrupt function:
//********************************************************************************
// controlling the speed of the Motor 0 if switched to control mode
//********************************************************************************
if (STATE_M0 == STATERAMPDN_M0)
{
if(control0.ReferenceSpeedUser > control0.ReferenceSpeed) control0.ReferenceSpeed += RAMP_STEP_M0;
if(control0.ReferenceSpeedUser < control0.ReferenceSpeed) control0.ReferenceSpeed -= RAMP_STEP_M0;
if(control0.ReferenceSpeedUser == control0.ReferenceSpeed)
{
STATE_M0 = STATESTOP_M0;
}
}
Application Note
27
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Implementation of a Sensorless FOC using the XC2236N
3.9
CPU Load
Figure 30 shows the cpu load of the complete application. Basically the cpu load is generated by the interrupt
routines of CAPCOM6 and ADC0. The cpu load is represented by the channel 3.
The observer window starts with the timer 12 period match (T12PM)
Interrupt Interrupt Interrupt
CCU6
CCU6
ADC
CPU Load
T12PM
Interrupt
ADC
T12OM
Output CC60
Output CC61
Output CC62
Figure 29
CPU Load
Application Note
28
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Communication Interface
4
Communication Interface
Communication is via the Drive Monitor Software for the PC and the Drive Monitor USB Stick. Download to the
XC2236N is via the JTAG connection. Motor communication, such as Start and Stop commands, is via MultiCAN.
The XC2236N uses the MultiCAN Node 0 running at 500kBaud, together with several Message objects, for this
communication.
For more information about the Drive Monitor please refer to the AppNote: Drive Monitor, Hardware Description
(ap0807120_DriveMonitor.pdf).[1]
4.1
MultiCAN Interface
In the current Implementation, five CAN Message objects are used.
Message Object 10 is configured as the receive object, forwarding commands from the Drive Monitor Software via
a CAN receive interrupt, to the Scheduler. CAN message objects MO1 through to MO4 are used for data transfer
from the XC2236N to the Drive Monitor Software.
4.1.1
Program Flow XC2236N
The CAN controller is configured to three interrupt vectors for receive, transmit and error handling. The CAN
Message Objects have following IDs:
–
–
–
–
–
ID5 - receive object - MO 10: SET/GET command and Buttons
ID55- receive object - MO 2; unused
ID7 - transmit object - MO1; slow data for status flags and display field
ID77- transmit object - MO 3; fast data for oscilloscope and progress bar
ID57- transmit object - MO 4; responds to GET command
RESET
CAN – REC
ID 5
Initialize
Application
copy message
to buffers
CANRxdBuf0
MAIN
Scheduler
send
CAN messages
reti
CAN– TRX
ID 7 / ID 77 / ID57
clear message
pending flags of
sent objects
reti
GPT T6
every 1ms
CTRAP
interrupt
Scheduler
ADC Poti VDC
set emergency
state
switch states upon
command exec.
ret
Figure 30
ADC
GPT T6
Handels ADC
results
Send Oszi Data
reti
reti
CCU60 T12
interrupt
CCU2 T7
interrupt
CC6 Shadow
Transfers
Speed Ramp
Speed Control
FOC_Calculation
reti
reti
reti
reti
Program Flow
Application Note
29
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Communication Interface
4.1.2
Command Structure
The command structure is as per the document ap0807120_DriveMonitor.pdf.[1]
D0
D1
D2
D3
D4
D5
D6
D7
CAN ID
0
0
0
CMD
5
commands from DriveMonitor to target
adrL
adrH
valL
valH
4.1.3
Receiving a CAN Message and Command Execution
On receipt of a CAN message object (M0 10 with ID5) the receive interrupt is vectorized. The interrupt service
routine scopes the received data into a global array named CANRxdBuf0.
The following shows a code extract of the CAN Receive interrupt service routine:
// The CAN controller has stored a new message into this object.
// USER CODE BEGIN (SRN0_OBJ10,4)
CANRxdBuf0[0]= CAN_MODATA10LL;
CANRxdBuf0[1]= CAN_MODATA10LH;
CANRxdBuf0[2]= CAN_MODATA10HL;
CANRxdBuf0[3]= CAN_MODATA10HH;
// USER CODE END
At every system timer tick the scheduler statemachine is executed. If a new command is received, the
corresponding command is executed and the CANRxdBuf0 is cleared. The CAN receive interrupt and the GPT
Timer 6 for scheduler use the same interrupt level. This mechanism ensures that an incoming command has to
be served first before a new command is accepted.
4.1.4
Transmitting a CAN Message
There are three transmit message objects configured for sending data from the target to the host. The transmit
messages have to be initialized. The transmit buffers CANTrxBuf0/1 are used to load the data to the message
objects. The load, release and transmit request functions are generated functions from DAvE.
The following show a example code of the transmit function for message object 3:
_inline void CAN_Transmit_MO3(void)
{
// MO3 is shown in Oscilloscope
CAN_vLoadData(3, (ubyte*) CANTrxBuf1 );
CAN_vReleaseObj(3);
CAN_vTransmit(3);
}
4.1.5
Command SET
With the SET command any variable of the FOC structs can be updated. Therefore it is necessary to have the
address information of the respective variables. Address and data information are read from the CANRxdBuf0 and
the contents of the address is written with the new value.
The following shows a code extract of the scheduler function:
Application Note
30
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Communication Interface
case CMDSET:
//
//
//
//
D0
D1
D2
byte #
0
1
2
3
4
5
6
7
CMD byte adrL adrH valL valH xxxx xxxx cmdL cmdH
CMD int adr
val
x
CMDSET
int #
0
1
2
3
adr = (unsigned int*) CANRxdBuf0[0];
value = CANRxdBuf0[1];
*adr = value;
// dont change state
break;
D3
D4
D5
D6
D7
CAN ID
0
0
cmdL
cmdH
5
commands from DriveMonitor to target
adrL
adrH
valL
4.1.6
Command GET
valH
With the GET command the host can read the contents of any variable. The host has to send the address
information first before the target responds with the data on transmit message object MO 4.
The following shows a code extract of the scheduler function:
case CMDGET:
//
//
//
//
byte #
0
1
2
3
4
5
6
7
CMD byte adrL adrH xxxx xxxx xxxx xxxx cmdL cmdH
CMD int adr
xxx
xxx
CMDGET
int #
0
1
2
3
adr = (unsigned int*) CANRxdBuf0[0];
// Transmit MO 4 on request
tmp[0] = (unsigned int) adr;
tmp[1] = *adr;
CAN_vLoadData(4, (ubyte*) tmp );
CAN_vReleaseObj(4);
CAN_vTransmit(4);
// dont change state
break;
D0
D1
D2
D3
D4
D5
D6
D7
CAN ID
0
0
0
cmdL
cmdH
5
from DriveMonitor to target
adrL
adrH
Application Note
0
31
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Communication Interface
4.1.7
Button Start, Stop, Ramp Down
On pressing the Start, Stop or Ramp Down buttons, the scheduler state variable is updated and will be entered.
D0
D1
D2
D3
D4
D5
D6
D7
CAN ID
0
0
0
cmdL
cmdH
5
from DriveMonitor to target
0
0
0
4.1.8
Scope Buttons
Realtime monitoring of fast changing data is one of the key features of the DriveMonitor. Therefore the CAN
message object MO 3 - ID 77 is sent with every GPT timer 5 tick to the host. With this message three 16bit values
can be monitored on the three beams of the virtual scope. With the scope buttons the addresses of the three
monitoring variables can be changed.
The following shows a code extract of the scheduler function:
case CMDSETBEAMS:
//Button Values: SCOPEgreen | SCOPEpink | SCOPEyellow | CMDSETSCOPE:
ScopePointer[0] = CANRxdBuf0[0];
ScopePointer[1] = CANRxdBuf0[1];
ScopePointer[2] = CANRxdBuf0[2];
break;
4.1.9
Oscilloscope and Progress Bar
With every GPT Timer 5 over flow the data for the soft oscilloscope and the progress bar are sent to the host.
These data have the highest transmit rate. The user has to ensure that the realtime conditions are met. This can
be tuned with the GPT timer 5 overflow rate. The fast data use ID77 with MO 3.
D0
D1
D2
D3
D4
D5
D6
D7
CAN ID
pinkH
yellowL
yellowH
0
0
5
from DriveMonitor to target
greenL
greenH
Application Note
pinkL
32
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Communication Interface
Figure 31
Drive Monitor Oscilloscope
4.1.10
Status Flags and Display Fields
For slower changing data, it is sufficient to send the data over a greater number of timer ticks. Such data would
be the status flags and display fields for example. The transmit rate is defined by a variable which counts a defined
number of system timer ticks. The slow data use ID7 with MO 1.
The following shows a code extract scheduler function:
//send parameter via CAN
if (++CANMO1Count == 50)
{
CANTrxBuf0[0] = (unsigned int)status0.off |
((unsigned int)(status0.on)<<1) |
((unsigned int)(status0.control)<<2) |
((unsigned int)(status0.ramp)<<3) |
((unsigned int)(status0.ctrap)<<4) ;
CANTrxBuf0[1] = svm0.Amplitude;
CANTrxBuf0[2] = control0.ActualSpeed;
CANTrxBuf0[3] = ADC_VDC;
//VDC
CAN_Transmit_MO1();
CANMO1Count=0;
}
Application Note
33
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Configuration and Monitoring
5
Configuration and Monitoring
5.1
Excel Sheet and defines.h
Parameterization of the application is done via the header file defines.h. An Excel sheet (see Figure 33) is used
to generate this files contents. The algorithm itself is left untouched.
The Excel sheet has two pages: the input page Input Parameter and the output page defines.h.
The Input Parameters can be filled into the yellow marked fields. These are the most relevant parameters. The
structure is as follows:
•
•
•
•
•
•
•
•
Motor Parameter - this is the resistance and inductance of the motor windings. The input value refers to one
phase, i.e. phase-to-neutral and not phase-to-phase.
Startup Parameter - these are the values which are used in the startup block.
Inverter Parameter - in case customized inverter is used, it can be adapted here.
Current Measurement - in case the current amplification or the shunt is changed it has to be changed here.
Speed and Current Controller - here the integral and proportional factor for the PI-controllers can be adjusted.
Flux Integration Scaling - here the PT1 filter for the flux estimator can be adjusted.
Speed Filter - here the PT1 filter for the speed filter can be adjusted
Speed Ramp - here the speed ramp time can be adjusted. In case the Speed Ramp time in the startup
parameters is not fast enough, the incremental steps can be increased.
The parameters influence each other, e.g. a very low inductance value L will scale to a very low value L’ which is
used for the flux estimator. In this case the input parameter K in the Flux Integrator Scaling should be increased.
If the Excel sheet shows red marked cells the scaling paramaters have to be changed accordingly.
XC2000 sensorless FOC
Parameter Calculation
v1.0.00
Motor Parameter
R
L
Pole Pairs
MAXON EC32-flat
1,715 ohm
935 µ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
1000
1
0,092307692
2000
5000
Inverter Parameter
DC link voltage
dead time
switch delay (max)
PWM frequency
Bootstrap precharge time
ENABLE pin logic level
12
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
1: high active
-1: low active
Autostart enable
Use poti for speed
0
0
Current Measurement
R_shunt
R_IN
R_feedback
maximum Voltage at ADC
0,005
0,39
6,19
5
Speed PI Controller
Ki
Kp
Current PI Controller
scale
Figure 32
ohm
kOhm
kOhm
V
Startup
Startup V/f offset (f = 0)
Startup V/f slew rate
0,000206 V
0,000014 V/Hz
Speed
speed
3,433228 rpm
Voltages
V(d,q)
V(D,E)
V(svm amplitude)
0,000206 V
0,000822 V
0,011871 V
Currents
I(d,q)
I(D,E)
I(u,v,w)
0,000452 A
0,000452 A
0,007235 A
PI Controller
Speed kp
0,001953
Speed ki
0,000031
Current kp
Current ki
0,001953
0,000031
0,01 ( < 0,5 )
10 ( < 64 )
(<= 0,1) (<= 0,1)
Excel sheet input page
Application Note
34
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Configuration and Monitoring
After changing the Input Parameter, the contents of output page has to be copied to the file defines.h, 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).
5.2
Drive Monitor
The DriveMonitor is a hardware tool which bridges USB to CAN. With this it is possible to monitor some interesting
data of the target on a host PC in real-time. For more information please refer to the DriveMonitor application note
in [1].
5.2.1
Configuration
The configuration of the DriveMonitor setup can be found in the DriveMonitor application note in [1].
5.2.2
Monitoring the Startup Behavior
Different motors have different startup behavior. The starting up of a synchronous motor takes effort. The first
revolutions have to be done in an open loop mode before the FOC algorithm can take over. There are some values
which mainly influence the startup behaviour. These values can be found in the Excel sheet under Startup
Parameter and will be discussed below.
After setting the correct R and L values, compilation and downloading, the DriveMonitor can be started and used
in Setting 1 | Startup.
Figure 33
Drive Monitor 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:
Angle from the Startup Control block which is the given angle following the V/f ramp depending on
the slew rate
FluxAngle from the Carthesian to Polar Transform block, which is the estimated (calculated) angle
based on the current measurement.
Application Note
35
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Configuration and Monitoring
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
defines.h:
AngleSpeedThreshold
Figure 34
Startup Behaviour of a Fan before Optimization
Example Fan:
After optimization of
Vf_offset and Vf_slew
the startup behavior is
much better (less ripples
on the estimated angle).
Figure 35
Startup Behaviour 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, defines.h:
AngleSpeedThreshold). 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 (Vq) based on the V/f calculation
otherwise the amplitude would drop immediately. This is accomplished in CC2.c Timer interrupt function by preloading control0.Iq.Yn:
//*****************************************************************************************
// ramp up to motor 0
//*****************************************************************************************
if (STATE_M0 == STATESTARTUP_M0)
{
if( (control0.ReferenceSpeedUser>0?foc0.AngleSpeed:-foc0.AngleSpeed) <
foc0.AngleSpeedThreshold )
foc0.AngleSpeed += (control0.ReferenceSpeedUser>0?RAMP_STEP_M0:-RAMP_STEP_M0);
else
{
if(control0.ControlSwitch)
{
Application Note
36
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Configuration and Monitoring
// preload parameters
control0.Iq.Yn = ((long)foc0.Vq)<<16;
// preload Iq-current controller integral value to last V/f-amplitude value
//*******************
status0.on = 0;
status0.control = 1;
svm0.SVMTMIN = SVMTMIN_M0;
STATE_M0 = STATEFOC_M0;
}
}
}
The speed controller must adjust at runtime. Therefore it is advisable that the speed controller is started with an
input step, i.e. a difference between the ANGLESPEED_THRESHOLD_M0 and the REFSPEED_STARTUP_M0. In
DriveMonitor the value Speed Ramp can be adjusted by Speed_ref, i.e. the user can play with this value.
reference speed
actual speed
Output of speed
controller:
Iq_reference
a)
Figure 36
b)
c)
Switching point from V/f to FOC with different Speed_ref settings
In Figure 37 different threshold conditions can be observed:
a) REFSPEED_STARTUP_M0= ANGLESPEED_THRESHOLD_M0
b) REFSPEED_STARTUP_M0>ANGLESPEED_THRESHOLD_M0
c) REFSPEED_STARTUP_M0>>ANGLESPEED_THRESHOLD_M0.
Application Note
37
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
Configuration and Monitoring
5.2.3
Monitoring the Runtime Behavior
The Runtime behavior can be influenced by the PI parameter settings of the speed and controllers. Here the
DriveMonitor offers the window Setting 2 | Control. The ki and kp parameters can be easily adjusted. For
monitoring the Scope Speed or Scope I_uvq can be used.
Figure 37
Drive Monitor Setting 2 | Control
Pink: reference speed
green: actual speed
yellow: output of current
regulator
small Kp
Application Note
large Kp
38
V 1.0, 2010-09
AP16180
XC2000 Sensorless Fieldoriented Control
References
6
References
[1]
Application note - AP0807120_DriveMonitor
[2]
Application note - AP0808810_XC878DriveCar
[3]
Application note - AP1617910_DriveCard_XC2236N
[4]
Application note - AP0805910_Sensorless_FOC
[5]
Application note - AP08090_XC878_Sensorless_FOC
[6]
Link to free toolchain program -- http://www.infineon.com/Freetools
[7]
Link to FOC Drive page - www.infineon.com/FOCDRIVE
Note: Please check the Infineon website (www.infineon.com) for the latest Version of these documents.
Application Note
39
V 1.0, 2010-09
w w w . i n f i n e o n . c o m
Published by Infineon Technologies AG