Flux control simulink and software library of a PMSM
Introduction
This application note describes a software library for the electric motor control implementing
a (FOC) Flux Oriented Control on an ST10 microcontroller.
This document describes a software library for the electric motor control implementing a
(FOC) Flux Oriented Control onST10 Microcontroller.
The library consists of:
●Simulink Library;
●Software Library.
The FOC Simulink Library is a set of Simulink blocks for implementing in Matlab-Simulink
environment the functions and the algorithms used in the electric motor control. These
blocks can be used either to conceive and to test new electric motor controls and to produce
automatic generated code in ANSI C, downloadable on microcontroller.
The Software Library is a set of routines for the electric motor control obtained from the code
generated in automatic, starting from FOC Simulink library, and then optimized in
Assembler. The Software Library is equivalent to FOC Simulink Library from point of view of
bit accuracy, same API.
This document begins with an introduction on Flux Oriented Control, the permanent magnet
synchronous machine (PMSM) and a short description of its mathematical model. Then, it
describes the Flux Oriented Control implementation on Simulink and details the space
vector modulation (SVM) technique and the used algorithm.
After the technical introduction, the Simulink Flux Control Library is described, followed by
the Software Flux Control Library.
The last part describes the code generation process from the Simulink blocks of this library.
6/53
AN2290FOC-flux oriented control
2 FOC-flux oriented control
The Flux Oriented Control (FOC) is a vectorial control strategy that consists of controlling
the stator currents represented by a space vector, phase angle and magnitude, by which the
terminology “vector control”.
This vector control form is based on three major points:
●the machine current and voltage vectors;
●the transformation of a three phase speed and time dependent system into two co-
These lead the control of AC machine to acquire every advantage of DC machine control,
very similar at the control of separately excited DC machine where the useful torque is
proportional to the product of the field current, icurrent, i
(torque-producing current) and torque and flux are controlled independently. .
a
T
cifia⋅⋅c1ψfia [2.1]⋅⋅==
el
In fact using the vector theory, it is easy to show that an expression of the electric torque
similar to one of DC machine can be expressed for AC motor, all depends on choice of an
appropriate frame where to project the machine model.
(flux-producing current), and the armature
f
The core of FOC control is the projection of a three phases (a,b,c) time and speed
dependent system into two co-ordinate (d,q) time invariant system, how explained in the
following.
Choosing a (d,q) frame where the d axis has the same direction of rotor magnet flux
ψ
, it is
f
possible to verify that the produced electromagnetic torque is proportional to the magnet flux
and the quadrature-axis stator current component (torque-producing stator current i
sq
).
In the Figure 1, the Vector Diagram is shown:
Figure 1.Vector diagram
From this figure it is possible to understand that the direct-axis stator current component i
sd
is the only component in able to modify the field flux, weakening it.
Supposing constant field flux (setting to zero i
, if field weakening is no used), a quick
sdref
torque response is obtained changing only the quadrature-axis stator current component,
i
, by means of a current-controlled PWM inverter, as shows the following equation (2.2):
sq
7/53
FOC-flux oriented controlAN2290
We can conclude saying the Flux Oriented Control, handling instantaneous electrical
quantities, is a very accurate control in every working operation, either in steady state and in
transient, achieving high dynamic performance in terms of response times and power
conversion.
In this application note, the FOC control is explained using a particular AC machine, called
Permanent Magnetic Synchronous Machine (PMSM).
A short description of this machine, its features and mathematical model, follow before to
explain in details the FOC implementation.
2.1 PMSM
The necessity of reducing the charge of the combustion engine and of eliminating the weight
due to the mechanical connections in several applications, like in automotive field, induces
to use more and more electric motors, that assure a wide range in speed and torque control
satisfying the load demand.
The DC machine fulfils these requirements but needs periodic maintenance.
The AC machine, like induction motor and brushless permanent magnet motor, hasn’t
brushes, and its rotor is more robust because there aren’t commutator and/or rings. That
means a very low maintenance, other than increases the power-to-weight ratio and
efficiency.
3
T
--- pψ
el
2
fis
αsθe–()sin⋅
3
--- pψ
2
fis
3
δ()sin⋅
--- pψ
2
[2.2] ⋅===
fisq
In particular, in the automotive field the Permanent Magnet Synchronous Machine (PMSM)
seems to be the best solution.
The brushless permanent magnet motors (PMSMs) have the same electromagnetic
structure of a synchronous machine, without the brushes. As shown in the cross-section in
the Figure 2, they have a wound stator, similar to an induction machine, and a permanent
magnet rotor that replaces a rotor fed with dc current, like a synchronous machine. Besides,
they need of an internal or external device for sensing of the rotor position, like Hall sensors,
encoder or resolver.
Figure 2.Cross-section of PMSM
In fact the PMSMs are not self-commuting motors and to produce useful torque, the currents
and the voltages applied to stator phases must be controlled as a function of rotor position.
8/53
AN2290FOC-flux oriented control
Therefore it is generally required to count the rotor position with a sensor so that the inverter
phases which feed it, acting at any time, are commuted depending on the rotor position.
That explains the necessity of a closed-loop speed/position feedback.
There are two kinds of brushless permanent magnet machines classifiable in account of the
shape of the BEMF (back-electromagnetic force):
●DC brushless machine having trapezoidal flux distribution and a trapezoidal BEMF fed
by quasi-square wave currents;
●AC brushless machine having approximately sinusoidal air-gap flux density and a
quasi-sinusoidal BEMF fed by sinusoidal stator currents.
Generally the DC brushless machines have a simpler control strategy than AC brushless
machines.
For trapezoidal flux distributions, to impose quasi-square wave currents on stator windings,
it is only needed a six position sensor, with a resolution of at least 60° electrical degrees.
On the contrary, for the sinusoidal current type, the angular position needs to be known with
a very accurate precision in order to control each of the three phases currents.
For both kinds, the high reliability of control makes this type of machine a powerful system
for electric vehicle application.
2.2 Mathematical model of the machine
In order to model the fields produced by the stator windings in terms of windings current,
“current space vectors” are used. The current space vector for a given winding has the
direction of the field produced by that winding and a magnitude proportional to the current
through the winding. This allows us to represent the total stator field as a current space
vector that is the vector sum of three space vector components, one for each of the stator
windings.
The three-phase voltage, currents and fluxes of AC motors can be analyzed in terms of
complex space vectors.
For instance, with regard to the currents in the stator windings, the current space vector can
be define as follows.
Figure 3.Stator current space vector and its components in (a,b,c)
9/53
FOC-flux oriented controlAN2290
Assuming that is1,is2,is3 are the instantaneous currents in the stator phases, then the
complex stator current vector i
is defined by:
s
2
where
α
= e
j(2π/3)
and
α
2
= e
i
s
---i
s1is2
3
j(4π/3)
represent spatial operators. The Figure 3 shows the
α⋅is3α2⋅++() [2.3]⋅=
stator current complex space vector.
That being stated, it is possible to write the mathematical model of an AC brushless
machine in a stator frame in terms of space vectors, as follows:
usRsisL
di
d
s
-------
dt
----- ψ
dt
s
jpθ
r
e
⋅() [2.4]+⋅+⋅=
f
where:
ψ
f
R
s
L
s
ω
r
pNumber of pole pairs
θ
r
Modulus of the magnetizing flux-linkage vector
Stator resistance
Total three phase stator inductance
Rotor angular speed
Mechanical position
and the space vectors:
2π
-------
u
s
2
i
---i
s
3
t() u2t() e
---u
3
++
⎜⎟
1
⎝⎠
⎛⎞
t() i
⎜⎟
s1
⎝⎠
⎛⎞
2
⋅u3t() e⋅
t() e
⋅i
s
2
j
3
2π
j
-------
3
s
3
t() e
⋅++
4π
-------
j
3
Space vector of the stator voltage ⋅=
4π
j
-------
3
Space vector of the stator current⋅=
Note that the mechanical position of the electric motors is related to the rotation of the shaft
while the electrical position is relate to the rotation of the rotor magnetic field.
So being the motor with p pole pairs, its rotor needs only to move 360/p mechanical degrees
to obtain an identical magnetic configuration as when it started.
10/53
AN2290FOC-flux oriented control
Figure 4.Phase motor with 2 pole pair
Consequently the electric position of the rotor is linked to the mechanical position by the
relation:
θeθrp ⋅=
To complete the mathematical model of the motor, we include the equation of mechanical
equilibrium:
dω
r
J
---------T
dt
+() [2.5]–=
eTmTν
and substituting the expression of the electric torque (2.2), it yields:
dω
---------
dt
1
r
---T
eTmTν
J
+()–()⋅
1
3
⎛⎞
---
--- pψfi
⎝⎠
J
2
αsp θ⋅r–()TmTν+()–()sin⋅
s
[2.6]⋅==
where:
T
e
T
m
T
ν
α
s
JInertia momentum of the machine
Electromagnetic torque
Mechanical torque
Viscose friction torque
Phase of the current space vector respect
Note: in Matlab-Simulink environment, the PMSM discrete model has been implemented
using a model of the machine in a stationary stator reference (D,Q) frame.
11/53
FOC-flux oriented controlAN2290
2.3 FOC control structure of PMSM
In Flux Oriented Control, motor currents and voltages are manipulated in the d-q reference
frame of the rotor. This means that measured motor currents must be mathematically
transformed from the three-phase stationary reference frame (a,b,c) of the stator windings to
the two axis rotating d-q reference frame, prior to processing, for example by PI controllers
(it is possible to use a different controller). Similarly, the voltages to be applied to the motor
are mathematically transformed from d-q frame of the rotor to the three phases reference
frame of stator before they can be used to produce the voltage control signals for the output
inverter that feeds the motor.
These transformations are the core of Flux Oriented Control.
Simplifying the expression of the electrical model of the machine, the projection from the
three-phase stationary reference frame of the stator windings to the two axis rotating
reference frame can be executed into two subsequent steps:
●(a,b,c) => (D,Q ) (the Clarke transformation) which outputs a two co-ordinate time
variant system;
●(D,Q ) => (d,q) (the Park transformation) which outputs a two co-ordinate time
invariant system;
where it is necessary to know in any time the current values in the stator phases and the
rotor position to execute the projections from a frame to other one, how explained in details
in the following.
Figure 5 is showing the block diagram of the FOC control library, where two motor phase
currents,(i.e. i
, is2), are measured with two current sensors (e.g. by phase shunts or
s1
current transducers) calculating the current in the third winding like the negative sum of the
other two windings, (i
= -(is1 + is2)), and then sending them to the Clarke transformation
s3
module, (Forward Clarke).
Outputs of this block are the two current components (i
, isQ) in the D,Q stator fixed frame.
sD
These components are used as inputs of the Park transformation module, (Forward Park),
that gives in output the current components (i
The i
reference) and i
and isq measured current components are compared to the references i
sd
(the torque reference) and corrected by mean of two PI controllers.
sqref
, isq) in the d,q rotating reference frame.
sd
sdref
(the flux
As in brushless synchronous permanent magnet motor the magnet flux is fixed (depending
on magnets), in the PMSM control, i
component in able to weak the flux, while the torque command i
the speed regulator, e.g. for a speed-FOC. That forces the current space vector i
exclusively in the quadrature direction, respect on the magnet flux vector. Since only i
should be set to zero, being the only current
sdref
could be the output of
sqref
to be
s
sq
produces useful torque, this maximizes the torque efficiency of the system.
Then the outputs of two PI, u
and usq, are sent to the Inverse Park transformation module,
sd
(Reverse Park), from which we get the new components of the stator voltage vector in the
(u
, usQ) non-rotating stator frame.
sD
12/53
AN2290FOC-flux oriented control
Figure 5.Block diagram of the flux oriented control library
These signals are then appropriately processed to produce voltage signals for the output
bridge.
In our case, it is chosen to use the Space Vector Modulation (SVM) technique to impress
the new voltage vector to the motor.
2.4 The space vector modulation theory
The SVM technique is a sophisticated continuous modulation method used, independently
from the type of implemented control on the motor, to generate a desired voltage space
vector at the output of the inverter that feeds the AC motor, in our case a PMSM. It uses a
special scheme to switch the power transistors generating pseudo-sinusoidal currents in the
stator windings.
This strategy offers the following advantages to the application:
●Higher performance to control mid/high dynamical motors;
●higher efficiency (86%);
●improved torque management;
●better start up performance;
●constant torque, less torque ripple;
●improved dynamical reaction.
To better understand the space vector modulation algorithm, it is before explained an other
fundamental component of the control system: the 3 phase inverter.
13/53
FOC-flux oriented controlAN2290
2.4.1 The 3-phase inverter
The inverter is a d.c. to a.c. converter. The Figure 6 shows the structure of a typical 3-phase
power inverter connected to the star motor windings, where V
The six switches can be power BJT, GTO, IGBT etc. The state-of-the-art solution for the
inverter power stages uses MOSFETs in low-voltage applications (i.e. automotive field).
The ON-OFF sequence of all these devices must respect the following conditions, so as to
feed in any time all three stator windings:
–three of the switches must always be ON and three always OFF.
–to avoid shortcut, the upper and lower switches of the same leg are driven with two
complementary pulsed signals
Figure 6.3-phase power inverter scheme
is the DC Link voltage.
dc
On base of the aforementioned conditions, the inverter has only eight permissible switching
states of which six states apply a no-zero voltage to the motor windings and two states with
(V
and V7 ) zero volts when the motor is shorted through the upper or lower transistors.
0
It is useful to express the eight states of the inverter as space vectors: V
three voltages V
, VBn, VCn, that are spatially separated 120° apart, as a space vector for
An
expresses the
0-7
each of the switching states 0-7.
The six vectors including the zero voltage vectors can be expressed geometrically on the
complex plane as shown in the following Figure 7.
In order to generate a rotating field into the machine to produce a useful torque, the inverter
has to be switched in all the possible eight states. A way to use the inverter is the operating
mode called “six-step mode”, that generates high magnitude low order harmonics which
cannot be filtered by motor inductance.
14/53
AN2290FOC-flux oriented control
Figure 7.Space vector diagram
2.4.2 The Space vector pulse width modulation
The inverter is able to apply only eight space vector positions to the stator winding of an
electric machine, while the control imposes a voltage space vector that vary in all the inner
cycle of the hexagon in order to create a smooth rotating field (see Figure 7).
The SVM block, here implemented in Simulink, allows to generate the appropriate PWM
patter to impulse the inverter so that any voltage vector inside the space vector hexagon can
be produced by “time weighting“.
It is based on the fact that a reference voltage vector V
, can be realized by a combination of
s
the two adjacent active vectors and the zero vectors inside of sector where it lies. The output
space vector voltage (choosing an appropriate PWM period, T
the vector V
in this period), can be computed by the integral:
s
T
PWM
∫
0
Vstd⋅()
δ
⎛⎞
V
∫
⎝⎠
0
α
V
++
07⁄
∫
0
β
k
∫
0
V
k1+
so as to suppose steady
PWM,
[2.7]=
from which it yields:
VsV
07⁄
δ
---------------- V
T
PWM
α
---------------- V
k
T
PWM
k1+
----------------⋅+⋅+⋅=
T
PWM
β
where:
V
and V
k
included, T
V
0/V7
(k=0,..7) are the vectors that bound the sector in which the reference vector is
k+1
PWM
vectors in that sector.
T
PWM
is the switching period and α, β and δ are the time frames of Vk, V
αβδ [2.8]++=
and
k+1
15/53
FOC-flux oriented controlAN2290
The resulting equation is:
For example, assuming that the vector V
Figure 8.SVM in the 1
in which α and β are the times during which the vectors V
is in the 1st sector, we have the following situation:
s
k1+
β⋅+⋅
100
and V
are applied.
110
To impose the Vs voltage vector at the motor windings, it is fundamental the knowledge of
the sector where the reference vector is included for a correct behavior of SVM.
In the classic approach, in order to find the sector, you need to know the phase of the
complex reference vector that is calculated with the known formula:
⎛⎞
γarc
ℑmVs()
---------------------
tan [2.10]=
⎜⎟
ℜeV
()
⎝⎠
s
The main problem of this formula is the calculation of arctan implemented on a 16bit
microcontroller. One solution can be to calculate the arctan making a look-up table of thearctan function.
Another solution (here chosen) is to recognize the sector of reference vector V
, starting
s
from the knowledge of the sign of the imaginary (quadrature component) and real (direct
component) parts of the reference vector (u
sDref
, u
) written in a stator non-rotating
sQref
frame and the comparison of the their magnitudes in order to avoid the division in the
equation [2.10].If the vector phase obtained from the formula [2.11] is bigger than π/3 the
vector lies in sector 2 or 5. The control on sign of the components discriminates between the
sector 1-4 and 6-3 if the angle is less than π/3.
ℑmVs()
---------------------
()
ℜeV
s
arc
π
⎛⎞
---
tan≥ℑmV
⎝⎠
3
()arc
π
⎛⎞
---
s
tanℜeV
⎝⎠
3
() [2.11]⋅≥⇒
s
iFigure 9 shows the exploded Sector Finder block:
16/53
Loading...
+ 37 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.