Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Sensorless ACIM Field-Oriented Control: Design Reference Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

NXP Semiconductors Document Number: DRM150

Design Reference Manual Rev. 1, 01/2017

Sensorless ACIM Field-Oriented Control

Contents
1. Introduction
This document describes the software design of the 1. Introduction ....................................................................... 1
direct vector control of 3-phase AC Induction Motors 2. AC induction motor ........................................................... 2
2.1. Equivalent circuit of induction motor ........................ 4
(ACIM). ACIMs are popular in the industry for a 2.2. Space vector model of AC induction motor............... 5
number of reasons, such as: 3. ACIM field-oriented control .............................................. 9
3.1. Rotor flux observer .................................................. 12
• Their construction is extremely optimized, because 3.2. Rotor speed estimation ............................................ 15
they have been produced for years. 3.3. Max Torque Per Ampere ......................................... 16
3.4. Flux weakening ....................................................... 17
• They are very simple and the manufacturing costs 3.5. Space vector modulation ......................................... 18
are low, because they do not include any expensive 4. Software design ............................................................... 20
4.1. Data types ................................................................ 22
components (such as permanent magnets). 4.2. Scaling of analog quantities ..................................... 23
• They are robust and require minimum maintenance 4.3. Motor-control algorithms synchronization .............. 24
4.4. State machines ......................................................... 25
due to the absence of brushes, permanent magnets, 4.5. ACIM control software implementation .................. 34
or other complicated mechanical elements. 5. References ....................................................................... 39
6. Revision history ............................................................... 39
• Unlike Permanent Magnet Synchronous Motors
(PMSM), they can run without any control method
using the mains 3-phase voltage.
You can find induction motors in applications like
water pumps, compressors, fans, and air-conditioning
systems. To achieve variable speed operations with a
3-phase AC induction motor, variable voltage and
frequency must be supplied to the motor. The modern
3-phase variable speed drives achieve this using
digitally-controlled switching inverters. NXP offers the
High-Voltage Motor-Control Platform (HVP) power
stage, which supports many kinds of MCUs, easily
interchangeable using expansion cards. For more
information, see the Freescale High-Voltage Motor-
Control Platform User's Guide (document
HVPMC3PHUG).

© 2016-2017 NXP B.V.


AC induction motor

The control algorithms can be divided into two groups. The first group is called Scalar Control (SC). As
the name suggest, these algorithms were inferred for a steady state (all quantities are scalar values) and
the dynamic behavior of the machine is ignored. The constant Volt per Hertz (V/Hz) control is a very
popular and simple technique, representing the scalar control of variable speed drives. The second group
is called Vector Control (VC), or Field-Oriented Control (FOC). This time the quantities like voltages
and currents within the motor are treated as vectors. While being more computationally complex, FOC
brings overall improvements in drive performance over the scalar control, such as improved dynamics,
full torque control from zero to the nominal speed, higher efficiency, decoupled control of flux and
torque, and other.
The field-oriented methods for the PMSM and ACIM have basically the same principle, but, for the
ACIM FOC, the amplitude of the rotor flux must be controlled and its position must be estimated, rather
than the position of the rotor itself. It is because the rotor flux is not attached to the rotor (as in the case
of PMSM). This also means that the rotor speed does not match the magnetic flux speed (there is the
slip) and must be estimated separately as well. More details about the ACIM FOC are found further on
in this document.
This document shows the reference design of a platform-independent field-oriented control algorithm
for 3-phase AC induction motors, targeted mainly for the consumer and industrial applications. The
reference design is based on the Real-Time Control Embedded Software Libraries (RTCESL) for the
ARM® Cortex® platform, which include various math, general, and motor-control function libraries (see
www.nxp.com/rtcesl).

2. AC induction motor
An AC induction motor is a rotating electric machine, designed to be powered by a 3-phase alternating
current. For variable speed drives, the source is usually an inverter that uses power switches to produce
voltage pulses and generate approximate sinusoidal voltages and currents of a controllable magnitude
and frequency.
The squirrel-cage AC induction motors are popular due to their simple construction, low cost per
horsepower, minimum maintenance, and are available in a wide range of power ratings. With
field-oriented control methods, AC induction motors can fully replace standard DC motors, even in
high-performance applications. The squirrel-cage rotor has aluminum conductors (or bars), which are
cast into the slots in the outer periphery of the rotor. These conductors (or bars) are shorted together at
both ends of the rotor by cast aluminum end rings, which can be also shaped to act as fans. In larger
induction motors, copper or copper-alloy bars are used to fabricate the rotor cage winding.
The cross section of a 2-pole induction motor is shown in the following figure. The slots in the inner
periphery of the stator accommodate the 3-phase windings A, B, and C. The turns in each winding are
distributed in such way that the current in the stator winding produces the approximate
harmonically-distributed flux density around the periphery of the air gap. When the 3-phase sinusoidal
current with a 120° phase mutual displacement of each phase flows through the stator, a radially directed
flux, rotating with a synchronous speed is generated.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


2 NXP Semiconductors
AC induction motor

Figure 1. Cross section of 3-phase AC induction motor

When the harmonically-distributed flux density wave produced by the stator magnetizing currents
sweeps past the rotor conductors, it induces voltage in them. The result is a harmonically distributed set
of currents in the short-circuited rotor bars. Because of the low resistance of these shorted bars, only a
small relative angular velocity between the angular velocity of the flux wave 𝜔𝜔𝑒𝑒 and the mechanical
angular velocity 𝜔𝜔𝑚𝑚 of the 2-pole rotor is required to produce the necessary rotor current. This relative
angular velocity is called the slip velocity

𝝎𝝎𝒔𝒔𝒔𝒔𝒔𝒔𝒔𝒔 = 𝝎𝝎𝒆𝒆 − 𝝎𝝎𝒓𝒓 = 𝝎𝝎𝒆𝒆 − 𝑷𝑷𝒑𝒑 𝝎𝝎𝒎𝒎 [rad/s], Eq. 1

where 𝜔𝜔𝑟𝑟 is the rotor electrical speed and 𝑃𝑃𝑝𝑝 is the number of motor pole-pairs. This leads to the
definition of an important quantity, called the slip:
(𝝎𝝎𝒆𝒆 −𝝎𝝎𝒓𝒓 ) Eq. 2
𝒔𝒔 = [-]
𝝎𝝎𝒆𝒆

The interaction of the harmonically distributed air gap flux and the induced rotor currents produces
torque in the rotor. The machine produces torque only with a non-zero slip. This is why the induction
motors are also called asynchronous. The relationship between the rotor electrical speed 𝜔𝜔𝑟𝑟 and
frequency 𝑓𝑓𝑟𝑟 is:

𝝎𝝎𝒓𝒓 = 𝟐𝟐𝟐𝟐𝒇𝒇𝒓𝒓 [rad/s] Eq. 3

The mechanical rotor speed related to the number of pole-pairs in revolutions per minute (rpm) is:
𝒇𝒇𝒓𝒓 Eq. 4
𝑵𝑵𝒎𝒎 = 𝟔𝟔𝟔𝟔 [rpm]
𝑷𝑷𝒑𝒑

The typical induction machine speed-torque characteristic is shown in the following figure. The first
way of characteristic division is by the machine states into the braking, motor, and generator regions.
FOC can control the machine in each of these states. The motor and generator states are
centrally-symmetric around the zero-torque point. When the motor operates in the stable motor region

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 3
AC induction motor

(green area located between the machine maximum positive or negative torques), the increasing slip
(loading torque) leads to the generation of a higher torque. The increase of the load torque in unstable
motor regions leads to a drop in the generated torque and potentially to the stopping or reversing of the
rotor. When the motor operates using FOC, it uses only the stable part. The stable region can be moved
left or right by changing the supply frequency.

Figure 2. ACIM speed-torque characteristic

The following sections are dedicated to the ACIM modeling. Section 2.1, “The equivalent circuit of
induction motor” shows the equivalent circuit of ACIM. However, the model used for the FOC design
utilizes the space-vector theory, which is described in Section 2.2, “Space vector model of AC induction
machine”.

2.1. Equivalent circuit of induction motor


The purpose of the equivalent circuit (see Figure 3) is to analyze and understand the operation of
induction motors. In the equivalent circuit, 𝑅𝑅𝑠𝑠 represents the resistance of the stator winding and 𝑋𝑋𝑠𝑠𝑠𝑠 is
the stator leakage reactance (flux that does not link with the air gap and the rotor). The magnetizing
reactance required to cross the air gap is represented by 𝑋𝑋𝑚𝑚 , and the core losses (hysteresis and eddy
current) by 𝑅𝑅𝑐𝑐 .
On the rotor side, the induced EMF is affected by the slip. A larger slip leads to the increase of EMF and
rotor current. Therefore, the rotor can be represented by the resistance and reactance 𝑅𝑅𝑟𝑟 and 𝑋𝑋𝑟𝑟𝑟𝑟 . The
equivalent circuit shown in the following figure refers to the rotor resistance and reactance, calculated to
the primary side.
The typical parameter identification process usually involves the no-load, blocked-rotor, and DC tests
for the stator resistance measurement. Such measurement is not in the scope of this document.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


4 NXP Semiconductors
AC induction motor

Figure 3. Equivalent circuit of induction motor

2.2. Space vector model of AC induction motor


The AC induction motor model used for FOC utilizes the space vector theory. Using this theory, the
3-phase motor quantities (such as voltage, current, magnetic flux, and other) are expressed in terms of
complex space vectors. Such model is valid for any instantaneous variation of voltage and current, and
adequately describes the performance of the machine in both the steady-state and transient operations.
Complex space vectors can also be described using only two orthogonal axes, which reduces the
complexity of the machine model.

2.2.1. Space vector theory


Let’s assume that 𝑖𝑖𝑠𝑠𝑠𝑠 , 𝑖𝑖𝑠𝑠𝑠𝑠 , and 𝑖𝑖𝑠𝑠𝑠𝑠 are instantaneous, balanced, 3-phase stator currents. The stator current
space vector then can be defined as

𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔𝒔𝒔 = 𝒌𝒌(𝒊𝒊𝒔𝒔𝒔𝒔 + 𝒂𝒂𝒊𝒊𝒔𝒔𝒔𝒔 + 𝒂𝒂𝟐𝟐 𝒊𝒊𝒔𝒔𝒔𝒔 ), Eq. 5

where 𝑎𝑎 = 𝑒𝑒 𝑗𝑗2𝜋𝜋\3 and 𝑎𝑎2 = 𝑒𝑒 −𝑗𝑗2𝜋𝜋\3 are the spatial operators, and 𝑘𝑘 is the transformation constant. This
constant is usually selected as 𝑘𝑘 = 2/3, so that the resulting stator current space vector has the same
amplitude as the phase currents. Figure 4 shows the stator-current space vector projection.
However, the space vector rotates only in a 2-dimensional space, so only two axes are needed to express
it. The stator current vector can be expressed as:

𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝒋𝒋𝒋𝒋𝒔𝒔𝒔𝒔 , Eq. 6

where 𝑖𝑖𝑠𝑠𝑠𝑠 and 𝑖𝑖𝑠𝑠𝑠𝑠 are the real and imaginary components of the stator current vector in the 𝛼𝛼𝛼𝛼 stator
reference frame (the alpha axis is usually selected to be aligned with the axis of phase A). Note that the
currents 𝑖𝑖𝑠𝑠𝑠𝑠 and 𝑖𝑖𝑠𝑠𝑠𝑠 are only fictitious and can’t be measured directly within the machine. This is called
the Clarke transformation, and, assuming that 𝑖𝑖𝑠𝑠𝑠𝑠 + 𝑖𝑖𝑠𝑠𝑠𝑠 + 𝑖𝑖𝑠𝑠𝑠𝑠 = 0, the relation between two and three
phase currents is:

𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 7

𝟏𝟏 𝟐𝟐
𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔b + 𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 8
√𝟑𝟑 √𝟑𝟑

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 5
AC induction motor

The principle of Clarke transformation is shown in Figure 4. The inverse Clarke transformation is
defined as:

𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 9

𝟏𝟏 √𝟑𝟑 Eq. 10
𝒊𝒊𝒔𝒔𝒔𝒔 = − 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝒊𝒊
𝟐𝟐 𝟐𝟐 𝒔𝒔𝒔𝒔
𝟏𝟏 √𝟑𝟑 Eq. 11
𝒊𝒊𝒔𝒔𝒔𝒔 = − 𝒊𝒊𝒔𝒔𝒔𝒔 − 𝒊𝒊
𝟐𝟐 𝟐𝟐 𝒔𝒔𝒔𝒔
The space vectors of the other motor quantities (like voltages and magnetic fluxes) can be defined in the
same way as the stator-current space vector above.

Figure 4. Stator current space vector in stator reference frame

Besides the stationary 𝛼𝛼𝛼𝛼 reference frame, the space vectors can be formulated in the general 𝛾𝛾𝛾𝛾
reference frame, rotating at the general speed 𝜔𝜔𝑔𝑔 = d𝜃𝜃𝑔𝑔 /d𝑡𝑡, as shown in Figure 5. The direct axis of the
rotating reference frame 𝛾𝛾 is rotated from axis 𝛼𝛼 by angle 𝜃𝜃𝑔𝑔 . The stator-current space vector in the
general 𝛾𝛾𝛾𝛾 reference frame can be expressed as:

𝒊𝒊⃗𝒔𝒔𝜸𝜸𝜸𝜸 = �𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 �𝒆𝒆−𝒋𝒋𝜽𝜽𝒈𝒈 = 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝒋𝒋𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 12

The components of vector ��⃗


𝚤𝚤𝑠𝑠 in the 𝛾𝛾𝛾𝛾 reference frame can be obtained using the Park transformation:

𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 𝒄𝒄𝒄𝒄𝒄𝒄 𝜽𝜽𝒈𝒈 + 𝒊𝒊𝒔𝒔𝒔𝒔 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝒈𝒈 Eq. 13

𝒊𝒊𝒔𝒔𝒔𝒔 = −𝒊𝒊𝒔𝒔𝒔𝒔 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝒈𝒈 + 𝒊𝒊𝒔𝒔𝒔𝒔 𝒄𝒄𝒄𝒄𝒄𝒄 𝜽𝜽𝒈𝒈 Eq. 14

The inverse Park transformation is calculated using these equations:

𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 𝒄𝒄𝒄𝒄𝒄𝒄 𝜽𝜽𝒈𝒈 − 𝒊𝒊𝒔𝒔𝒔𝒔 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝒈𝒈 Eq. 15

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


6 NXP Semiconductors
AC induction motor

𝒊𝒊𝒔𝒔𝒔𝒔 = 𝒊𝒊𝒔𝒔𝒔𝒔 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝒈𝒈 + 𝒊𝒊𝒔𝒔𝒔𝒔 𝒄𝒄𝒄𝒄𝒄𝒄 𝜽𝜽𝒈𝒈 Eq. 16

The voltage and flux-linkage space vectors in the general reference frame 𝛾𝛾𝛾𝛾 can be obtained in a
similar way.

Figure 5. Application of general reference frame

2.2.2. ACIM model in stationary reference frame


This section provides the mathematical equations for a 3-phase squirrel-cage induction motor in a
general 𝛼𝛼𝛼𝛼 stator reference system. The motor model is expected to be ideally symmetrical with a linear
magnetic circuit characteristic. The stator voltage 𝑢𝑢
�⃗𝑠𝑠𝑠𝑠𝑠𝑠 = 𝑢𝑢𝑠𝑠𝑠𝑠 + 𝑗𝑗𝑢𝑢𝑠𝑠𝑠𝑠 can be expressed as:
𝒅𝒅𝝍𝝍𝒔𝒔𝒔𝒔
𝒖𝒖𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + , Eq. 17
𝒅𝒅𝒅𝒅

𝒅𝒅𝝍𝝍𝒔𝒔𝒔𝒔
𝒖𝒖𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + , Eq. 18
𝒅𝒅𝒅𝒅

where 𝜓𝜓�⃗𝑠𝑠𝑠𝑠𝑠𝑠 = 𝜓𝜓𝑠𝑠𝑠𝑠 + 𝑗𝑗𝜓𝜓𝑠𝑠𝑠𝑠 is the stator linkage vector.


The rotor 𝑢𝑢
�⃗𝑟𝑟 voltage components, expressed in the stator reference frame using the Park transformation,
are:
𝒅𝒅ψ𝒓𝒓𝒓𝒓
𝒖𝒖𝒓𝒓𝒓𝒓 = 𝟎𝟎 = 𝑹𝑹𝒓𝒓 𝒊𝒊𝒓𝒓𝒓𝒓 + + 𝝎𝝎𝒓𝒓 𝝍𝝍𝒓𝒓𝒓𝒓 , Eq. 19
𝒅𝒅𝒅𝒅

𝒅𝒅𝝍𝝍𝒓𝒓𝒓𝒓
𝒖𝒖𝒓𝒓𝒓𝒓 = 𝟎𝟎 = 𝑹𝑹𝒓𝒓 𝒊𝒊𝒓𝒓𝒓𝒓 + − 𝝎𝝎𝒓𝒓 𝝍𝝍𝒓𝒓𝒓𝒓 , Eq. 20
𝒅𝒅𝒅𝒅

where 𝜓𝜓�⃗𝑟𝑟𝑟𝑟𝑟𝑟 = 𝜓𝜓𝑟𝑟𝑟𝑟 + 𝑗𝑗𝜓𝜓𝑟𝑟𝑟𝑟 is the rotor flux linkage. The left-hand side shows that the rotor voltage sums
up to zero in a squirrel-cage induction motor.
The stator and rotor flux linkages, expressed in terms of the stator and rotor current space vectors, are:

𝝍𝝍𝒔𝒔𝒔𝒔 = 𝑳𝑳𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝑳𝑳𝒎𝒎 𝒊𝒊𝒓𝒓𝒓𝒓 , Eq. 21

𝝍𝝍𝒔𝒔𝒔𝒔 = 𝑳𝑳𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝑳𝑳𝒎𝒎 𝒊𝒊𝒓𝒓𝒓𝒓 , Eq. 22

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 7
AC induction motor

𝝍𝝍𝒓𝒓𝒓𝒓 = 𝑳𝑳𝒓𝒓 𝒊𝒊𝒓𝒓𝒓𝒓 + 𝑳𝑳𝒎𝒎 𝒊𝒊𝒔𝒔𝒔𝒔 , Eq. 23

𝝍𝝍𝒓𝒓β = 𝑳𝑳𝒓𝒓 𝒊𝒊𝒓𝒓𝒓𝒓 + 𝑳𝑳𝒎𝒎 𝒊𝒊𝒔𝒔𝒔𝒔 , Eq. 24

where 𝐿𝐿𝑠𝑠 , 𝐿𝐿𝑟𝑟 , and 𝐿𝐿𝑚𝑚 are the stator, rotor, and mutual inductances. The electromagnetic torque generated
by the machine is:
𝟑𝟑 𝑳𝑳𝒎𝒎
𝑻𝑻 = 𝑷𝑷𝒑𝒑 �𝝍𝝍𝒔𝒔𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 − 𝝍𝝍𝒔𝒔𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 � Eq. 25
𝟐𝟐 𝑳𝑳𝒓𝒓
The mechanical differential equation of the rotor is:
𝒅𝒅𝝎𝝎𝒓𝒓 𝑷𝑷𝒑𝒑 𝑩𝑩
= �𝑻𝑻 − 𝑻𝑻𝒍𝒍𝒍𝒍𝒍𝒍𝒍𝒍 − 𝑷𝑷 𝝎𝝎𝒓𝒓 �, Eq. 26
𝒅𝒅𝒅𝒅 𝑱𝑱 𝒑𝒑

where 𝐽𝐽 is the moment of inertia, 𝐵𝐵 is the viscous friction, and 𝑇𝑇𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 is the load torque.

2.2.3. ACIM model in general rotating reference frame


This section provides the mathematical model of an ACIM in the general 𝛾𝛾𝛾𝛾 rotating reference system.
The stator voltage equation in the general rotating coordinate system can be obtained from Eq. 17 and
Eq. 18 using the Park transformation as follows:
���⃗𝒔𝒔𝒔𝒔𝒔𝒔
𝒅𝒅𝝍𝝍
�⃗𝒔𝒔𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 +
𝒖𝒖 + 𝒋𝒋𝝎𝝎𝒈𝒈 ���⃗
𝝍𝝍𝒔𝒔𝒔𝒔𝒔𝒔 Eq. 27
𝒅𝒅𝒅𝒅
Similarly, the rotor voltage is:
���⃗𝒓𝒓𝒓𝒓𝒓𝒓
𝒅𝒅𝝍𝝍
𝟎𝟎 = 𝑹𝑹𝒓𝒓 𝒊𝒊⃗𝒓𝒓𝜸𝜸𝜸𝜸 + ���⃗𝒓𝒓𝒓𝒓𝒓𝒓
+ 𝒋𝒋�𝝎𝝎𝒈𝒈 − 𝝎𝝎𝒓𝒓 �𝝍𝝍 Eq. 28
𝒅𝒅𝒅𝒅
The stator and rotor flux linkages are:
���⃗
𝝍𝝍𝒔𝒔𝒔𝒔𝒔𝒔 = 𝑳𝑳𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝜸𝜸𝜸𝜸 + 𝑳𝑳𝒎𝒎 𝒊𝒊⃗𝒓𝒓𝜸𝜸𝜸𝜸 Eq. 29

���⃗
𝝍𝝍𝒓𝒓𝒓𝒓𝒓𝒓 = 𝑳𝑳𝒓𝒓 𝒊𝒊⃗𝒓𝒓𝜸𝜸𝜸𝜸 + 𝑳𝑳𝒎𝒎 𝒊𝒊⃗𝒔𝒔𝜸𝜸𝜸𝜸 Eq. 30

The produced electromagnetic torque is:


𝟑𝟑
𝑻𝑻𝒆𝒆 = 𝑷𝑷 ���⃗
𝝍𝝍 ×𝒊𝒊⃗ Eq. 31
𝟐𝟐 𝒑𝒑 𝒔𝒔𝒔𝒔𝒔𝒔 𝒔𝒔𝜸𝜸𝜸𝜸

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


8 NXP Semiconductors
ACIM field-oriented control

3. ACIM field-oriented control


Despite relatively higher computation demands, the field-oriented control scheme enables you to
produce highly dynamic performance drives that are comparable even with the DC machines. It also
brings a full torque control from zero to the nominal speed, higher efficiency, decoupled control of flux
and torque, and more.
The basic idea of the direct FOC is to express the machine space-vector model in the rotating 𝑑𝑑𝑑𝑑
reference frame, which has its direct d-axis aligned with the flux-linkage vector. Different FOC
strategies may be inferred, based on which magnetic flux vector (stator, rotor, or magnetizing) is going
to be aligned. However, best results and a complete separation of the torque and flux control can be
achieved by aligning the d-axis with the rotor flux-linkage vector. This is shown in the following figure:

Figure 6. Rotor flux and stator current in dq reference frame

Because of the alignment with rotor flux, the 𝑑𝑑𝑑𝑑 reference frame is rotating at a synchronous speed
𝜔𝜔𝑒𝑒 = d𝜃𝜃𝜓𝜓𝑟𝑟 /d𝑡𝑡. When substituting 𝜔𝜔𝑔𝑔 = 𝜔𝜔𝑒𝑒 in the machine model from Section 2.2.3, “ACIM model in
general rotating reference frame”, the stator and rotor voltages are:
���⃗𝒔𝒔𝒔𝒔𝒔𝒔
𝒅𝒅𝝍𝝍
�⃗𝒔𝒔𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 +
𝒖𝒖 + 𝒋𝒋𝝎𝝎𝒆𝒆 ���⃗
𝝍𝝍𝒔𝒔𝒔𝒔𝒔𝒔 Eq. 32
𝒅𝒅𝒅𝒅
���⃗𝒓𝒓𝒓𝒓𝒓𝒓
𝒅𝒅𝝍𝝍
𝟎𝟎 = 𝑹𝑹𝒓𝒓 𝒊𝒊⃗𝒓𝒓𝒅𝒅𝒅𝒅 + ���⃗𝒓𝒓𝒓𝒓𝒓𝒓
+ 𝒋𝒋(𝝎𝝎𝒆𝒆 − 𝝎𝝎𝒓𝒓 )𝝍𝝍 Eq. 33
𝒅𝒅𝒅𝒅
Combining the voltage equations Eq. 32 and Eq. 33 with the flux-linkage equations Eq. 29 and Eq. 30
leads to:
𝒅𝒅𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 ���⃗𝒓𝒓𝒓𝒓𝒓𝒓
𝑳𝑳𝒎𝒎 𝒅𝒅𝝍𝝍 𝑳𝑳𝒎𝒎
�𝒖𝒖⃗𝒔𝒔𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 + 𝝈𝝈𝑳𝑳𝒔𝒔 + 𝒋𝒋𝝎𝝎𝒆𝒆 𝝈𝝈𝑳𝑳𝒔𝒔⃗ı𝒔𝒔𝒔𝒔𝒔𝒔 + + 𝒋𝒋𝝎𝝎𝒆𝒆 ���⃗
𝝍𝝍𝒓𝒓𝒓𝒓𝒓𝒓 , Eq. 34
𝒅𝒅𝒅𝒅 𝑳𝑳𝒓𝒓 𝒅𝒅𝒅𝒅 𝑳𝑳𝒓𝒓

���⃗𝒓𝒓𝒓𝒓𝒓𝒓
𝒅𝒅𝝍𝝍 𝑳𝑳𝒎𝒎 𝟏𝟏
= 𝒊𝒊⃗ − �𝒋𝒋(𝝎𝝎𝒆𝒆 − 𝝎𝝎𝒓𝒓 ) + � ���⃗
𝝍𝝍𝒓𝒓𝒓𝒓𝒓𝒓 , Eq. 35
𝒅𝒅𝒅𝒅 𝝉𝝉𝒓𝒓 𝒔𝒔𝒅𝒅𝒅𝒅 𝝉𝝉𝒓𝒓

where 𝜎𝜎 = 1 − 𝐿𝐿2𝑚𝑚 /(𝐿𝐿𝑠𝑠 𝐿𝐿𝑟𝑟 ) is the leakage coefficient and 𝜏𝜏𝑟𝑟 = 𝐿𝐿𝑟𝑟 /𝑅𝑅𝑟𝑟 is the rotor time constant. Notice
that the above equations no longer contain the rotor current. Because the rotor flux is aligned with the
direct axis, the q-axis component of the rotor flux 𝜓𝜓𝑟𝑟𝑟𝑟 is zero. Considering motor operation with the
constant flux d𝜓𝜓𝑟𝑟𝑟𝑟 /d𝑡𝑡 = 0, the above equations are simplified as:

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 9
ACIM field-oriented control

𝒅𝒅𝒊𝒊𝒔𝒔𝒔𝒔
𝒖𝒖𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝝈𝝈𝑳𝑳𝒔𝒔 − 𝝎𝝎𝒆𝒆 𝝈𝝈𝑳𝑳𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 36
𝒅𝒅𝒅𝒅
𝒅𝒅𝒊𝒊𝒔𝒔𝒔𝒔 𝑳𝑳𝒎𝒎
𝒖𝒖𝒔𝒔𝒔𝒔 = 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 + 𝝈𝝈𝑳𝑳𝒔𝒔 + 𝝎𝝎𝒆𝒆 𝝈𝝈𝑳𝑳𝒔𝒔 𝒊𝒊s𝒅𝒅 + 𝝎𝝎𝒆𝒆 𝝍𝝍 Eq. 37
𝒅𝒅𝒅𝒅 𝑳𝑳𝒓𝒓 𝒓𝒓𝒓𝒓
𝒅𝒅𝝍𝝍𝒓𝒓𝒓𝒓 𝟏𝟏 𝑳𝑳𝒎𝒎
= − 𝝍𝝍𝒓𝒓𝒓𝒓 + 𝒊𝒊 ≅ 𝟎𝟎 → 𝝍𝝍𝒓𝒓𝒓𝒓 = 𝑳𝑳𝒎𝒎 𝒊𝒊𝒔𝒔𝒔𝒔 Eq. 38
𝒅𝒅𝒅𝒅 𝝉𝝉𝒓𝒓 𝝉𝝉𝒓𝒓 𝒔𝒔𝒔𝒔
The torque equation is:
𝟑𝟑 𝑳𝑳𝒎𝒎
𝑻𝑻 = 𝑷𝑷𝒑𝒑 𝝍𝝍 𝒊𝒊 Eq. 39
𝟐𝟐 𝑳𝑳𝒓𝒓 𝒓𝒓𝒓𝒓 𝒔𝒔𝒔𝒔
Notice from equations Eq. 38 and Eq. 39 that the stator current is decoupled into the torque-producing
𝑖𝑖𝑠𝑠𝑠𝑠 and flux-producing 𝑖𝑖𝑠𝑠𝑠𝑠 components.
A very important aspect of using the 𝑑𝑑𝑑𝑑 reference synchronous frame is that all motor quantities in this
frame are no longer harmonic, but DC functions (as shown in the following figure), which greatly
simplifies their control.

Figure 7. Transformations within FOC

The basic scheme of the direct field-oriented ACIM control is shown in the following figure. Because
the rotor flux can’t be easily measured directly, the rotor flux observer algorithm is necessary for the
estimation of the 𝜃𝜃𝜓𝜓𝑟𝑟 angle. The required rotor flux amplitude and torque commands are the inputs of
FOC.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


10 NXP Semiconductors
ACIM field-oriented control

Figure 8. ACIM vector control principle block diagram

The FOC calculation can be summarized in these steps:


• Measure the phase currents and the DC-bus voltage (from which the phase voltage is
reconstructed).
• Transform the currents into a 2-phase 𝛼𝛼𝛼𝛼 system using Clarke transformation (Eq. 7 and Eq. 8).
• Calculate the position angle of the rotor flux vector 𝜃𝜃𝜓𝜓𝑟𝑟 using the flux observer.
• Transform the stator currents into the 𝑑𝑑𝑑𝑑 reference frame using Park transformation (Eq. 13 and
Eq. 14).
• Control the stator torque-producing current 𝑖𝑖𝑠𝑠𝑠𝑠 and the flux-producing component 𝑖𝑖𝑠𝑠𝑠𝑠 separately
within the control process.
• Transform the stator voltage vector using the inverse Park transformation back from the 𝑑𝑑𝑑𝑑
reference frame into the 2-phase 𝛼𝛼𝛼𝛼 system (Eq. 15 and Eq. 16).
• Generate the 3-phase output voltage signals for the inverter using the Space Vector Modulation
(SVM).

The overview block diagram of the implemented control algorithm is shown in the following figure. The
rotor flux position 𝜃𝜃𝜓𝜓𝑟𝑟 and rotor speed 𝜔𝜔𝑚𝑚 are estimated using the rotor flux observer and the speed
estimator (the Model-Reference Adaptive System type in this design). The control process utilizes the
𝑖𝑖𝑠𝑠𝑠𝑠 and 𝑖𝑖𝑠𝑠𝑠𝑠 current PI controllers. The 𝑖𝑖𝑠𝑠𝑠𝑠 current is used to control the rotor magnetizing flux. The goal
of the 𝑖𝑖𝑠𝑠𝑠𝑠 current control is usually to achieve a better power efficiency (for example, with the Max
Torque per Ampere algorithm) or to reach the above-nominal speed (flux-weakening algorithm). The
torque-producing 𝑖𝑖𝑠𝑠𝑠𝑠 current required value is set by the speed PI controller. The DC-Bus
ripple-elimination and SVM algorithms are used to generate the desired stator voltage vector, which is
applied to the motor.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 11
ACIM field-oriented control

Figure 9. Field-oriented control algorithm overview

The following sections provide a closer description of the rotor flux observer, the MRAS speed
estimator, and the field-weakening, Max Torque per Ampere, and Space Vector Modulation algorithms
used in this reference design.

3.1. Rotor flux observer


The observer’s task is to provide the estimates of the rotor flux 𝜓𝜓�⃗𝑟𝑟 using the available measured current
and voltage signals. The rotor flux vector, namely its position 𝜃𝜃𝜓𝜓𝑟𝑟 , is then used in FOC, as described in
Section 3, “ACIM Field-Oriented Control”. When the rotor flux estimate is known, the generated torque
estimate can be calculated as well (using Eq. 25 or Eq. 39).
The closed-loop flux observer used in the FOC design is formed from the two commonly known
open-loop estimators, which are referred to as the voltage (or stator) model and the current (or rotor)
model (see the following figure). Both models are suitable for different rotor speeds and sensitive to the
uncertainty of different motor parameters. To get an accurate and robust rotor flux estimate in a wide
speed range, the PI controllers are used to combine the estimates from both models and compensate for
potential inaccuracies through the voltage 𝑢𝑢
�⃗𝑠𝑠𝑠𝑠𝑠𝑠,𝑐𝑐𝑐𝑐𝑐𝑐 .

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


12 NXP Semiconductors
ACIM field-oriented control

Figure 10. Flux observer block diagram

3.1.1. Voltage model rotor flux observer


The stator (voltage) model operates in the stator 𝛼𝛼𝛼𝛼 reference frame. It uses the well-known stator flux
estimator, which is obtained by the integration of Eq. 17 and Eq. 18:

���⃗ �⃗𝒔𝒔𝜶𝜶𝜶𝜶 − 𝑹𝑹𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝜶𝜶𝜶𝜶 �𝒅𝒅𝒅𝒅


𝝍𝝍𝒔𝒔𝒔𝒔𝒔𝒔 = ��𝒖𝒖 Eq. 40

However, the stator flux estimator in this form contains a pure integration, which has problems with the
drift. These problems can be solved by approximating the pure integrator with the low-pass filter, which
suppresses the lower frequencies and prevents the drift. The operator transfer function of the integrator
is then replaced as:
𝟏𝟏 𝝉𝝉𝟏𝟏
≅ , Eq. 41
𝒔𝒔 𝝉𝝉𝟏𝟏 𝒔𝒔+𝟏𝟏

where 𝜏𝜏1 = 1/(2𝜋𝜋𝑓𝑓1 ) is the approximation time constant. The example of this situation is shown in
Figure 11. Set the low-pass filter cut-off frequency one order below the lowest frequency of the signal
that must be integrated. A very low cut-off frequency might not prevent the drift and very high values
might lead to a high number of estimation errors. The final transfer function of the stator flux estimator
is:
𝝉𝝉𝟏𝟏
𝜳𝜳𝒔𝒔𝒔𝒔 (𝒔𝒔) = [𝑼𝑼 (𝒔𝒔) − 𝑹𝑹𝒔𝒔 𝑼𝑼𝒔𝒔𝜶𝜶 (𝒔𝒔)] Eq. 42
𝝉𝝉𝟏𝟏 𝒔𝒔 + 𝟏𝟏 𝒔𝒔𝜶𝜶
𝝉𝝉𝟏𝟏
𝜳𝜳𝒔𝒔𝒔𝒔 (𝒔𝒔) = �𝑼𝑼 (𝒔𝒔) − 𝑹𝑹𝒔𝒔 𝑼𝑼𝒔𝒔𝜷𝜷 (𝒔𝒔)� Eq. 43
𝝉𝝉𝟏𝟏 𝒔𝒔 + 𝟏𝟏 𝒔𝒔𝜷𝜷
The final rotor flux estimation is obtained from Eq. 21, Eq. 22, Eq. 23, and Eq. 24 as:

���⃗ 𝑳𝑳 ���⃗
� 𝒓𝒓𝒓𝒓𝒓𝒓 = 𝒓𝒓 �𝝍𝝍
𝝍𝝍 � − 𝝈𝝈𝝈𝝈𝒔𝒔 𝒊𝒊⃗𝒔𝒔𝜶𝜶𝜶𝜶 � Eq. 44
𝑳𝑳𝒎𝒎 𝒔𝒔𝒔𝒔𝒔𝒔

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 13
ACIM field-oriented control

These equations show that the rotor flux linkage is basically the difference between the stator flux
linkage and the leakage flux.

Figure 11. Approximation of pure integrator with low-pass filter

These discrete equations of the voltage model rotor flux estimator are obtained using the Euler’s method
with the sampling time 𝑇𝑇𝑠𝑠 :
𝝉𝝉𝟏𝟏
� 𝒔𝒔𝒔𝒔 (𝒌𝒌) =
𝝍𝝍 � (𝒌𝒌 − 𝟏𝟏) + 𝑻𝑻𝒔𝒔 �𝒖𝒖𝒔𝒔𝒔𝒔 (𝒌𝒌) − 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 (𝒌𝒌)��
�𝝍𝝍 Eq. 45
𝝉𝝉𝟏𝟏 + 𝑻𝑻𝒔𝒔 𝒔𝒔𝒔𝒔
𝝉𝝉𝟏𝟏
� 𝒔𝒔𝒔𝒔 (𝒌𝒌) =
𝝍𝝍 � (𝒌𝒌 − 𝟏𝟏) + 𝑻𝑻𝒔𝒔 �𝒖𝒖𝒔𝒔𝒔𝒔 (𝒌𝒌) − 𝑹𝑹𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 (𝒌𝒌)��
�𝝍𝝍 Eq. 46
𝝉𝝉𝟏𝟏 + 𝑻𝑻𝒔𝒔 𝒔𝒔𝒔𝒔
𝑳𝑳𝒓𝒓
� 𝒓𝒓𝒓𝒓 (𝒌𝒌) =
𝝍𝝍 � (𝒌𝒌) − 𝝈𝝈L𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 (𝒌𝒌)�
�𝝍𝝍 Eq. 47
𝑳𝑳𝒎𝒎 𝒔𝒔𝒔𝒔
𝑳𝑳𝒓𝒓
� 𝒓𝒓𝒓𝒓 (𝒌𝒌) =
𝝍𝝍 � (𝒌𝒌) − 𝝈𝝈𝝈𝝈𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 (𝒌𝒌)�
�𝝍𝝍 Eq. 48
𝑳𝑳𝒎𝒎 𝒔𝒔𝒔𝒔
This rotor flux estimation is used to calculate the final RFO output rotor flux angle 𝜃𝜃𝜓𝜓𝑟𝑟 estimate,
according to this equation:
� 𝒓𝒓𝒓𝒓
𝝍𝝍
𝜽𝜽𝝍𝝍𝒓𝒓 = 𝒂𝒂𝒂𝒂𝒂𝒂𝒂𝒂𝒂𝒂𝒂𝒂 � � Eq. 49
� 𝒓𝒓𝒓𝒓
𝝍𝝍

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


14 NXP Semiconductors
ACIM field-oriented control

The stator model is sufficiently robust and accurate at higher frequencies. These two deficiencies can
degrade this model as the speed reduces: the integration problem, and the model’s sensitivity to the
stator resistance mismatch.

3.1.2. Current model rotor flux observer


The rotor model is derived from the differential equation of the rotor winding. It can be either
implemented in the stator coordinates, the field coordinates, or the rotor coordinates. The model used in
this design is inferred in the synchronous 𝑑𝑑𝑑𝑑 reference frame, rotating at the speed 𝜔𝜔𝑟𝑟 . When applying
the field-oriented control assumption 𝜓𝜓𝑟𝑟𝑟𝑟 = 0 to Eq. 35, the rotor flux estimate is:
𝒅𝒅𝝍𝝍𝒓𝒓𝒓𝒓 𝟏𝟏 𝑳𝑳𝒎𝒎
=− 𝝍𝝍𝒓𝒓𝒓𝒓 + 𝒊𝒊 , Eq. 50
𝒅𝒅𝒅𝒅 𝝉𝝉𝒓𝒓 𝝉𝝉𝒓𝒓 𝒔𝒔𝒔𝒔

Using the Euler’s discretization method with the sampling time 𝑇𝑇𝑠𝑠 , the current model rotor flux
estimator is obtained:
𝝉𝝉𝒓𝒓 𝑳𝑳𝒎𝒎
𝝍𝝍𝒓𝒓𝒓𝒓 (𝒌𝒌) = �𝝍𝝍𝒓𝒓𝒓𝒓 (𝒌𝒌 − 𝟏𝟏) + 𝑻𝑻𝒔𝒔 𝒊𝒊 (𝒌𝒌)� Eq. 51
𝝉𝝉𝒓𝒓 + 𝑻𝑻𝒔𝒔 𝝉𝝉𝒓𝒓 𝒔𝒔𝒔𝒔
The accuracy of the rotor model estimator depends on correct model parameters, especially the rotor
time constant 𝜏𝜏𝑟𝑟 .

3.2. Rotor speed estimation


The Model Reference Adaptive System (MRAS) observer uses the redundancy of two mutually
independent machine models of different structures, which estimate the same state variable based on
different sets of input variables. The block diagram of the MRAS speed estimator is shown in this
figure:

Figure 12. MRAS speed estimator

The RFO described in Section 3.1, “Rotor flux observer” serves as the reference rotor flux model. The
adaptive model is based on Eq. 35 and operates in the 𝑑𝑑𝑑𝑑 synchronous rotating reference frame,
according to this equation:
Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017
NXP Semiconductors 15
ACIM field-oriented control

���⃗
� 𝒓𝒓𝒓𝒓𝒓𝒓
𝒅𝒅𝝍𝝍 𝟏𝟏 𝑳𝑳
= − ���⃗ � 𝒓𝒓 ���⃗
� 𝒓𝒓𝒓𝒓𝒓𝒓 + 𝒋𝒋𝝎𝝎
𝝍𝝍 � 𝒓𝒓𝒓𝒓𝒓𝒓 + 𝒎𝒎 𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔
𝝍𝝍 Eq. 52
𝒅𝒅𝒅𝒅 𝝉𝝉𝒓𝒓 𝝉𝝉𝒓𝒓

The phase angle between the two rotor flux vectors 𝜓𝜓��⃗𝑟𝑟𝑟𝑟𝑟𝑟

and 𝜓𝜓��⃗𝑟𝑟𝑟𝑟𝑟𝑟
′′
, estimated by the reference and
adaptive model observers, is compensated by the PI controller that sets the estimated rotor speed 𝜔𝜔 �𝑟𝑟 for
the adaptive model. The control error for this PI controller is calculated as a cross-product of two
estimated fluxes:

𝒆𝒆𝑴𝑴𝑴𝑴𝑴𝑴𝑴𝑴 = ���⃗
𝝍𝝍 ���⃗
� ′𝒓𝒓𝒓𝒓𝒓𝒓 ×𝝍𝝍
� ′′ � ′ � ′′ � ′ � ′′
𝒓𝒓𝒓𝒓𝒓𝒓 = 𝝍𝝍𝒓𝒓𝒓𝒓 𝝍𝝍𝒓𝒓𝒓𝒓 − 𝝍𝝍𝒓𝒓𝒓𝒓 𝝍𝝍𝒓𝒓𝒓𝒓
Eq. 53

3.3. Max Torque Per Ampere


Max Torque Per Ampere (MTPA) is a simple loss-model-based power-optimizing strategy to select the
required value of the d-axis current and the rotor flux amplitude. As the name suggests, its goal is to
obtain the maximal torque with the given stator current amplitude. It is based on Eq. 39, which can be
rewritten as:
𝟑𝟑 𝑳𝑳𝟐𝟐𝒎𝒎 𝟑𝟑 𝑳𝑳𝟐𝟐𝒎𝒎 𝟑𝟑 𝑳𝑳𝟐𝟐𝒎𝒎
𝑻𝑻 = 𝑷𝑷𝒑𝒑 𝒊𝒊𝒔𝒔𝒔𝒔 𝒊𝒊𝒔𝒔𝒔𝒔 = 𝑷𝑷𝒑𝒑 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝑰𝑰 = 𝑷𝑷𝒑𝒑 �𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 � 𝒔𝒔𝒔𝒔𝒔𝒔 𝜽𝜽𝑰𝑰 , Eq. 54
𝟐𝟐 𝑳𝑳𝒓𝒓 𝟒𝟒 𝑳𝑳𝒓𝒓 𝟒𝟒 𝑳𝑳𝒓𝒓

where 𝜃𝜃𝐼𝐼 is the angle of the current vector 𝚤𝚤⃗𝑠𝑠𝑠𝑠𝑠𝑠 . The optimal current angle is then calculated as:
𝒅𝒅𝒅𝒅 𝟑𝟑 𝑳𝑳𝟐𝟐𝒎𝒎 𝝅𝝅
= 𝑷𝑷𝒑𝒑 �𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 � 𝒄𝒄𝒄𝒄𝒄𝒄 𝜽𝜽𝑰𝑰 = 𝟎𝟎 → 𝜽𝜽𝑰𝑰 = , Eq. 55
𝒅𝒅𝜽𝜽𝑰𝑰 𝟐𝟐 𝑳𝑳𝒓𝒓 𝟒𝟒

According to MTPA, the components of the stator current vector in the 𝑑𝑑𝑑𝑑 reference frame should be
simply equal.
The power equation for ACIM is:
𝟐𝟐
𝑷𝑷𝒊𝒊𝒊𝒊 = 𝑷𝑷𝑪𝑪𝑪𝑪 + 𝑷𝑷𝒍𝒍𝒍𝒍𝒍𝒍𝒍𝒍 + 𝑷𝑷𝒐𝒐𝒐𝒐𝒐𝒐 = 𝑹𝑹𝒔𝒔 �𝒊𝒊⃗𝒔𝒔𝒔𝒔𝒔𝒔 � + 𝑷𝑷𝒍𝒍𝒍𝒍𝒍𝒍𝒍𝒍 + 𝑻𝑻𝝎𝝎𝒎𝒎 , Eq. 56

where 𝑃𝑃𝑖𝑖𝑖𝑖 is the input electrical power, 𝑃𝑃𝐶𝐶𝐶𝐶 is the Joule loss in the stator, 𝑃𝑃𝑜𝑜𝑜𝑜𝑜𝑜 is the output mechanical
power, and 𝑃𝑃𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 is the remaining power loss including the core losses, the Joule losses in the rotor, and
the stray losses. Notice that selecting 𝑖𝑖𝑠𝑠𝑠𝑠 = 𝑖𝑖𝑠𝑠𝑠𝑠 minimizes the stator joule losses. While the overall
power losses 𝑃𝑃𝐶𝐶𝐶𝐶 + 𝑃𝑃𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 are not minimized by such selection, the stator Joule losses form the majority
of the overall losses and their minimization improves the power efficiency significantly.
The output d-axis stator current must be limited. The upper limit 𝑖𝑖𝑠𝑠𝑠𝑠,𝑚𝑚𝑚𝑚𝑚𝑚 is set so that the stator current
amplitude �𝚤𝚤⃗𝑠𝑠𝑠𝑠𝑠𝑠 � does not exceed the maximal stator current amplitude 𝐼𝐼𝑚𝑚𝑚𝑚𝑚𝑚 (usually the nominal
current), which means 𝑖𝑖𝑠𝑠𝑠𝑠,𝑚𝑚𝑚𝑚𝑚𝑚 = 𝐼𝐼𝑚𝑚𝑚𝑚𝑚𝑚 /√2. When the available stator voltage 𝑈𝑈𝑚𝑚𝑚𝑚𝑚𝑚 is lower than the
nominal voltage 𝑈𝑈𝑁𝑁 and the nominal speed must remain reachable, the maximal d-axis stator current can
be calculated as:
𝑼𝑼𝒎𝒎𝒎𝒎𝒎𝒎
𝒊𝒊𝒔𝒔𝒔𝒔,𝒎𝒎𝒎𝒎𝒎𝒎 ≅ , Eq. 57
𝟐𝟐𝝅𝝅𝑳𝑳𝒎𝒎 𝒇𝒇𝑵𝑵

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


16 NXP Semiconductors
ACIM field-oriented control

where 𝑓𝑓𝑁𝑁 is the nominal frequency. The other upper 𝑖𝑖𝑠𝑠𝑠𝑠,𝑚𝑚𝑚𝑚𝑚𝑚 limitations may be set by the
flux-weakening algorithms (see Section 3.4, “Flux weakening”). The lower limit 𝑖𝑖𝑠𝑠𝑠𝑠,𝑚𝑚𝑚𝑚𝑚𝑚 has only one
particular restriction, which is keeping the sufficient rotor flux amplitude level for the RFO to function
properly (very low signal levels lead to problems with noise, rounding, and parameter uncertainty). The
final stator current trajectory is shown in this figure:

Figure 13. Max torque per ampere principle

There are two issues to note. As mentioned in Section 3, “ACIM field-oriented control”, FOC is based
on the assumption that the d-axis rotor flux is constant (d𝜓𝜓𝑟𝑟𝑟𝑟 /d𝑡𝑡 = 0) and the 𝑖𝑖𝑠𝑠𝑠𝑠 is constant as well.
While it is preferable to keep this condition true for high-dynamic applications, a slow change of the
d-axis current causes only minimal effect. It is recommended to use a low-pass filter on the d-axis stator
current required value or set a slower d-axis current control loop bandwidth to prevent too fast d-axis
current changes. Another issue is that, without an adequate compensation, the d-axis current level affects
the speed loop gain which is no longer constant. This causes a variation of the transient speed response.

3.4. Flux weakening


Notice from equations Eq. 36 and Eq. 37 that, unlike the 𝑢𝑢𝑠𝑠𝑑𝑑 voltage, the 𝑢𝑢𝑠𝑠𝑠𝑠 voltage contains the
product of the electrical speed and rotor flux 𝜔𝜔𝑒𝑒 𝜓𝜓𝑟𝑟𝑟𝑟 , which raises very quickly and increases the speed.
At a certain point (with the nominal flux it is the nominal speed) it is no longer possible to increase the
speed due to the voltage limitation. However, it is possible to decrease the rotor flux amplitude, which
lowers the 𝜔𝜔𝑒𝑒 𝜓𝜓𝑟𝑟𝑟𝑟 element and allows for further acceleration. The Flux-Weakening (FW) algorithms are
therefore being implemented to enable the above-nominal-speed operations. However, this has a
downside. According to Eq. 39, lowering the rotor flux amplitude leads to the loss of the maximum
available torque, which drops inversely to speed 𝜔𝜔𝑒𝑒 . The below-flux-weakening speed region is
therefore sometimes called the constant torque mode, and the flux-weakening speed region is called the
constant power mode.
There are various flux-weakening strategies. This design implements the FW algorithms based on the PI
controller, which maintains the 𝑖𝑖𝑠𝑠𝑠𝑠 current at the required value (and with it the 𝜓𝜓𝑟𝑟𝑟𝑟 rotor flux) so that
the 𝑢𝑢𝑠𝑠𝑠𝑠 voltage is always kept below the maximum available voltage. The block diagram of the
implemented FW algorithm is shown in this figure:

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 17
ACIM field-oriented control

Figure 14. Flux-weakening algorithm

3.5. Space vector modulation


The standard technique of output voltage generation uses the inverse Clarke transformation to obtain the
3-phase values. The duty cycles (needed to control the power stage switches) are then calculated using
the phase voltage values. However, the Space Vector Modulation (SVM) is more straightforward, as it
can transform the stator voltage vector in the stationary 𝛼𝛼𝛼𝛼 coordinate system directly into the Pulse
Width Modulation (PWM) signals (duty-cycle values). The basic principle of the standard space vector
modulation technique is explained using the power stage schematic diagram shown in this figure:

Figure 15. Power stage schematic diagram

There are eight possible switching states (vectors) on such 3-phase power stage configuration. They are
given by the combinations of the corresponding power switches 𝑆𝑆𝐴𝐴 , 𝑆𝑆𝐵𝐵 , and 𝑆𝑆𝐶𝐶 . The combinations of the
ON/OFF states in the power stage switches for each voltage vector are listed in the following table.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


18 NXP Semiconductors
ACIM field-oriented control

For each phase, a value of one means that the upper switch (𝑆𝑆𝐴𝐴𝐴𝐴 , 𝑆𝑆𝐵𝐵𝐵𝐵 , or 𝑆𝑆𝐶𝐶𝐶𝐶 ) is ON and the bottom
switch (𝑆𝑆𝐴𝐴𝐴𝐴 , 𝑆𝑆𝐵𝐵𝐵𝐵 , or 𝑆𝑆𝐶𝐶𝐶𝐶 ) is OFF. A value of zero means that the upper switch is OFF and the bottom
switch is ON. The resulting instantaneous output line-to-line voltages, phase voltages, and voltage
vectors for all states are listed in this table as well:
Table 1. Switching patterns and resulting instantaneous line-to-line phase voltages

𝑺𝑺𝑨𝑨 𝑺𝑺𝑩𝑩 𝑺𝑺𝑪𝑪 𝒖𝒖𝒔𝒔𝒔𝒔 𝒖𝒖𝒔𝒔𝒔𝒔 𝒖𝒖𝒔𝒔𝒔𝒔 𝒖𝒖𝒔𝒔𝒔𝒔𝒔𝒔 𝒖𝒖𝒔𝒔𝒔𝒔𝒔𝒔 𝒖𝒖𝒔𝒔𝒔𝒔𝒔𝒔 Vector
0 0 0 0 0 0 0 0 0 𝑂𝑂000
1 1 1 2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈0
R

1 1 0 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈60


0 1 0 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 𝑈𝑈120
0 1 1 −2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈180
0 0 1 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈240
1 0 1 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −2𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 −𝑈𝑈𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷𝐷 /3 0 𝑈𝑈300
1 1 1 0 0 0 0 0 0 𝑂𝑂111

The graphical representation of all combinations is shown in this figure:

Figure 16. Basic space vectors and voltage vector projection

There are six non-zero vectors 𝑈𝑈𝑥𝑥 ∈ 〈𝑈𝑈0 , 𝑈𝑈60 , 𝑈𝑈120 , 𝑈𝑈180 , 𝑈𝑈240 , 𝑈𝑈300 〉 and two zero vectors (𝑂𝑂000 and
𝑂𝑂111 ) defined in the 𝛼𝛼𝛼𝛼 coordinates. The six non-zero vectors also delimit the six sectors in which the
desired voltage vector 𝑢𝑢 �⃗𝑠𝑠𝑠𝑠𝑠𝑠 can be located. This 𝑢𝑢
�⃗𝑠𝑠𝑠𝑠𝑠𝑠 voltage vector is then created by applying the
sector base vectors (𝑈𝑈𝑥𝑥 and 𝑈𝑈𝑥𝑥±60 ) and the zero vectors (𝑂𝑂000 or 𝑂𝑂111 ) in such way that the average
vector of the PWM period 𝑇𝑇𝑃𝑃𝑃𝑃𝑃𝑃 is equal to the desired voltage vector. This means:
�⃗𝒔𝒔𝒔𝒔𝒔𝒔 = 𝑻𝑻𝟏𝟏 𝑼𝑼𝒙𝒙 + 𝑻𝑻𝟐𝟐 𝑼𝑼𝒙𝒙±𝟔𝟔𝟔𝟔 + 𝑻𝑻𝟎𝟎 (𝟎𝟎𝟎𝟎𝟎𝟎𝟎𝟎 𝒗𝒗 𝟎𝟎𝟏𝟏𝟏𝟏𝟏𝟏 )
𝑻𝑻𝑷𝑷𝑷𝑷𝑷𝑷 𝒖𝒖 Eq. 58

𝑻𝑻𝑷𝑷𝑷𝑷𝑷𝑷 = 𝑻𝑻𝟏𝟏 + 𝑻𝑻𝟐𝟐 + 𝑻𝑻𝟎𝟎 Eq. 59

To solve the time periods 𝑇𝑇0 , 𝑇𝑇1 , and 𝑇𝑇2 , the space voltage vector 𝑢𝑢
�⃗𝑠𝑠𝑠𝑠𝑠𝑠 must be decomposed into the
directions of the current sector base vectors 𝑈𝑈𝑥𝑥 and 𝑈𝑈𝑥𝑥±60 .

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 19
Software design

The SVM technique calculation consists of these steps:


1. Sector identification.
2. Space voltage vector decomposition into directions of sector base vectors 𝑈𝑈𝑥𝑥 , 𝑈𝑈𝑥𝑥±60 .
3. PWM duty cycle calculation.
This method provides the greatest variability in arranging the zero and non-zero vectors during the
PWM period. The vectors can be arranged to lower the switching losses or to reach different pulse
alignments, such as the center-aligned PWM, the edge-aligned PWM, and so on.

4. Software design
The basic steps of the FOC calculation are described in Section 3, “ACIM field-oriented control”. This
section provides more detailed information about the design of the ACIM FOC software and specific
issues, such as the numerical scaling in fixed-point fractional arithmetic, current sensing, prioritizing of
tasks, and the control state machines.
The ACIM FOC algorithm overview is provided in Figure 17. ACIM is an electro-mechanical system.
The electrical part of this system (described by the equivalent circuit in Section 2.1, “The equivalent
circuit of induction motor”) contains relatively very short time constants, and therefore the control of the
stator currents and the estimation of the rotor flux requires the short sampling time periods 𝑇𝑇𝑆𝑆 (usually
selected in order of 10-4 s). On the other hand, the mechanical part (described by the differential
equation Eq. 26) is usually represented by a system with much longer time constants, its control does not
require such a short sampling time, and it is calculated with the slow period 𝑇𝑇𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 . Thus, the
motor-control application can be divided into:
• Fast control loop—a high-priority task that executes these basic operations and algorithms every
𝑇𝑇𝑆𝑆 :
— Phase-current and DC-Bus voltage ADC sensing
The ADC sampling is synchronized with the PWM module using the trigger signals. A
digital filter is applied to the sampled values of the DC-Bus voltage. The phase currents
are used unfiltered. The 3-phase motor current is reconstructed from two samples taken at
the inverter’s shunt resistors. The ADC sensing and synchronization is described in more
detail later on in this document and in Sensorless ACIM Field-Oriented Control on
Kinetis® KV and KE (document AN5051) for specific peripherals .
— Clark and Park transformations
Used for transformations between different reference frames, as explained in
Section 2.2.1, “Space vector theory”.
— Rotor flux position observer and rotor speed MRAS estimator
Both algorithms are more closely described in Section 3.1, “Rotor flux observer” and
Section 3.2, “Rotor speed estimation”.
— Stator current PI controllers
The direct and quadrature axis stator currents are controlled using the PI controllers. The
direct axis voltage is limited as 𝑢𝑢𝑠𝑠𝑠𝑠 < 𝑈𝑈𝑚𝑚𝑚𝑚𝑚𝑚 and the quadrature voltage as
2
𝑢𝑢𝑠𝑠𝑠𝑠 < �𝑈𝑈𝑚𝑚𝑚𝑚𝑚𝑚 2
− 𝑢𝑢𝑠𝑠𝑠𝑠 . The maximum available stator voltage amplitude is reconstructed
based on the DC-Bus voltage measurement.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


20 NXP Semiconductors
Software design

— Voltage vector modulation using the SVM


The required duty cycles for the PWM periphery are calculated according to the standard
space vector modulation (see Section 3.5, “Space vector modulation”).
• Slow control loop—a lower-priority task that executes these operations and algorithms every
𝑇𝑇𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 :
— Speed S-ramp and speed loop PI controller
The speed command 𝑁𝑁𝑚𝑚_𝑟𝑟𝑟𝑟𝑟𝑟 , entered from the higher-level application layer, is processed
by means of the S-ramp speed algorithm, which limits the acceleration (the first speed
derivative) and jerk (the second speed derivative). The comparison of the actual speed
command and the measured speed generates a speed error for the speed PI controller,
which generates the required value of the torque-producing component of the stator
current.
— Max torque per ampere algorithm and flux-weakening algorithm
The flux-producing current is controlled by a combination of the MTPA power
optimization law (see Section 3.3, “Max Torque Per Ampere”) and the flux-weakening
algorithm to access the higher-speed operation.
Both the fast and slow control loops execute their slow and fast motor-control state machines, which
ensures that a correct state and sub-state machine logic and a correct control algorithm are called. More
details about the structure and execution of the fast and slow control tasks can be found in this section.

Figure 17. ACIM FOC software overview

This application is written as a simple C project with the inclusion of the Real-Time Control Embedded
Software Libraries (RTCESL) written in the assembly language. Beside the data types, math functions,
controllers, and filters used in the application, the library also contains these algorithms:

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 21
Software design

• AMCLIB_ACIMRotFluxObsrv—rotor flux observer (see Section 3.1, “Rotor flux observer”)


• AMCLIB_ACIMSpeedMRAS—MRAS type speed estimator (see Section 3.2, “Rotor speed
estimation”)
• AMCLIB_CtrlFluxWkng—flux-weakening algorithm (see Section 3.4, “Flux-weakening”)
• GMCLIB_SvmStd—standard space vector modulation (see Section 3.5, “Space vector
modulation”)
For more information about these implementations and to download the latest version of RTCESL, visit
www.nxp.com/rtcesl.

4.1. Data types


These data types are defined in the RTCESL libraries and used in the entire application:
• Integer—useful for the general-purpose computation; they are familiar to the MPU and MCU
programmers.
— uint16_t—unsigned 16-bit integer within the 〈0; 65535〉 range and with a resolution of
one.
— int16_t—signed 16-bit integer within the 〈−32768; 32767〉 range and with a resolution
of one.
— uint32_t—unsigned 32-bit integer within the 〈0; 4294967295〉 range and with a
resolution of one.
— int32_t—signed 32-bit integer within the 〈−2147483648; 2147483647〉 range and with
a resolution of one.
• Fractional—enable the implementation of numeric and digital-signal-processing algorithms.
— frac16_t—fixed-point 16-bit fractional within the 〈−1.0; 1.0 − 2−15 〉 range and with a
resolution of 2-15.
— frac32_t—fixed-point 32-bit fractional within the 〈−1.0; 1.0 − 2−31 〉 range and with a
resolution of 2-31.
• Accumulator—combination of both the integer and fractional data types; it has both the integer
and fractional portions.
— acc16_t—fixed-point 16-bit accumulator within the 〈−256.0; 256.0 − 2−15 〉 range and
with a resolution of 2-15.
— acc32_t—fixed-point 32-bit accumulator within the 〈−65536.0; 65536.0 − 2−31 〉 range
and with a resolution of 2-31.
• Floating-point—capable of storing real numbers in wide dynamic ranges. This type is
represented by binary digits and an exponent. The exponent enables scaling of numbers from
extremely small numbers to extremely big numbers. Because the exponent takes part of the type,
the overall resolution of the number is reduced when compared to the fixed-point type of the
same size.
— float_t—floating-point 32-bit single precision within the ±3.4 ∙ 1038 range.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


22 NXP Semiconductors
Software design

4.2. Scaling of analog quantities


The measurement results provided by the ADC periphery must be scaled to obtain the number that
represents the measured quantity in the form required for further processing by the FOC algorithms.
This equation shows the relationship between the real and fractional representations:
𝑹𝑹𝑹𝑹𝑹𝑹𝑹𝑹 𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗
𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭𝑭 𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗𝒗 = , Eq. 60
𝑵𝑵𝑵𝑵𝑵𝑵𝑵𝑵

where:
• Fractional value is a dimensionless fractional representation of a given quantity.
• Real value is the real quantity in physical units.
• Norm is the maximum defined quantity value used for scaling in physical units.
The following subsections provide examples of scaling of different quantities used by the ACIM FOC.

4.2.1. Voltage scale


Voltage is generally measured on the voltage resistor divider by the ADC. The maximum voltage scale
is proportional to the maximum ADC input voltage range. In this example, the maximum voltage is
𝑉𝑉𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 = 472 V. This example shows the calculation of a 16-bit fractional variable representation of
voltage 𝑉𝑉𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚 = 352 V:
𝑽𝑽𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎 𝟑𝟑𝟑𝟑𝟑𝟑
𝒇𝒇𝒇𝒇𝒇𝒇𝒇𝒇𝟏𝟏𝟏𝟏_𝒕𝒕 𝒇𝒇𝟏𝟏𝟏𝟏𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽 = = = 𝟎𝟎. 𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕 Eq. 61
𝑽𝑽𝒏𝒏𝒏𝒏𝒏𝒏𝒏𝒏 𝟒𝟒𝟒𝟒𝟒𝟒
This 16-bit fractional variable is stored internally as a 16-bit integer variable:

𝒊𝒊𝒊𝒊𝒊𝒊𝟏𝟏𝟏𝟏_𝒕𝒕 𝒊𝒊𝟏𝟏𝟏𝟏𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽 = 𝒇𝒇𝟏𝟏𝟏𝟏𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽 ∙ 𝟐𝟐𝟏𝟏𝟏𝟏 = 𝟎𝟎. 𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕. 𝟐𝟐𝟏𝟏𝟏𝟏 Eq. 62


= 𝟐𝟐𝟐𝟐𝟐𝟐𝟐𝟐𝟐𝟐
The following figure illustrates the previous equations of voltage scaling into an integer number. If you
need a floating-point representation of this value, the fractional number is converted to a float number
as:
𝑽𝑽𝒏𝒏𝒏𝒏𝒏𝒏𝒏𝒏
𝒇𝒇𝒇𝒇𝒇𝒇𝒇𝒇𝒇𝒇_𝒕𝒕 𝒇𝒇𝒇𝒇𝒇𝒇𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽 = 𝒇𝒇𝟏𝟏𝟏𝟏𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽 Eq. 63
𝟐𝟐𝟏𝟏𝟏𝟏

Figure 18. Voltage measurement scaling

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 23
Software design

4.2.2. Current scale


Current is generally measured as a voltage drop on the shunt resistors and amplified by an operational
amplifier. If you need both the positive and negative currents, the amplified signal has an offset. The
offset is generally half of the ADC range. The maximum current scale is proportional to a half of the
maximum ADC input voltage range (see the following figure). The manipulation with the current
variable is similar to the voltage variable manipulation shown in Section 4.2.1, “Voltage scale”.

Figure 19. Current measurement scaling

4.2.3. Angle scale


The angles (such as the rotor flux position) are represented as a fixed-point, 32-bit accumulator number,
where the lower 16 bits are in the ⟨−1.0; 1.0) range, which corresponds to the angle in the ⟨−𝜋𝜋; 𝜋𝜋) range.
In a 16-bit signed integer value, the angle is represented as ⟨0x8000; 0x7FFF⟩. It is beneficial not to
express angles in the floating-point representation, because the overflow of a fractional number
representation automatically gives a correct result, which again falls into the ⟨−𝜋𝜋; 𝜋𝜋) range. The integer
part of the accumulator variable holds the number of revolutions, which can be easily converted to the
average speed information.

4.3. Motor-control algorithms synchronization


The timing and synchronization example is shown in the following figure. The motor-control algorithms
are synchronized with the PWM periphery module, which sets the duty-cycle signals for the inverter
every 𝑇𝑇𝑃𝑃𝑃𝑃𝑃𝑃 period. The PWM periphery usually inserts a short dead time 𝑇𝑇𝐷𝐷𝐷𝐷 to prevent from short
circuit on the DC-Bus. The PWM module triggers the ADC module. In case of the center-aligned PWM,
the trigger must be issued close to the beginning or center of the PWM period to prevent the ADC
measurement during the transistors state change. When the ADC conversion of all the necessary
quantities (phase currents and DC-Bus voltage) is completed, the fast control loop Interrupt Service
Routine (ISR), which calls the fast control loop state machine, is executed. The duty cycles for the next
PWM period in all phases are set at the end of this ISR. The slow control loop ISR, which calls the slow
control loop state machine, is usually triggered by a general timer periphery. All other tasks (such as the
FreeMASTER communication) have lower priorities than the motor-control portion of software (fast
and slow control loops) to enable its synchronized execution.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


24 NXP Semiconductors
Software design

Figure 20. Algorithms synchronization and timing example

4.4. State machines


State machines are used to ensure that the correct state machine logic and control algorithm is called and
that all tasks (execution of fast and slow control loops) are executed properly. This allows for special
cases like software initialization, fault states, motor startup, run, and stop. There are two types of state
machines used in the ACIM FOC design. The first one is the main state machine, which handles general
motor-control states like run or stop. The second one is the motor-control state machine, which handles
more specific tasks like machine startup, ADC calibration, and other user-defined motor-control states.

4.4.1. Main state machine


The state machine structure is unified for all components of the application and consists of the four main
states (see Figure 21). The states are:
• Fault—the system detected a fault condition and waits until it is cleared.
• Init—initialization of variables.
• Stop—the system is initialized and waiting for the Run command.
• Run—the system is running; it can be stopped by the Stop command.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 25
Software design

There are transition functions between these state functions:


• Init → Stop—the initialization is done, the system is entering the Stop state.
• Stop → Run—the Run command is applied, the system is entering the Run state (if the Run
command is acknowledged).
• Run → Stop—the Stop command is applied, the system is entering the Stop state (if the Stop
command is acknowledged).
• Fault → Stop—the fault flag is cleared, the system is entering the Stop state.
• [Init, Stop, Run] → Fault—a fault condition occurred, the system is entering the Fault state.
The state machine structure uses these flags to switch between the states:
• SM_CTRL_INIT_DONE—when this flag is set, the system goes from the Init state to the Stop
state.
• SM_CTRL_FAULT—when this flag is set, the system goes from any state to the Fault state.
• SM_CTRL_FAULT_CLEAR—when this flag is set, the system goes from the Fault state to the
Init state.
• SM_CTRL_START—this flag informs the system that there is a command to go from the Stop
state to the Run state. The transition function is called; the action must be acknowledged,
because sometimes it can take time before the system is ready to be switched on.
• SM_CTRL_RUN_ACK—this flag acknowledges that the system can proceed from the Stop state
to the Run state.
• SM_CTRL_STOP—this flag informs the system that there is a command to go from the Run
state to the Stop state. The transition function is called; the action must be acknowledged,
because the system must be turned off properly, which can take time.
• SM_CTRL_STOP_ACK—this flag acknowledges that the system can proceed from the Run
state to the Stop state.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


26 NXP Semiconductors
Software design

Figure 21. Main state machine diagram

The implementation of this state machine structure is done in the state_machine.c and .h files. This code
defines the state machine structure:
/* State machine control structure */
typedef struct
{
SM APP_STATE_FCN_T const* psState; /* State functions */
SM_APP_TRANS_FCN_T const* psTrans; /* Transition functions */
SM_APP_CTRL uiCtrl; /* Control flags */
SM_APP_STATE_T eState; /* State */
} SM_APP_CTRL_T;

The four variables used in the code are:


• psState—pointer to the user state machine functions. The particular state machine function from
this table is called when the state machine is in a specific state.
• psTrans—pointer to the user transient functions. The particular transient function is called when
the system goes from one state to another.
• uiCtrl—this variable is used to control the state machine behavior using the above-mentioned
flags.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 27
Software design

• eState—this variable determines the actual state of the state machine.


The user state machine functions are defined in this structure:
/* User state machine functions structure */
typedef struct
{
PFCN_VOID_VOID Fault;
PFCN_VOID_VOID Init;
PFCN_VOID_VOID Stop;
PFCN_VOID_VOID Run;
} SM_APP_STATE_FCNT;

The user transient state machine functions are defined in this structure:
/* User state-transition functions structure*/
typedef struct
{
PFCN_VOID_VOID FaultStop;
PFCN_VOID_VOID InitFault;
PFCN_VOID_VOID InitStop;
PFCN_VOID_VOID StopFault;
PFCN_VOID_VOID StopRun;
PFCN_VOID_VOID RunFault;
PFCN_VOID_VOID RunStop;
} SM_APP_TRANS_FCN_T;

The control flag variable has these definitions:


typedef unsigned short SM_APP_CTRL;
/* State machine control command flags */
#define SM_CTRL_NONE 0x0
#define SM_CTRL_FAULT 0x1
#define SM_CTRL_FAULT_CLEAR 0x2
#define SM_CTRL_INIT_DONE 0x4
#define SM_CTRL_STOP 0x8
#define SM_CTRL_START 0x10
#define SM_CTRL_STOP_ACK 0x20
#define SM_CTRL_RUN_ACK 0x40

The state identification variable has these definitions:


/* Application state identification enum */
typedef enum
{

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


28 NXP Semiconductors
Software design

FAULT = 0,
INIT = 1,
STOP = 2,
RUN = 3,
} SM_APP_STATE_T;

Call the state machine from the code periodically using the following inline function, as shown in the
example for the fast control loop below. This function’s input is the pointer to the state machine
structure described above. This structure is declared and initialized in the code where the state machine
is called:
/* State machine function */
static inline void SM_StateMachineFast(SM_APP_CTRL_T *sAppCtrl)
{
gSM_STATE_TABLE_FAST[sAppCtrl -> eState](sAppCtrl);
}

The particular example of how to initialize and use the state machine structure is described later on in
this document.

4.4.2. Motor state machine


The motor state machines are based on the main state machine structure. The Run state sub-states are
added on top of the main structure to control the motors properly. This is the description of the main
state user functions:
• Fault—the system faces a fault condition and waits until the fault flags are cleared.
• Init—initialization of variables.
• Stop—the system is initialized and waiting for the Run command.
• Run—the system is running and can be stopped by the Stop command. The Run sub-state
functions are called from here.
There are transition functions between these state functions:
• Init → Stop—nothing is processed in this function.
• Stop → Run:
— The duty cycle is initialized to 50 %.
— The PWM output is enabled.
— The current ADC channels are initialized.
— The Calib sub-state is set as the initial Run sub-state.
• Run → Stop:
— The Stop command is applied and the system enters the Stop state (if the Stop command
is acknowledged). The system does not go directly to Stop when it is in a certain Run
sub-state.
• Fault → Stop—nothing is processed in this function.
• [Init, Stop] → Fault:
Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017
NXP Semiconductors 29
Software design

— The PWM output is disabled.


• Run → Fault:
— Certain current and voltage variables are initialized.
— The PWM output is disabled.
The Run sub-states are called when the state machine is in the Run state. The Run sub-state functions
are:
• Calib:
— The current channels ADC offset is calibrated.
— After the calibration time expires, the system is switched to Ready.
— The DC-Bus voltage is measured and filtered.
— The PWM is set to 50 % and its output is enabled.
— The current channel offsets are measured and filtered.
• Ready:
— The PWM is set to 50 % and its output is enabled.
— The current is measured and the ADC channels are set up.
— The DC-Bus voltage is measured.
— Certain variables are initialized.
• Startup:
— The state machine is waiting until a defined level of the flux-producing current 𝑖𝑖𝑠𝑠𝑠𝑠 is
reached.
• Spin:
— The DC-Bus voltage is measured and filtered.
— The currents are measured and the ADC channels are set up.
— The rotor flux estimator function is called and the returned flux position is used for the
FOC algorithm (the rotor flux estimator is executed even with the scalar control mode for
application tuning and debugging).
— The rotor speed and position are calculated.
— The FOC algorithm is called and the PWM is updated.
— The motor spins.
— The speed ramp, the flux-control algorithms (MTPA and flux-weakening), and the speed
PI controller algorithms are called.
— The speed or current command is used.
• Freewheel:
— The PWM output is disabled and the modulo is set to 50 %.
— The current is measured and the ADC channels are set up. The DC-Bus voltage is
measured and filtered.
— The system waits in this sub-state for a certain time, which is generated due to the rotor
inertia (it waits until the rotor stops).
— The system proceeds into the Ready sub-states.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


30 NXP Semiconductors
Software design

Figure 22. Motor Run sub-state diagram

The Run sub-states have transition functions that are called when going from one sub-state to another.
The sub-state transition functions are:
• Calib → Ready
— Calibration is done; entering the Ready state.
• Ready → Startup
— A non-zero speed command was issued.
— Certain variables are initialized (voltage, speed, position).
• Startup → Spin
— Startup elapsed; entering the Spin state.
• Startup → Freewheel
— Zero speed command; entering the Freewheel state.
— Certain variables are initialized (voltage, speed, position).
— The freewheel timer is set up.
• Spin → Freewheel
— Zero speed command issued; entering the Freewheel state.
— Certain variables are initialized (voltage, speed, position).

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 31
Software design

— The freewheel timer is set up.


• Freewheel → Ready
— Zero-speed command; entering the Ready state.
— The PWM output is enabled.
The implementation of this structure of the motor state machine is done in the m1_sm_ref_sol.c and .h
files. Each state is doubled. The states with the Fast suffix are called in the fast control loop ISR and the
states with the Slow suffix are called in the slow loop control loop ISR. However, the state transitions
are not doubled, and the state machine flow is controlled from the fast-loop state machine. The main
state-machine structure is:
The main state user function prototypes are:
static void M1_StateFault(void);
static void M1_StateInit(void);
static void M1_StateStop(void);
static void M1_StateRun(void);

The main state user transient function prototypes are:


static void M1_TransFaultInit(void);
static void M1_TransInitFault(void);
static void M1_TransInitStop(void);
static void M1_TransStopFault(void);
static void M1_TransStopRun(void);
static void M1_TransRunFault(void);
static void M1_TransRunStop(void);

The main state functions table initialization is:


/* State machine functions field */
static const SM_APP_STATE_FCN_T msSTATE = {M1_StateFault, M1_StateInit, M1_StateStop,
M1_StateRun};

The main state transient functions table initialization is:


/* State-transition functions field */
static const SM_APP_TRANS_FCN_T msTRANS = {M1_TransFaultInit, M1_TransInitFault,
M1_TransInitStop, M1_TransStopFault, M1_TransStopRun, M1_TransRunFault,
M1_TransRunStop};

The main state machine structure initialization is:


/* State machine structure declaration and initialization */
SM_APP_CTRL_T gsM1_Ctrl =
{
/* gsM1_Ctrl.psState, User state functions */
&msSTATE,
/* gsM1_Ctrl.psTrans, User state-transition functions */
&msTRANS,

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


32 NXP Semiconductors
Software design

/* gsM1_Ctrl.uiCtrl, Default no control command */


SM_CTRL_NONE,
/* gsM1_Ctrl.eState, Default state after reset */
INIT
};

The Run sub-state machine is declared in a similar way. The Run sub-state identification variable has
these definitions:
typedef enum {
M1_CALIB = 0,
M1_READY = 1,
M1_STARTUP = 2,
M1_SPIN = 3,
M1_FREEWHEEL = 4
} M1_RUN_SUBSTATE_T; /* Run sub-states */

For the Run sub-states, two sets of user functions are defined. The user function prototypes of the Run
sub-states are:
static void M1_StateRunCalib(void);
static void M1_StateRunReady(void);
static void M1_StateRunStartup(void);
static void M1_StateRunSpin(void);
static void M1_StateRunFreewheel(void);

The user transient function prototypes of the Run sub-states are:


static void M1_TransRunCalibReady(void);
static void M1_TransRunReadyStartup (void);
static void M1_TransRunStartupSpin(void);
static void M1_TransRunStartupFreewheel(void);
static void M1_TransRunSpinFreewheel(void);
static void M1_TransRunFreewheelReady(void);

The table initialization of the Run sub-state functions is:


/* Sub-state machine functions field */
static const PFCN_VOID_VOID mM1_STATE_RUN_TABLE[6] = {
M1_StateRunCalib,
M1_StateRunReady,
M1_StateRunStartup,
M1_StateRunSpin,
M1_StateRunFreewheel
};

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 33
Software design

The state machine is called from the fast control loop ISR. The code syntax used to call the state
machine is:
/* StateMachine call */
SM_StateMachine(&gsM1_Ctrl);

Inside the user Run state function, the sub-state functions are called as:
/* Run sub-state function */
mM1_STATE_RUN_TABLE[meM1_StateRun]();

where the variable identifies the Run sub-state.

4.5. ACIM control software implementation


The following figure provides the high-level flowchart of the fast control loop implementation. The fast
control loop mainly executes the stator current control and the position and speed estimation.
The ADC and PWM peripheral access is done through the dedicated modules within the unified
interface called Motor Control Peripheral Drivers (MCDRV). MCDRV provides a hardware abstraction
layer, so the application code is hardware-independent. MCDRV has a low-level hardware-dependent
layer, which depends on the MCU and platform. Find the API of these drivers (including a list of
supported devices) in Sensorless ACIM Field-Oriented Control on Kinetis® KV and KE (document
AN5051). The application is written in a way that allows for a simple future expansion into multi-motor
control applications. All motor control variables are therefore organized into structures.

Figure 23. Fast-loop control flowchart

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


34 NXP Semiconductors
Software design

4.5.1. Field-oriented current control


The inputs of the current control mode are the required direct and quadrature currents. To execute the
FOC current control, call only one function that has one Input/Output (I/O) pointer to the FOC current
control structure. The prototype of the function is:
void MCS_ACIMFocCtrlCurrentA1(MCS_ACIM_FOC_A1_T *psFocACIM)

The inputs to this routine include the 3-phase current, the DC-Bus voltage, the electrical rotor flux
position, and the required 𝑑𝑑𝑑𝑑 currents. The output of this routine is the 3-phase duty cycle, the SVM
sector, and the saturation flags of the PI controllers. The PI controllers and filters have structures that
must be initialized before using this routine.
Example 1. Field-oriented current control code
typedef struct
{
AMCLIB_ACIM_ROT_FLUX_OBSRV_T_FLT sRFO; /* Rotor Flux Observer structure */
AMCLIB_ACIM_SPEED_MRAS_T_FLT sSpdObs; /* MRAS speed observer structure */
GFLIB_CTRL_PI_P_AW_T_FLT sPIParId; /* d-axis current controller */
GFLIB_CTRL_PI_P_AW_T_FLT sPIParIq; /* q-axis current controller */
GDFLIB_FILTER_IIR1_T_FLT sFiltParUDcBus; /* DC-bus voltage filter */
GMCLIB_3COOR_T_F16 sIABCFrac; /* meas. 3-phase current (f16) */
GMCLIB_3COOR_T_FLT sIABC; /* meas. 3-phase current [A] */
GMCLIB_3COOR_T_F16 sDutyABC; /* duty cycles (f16) */
GMCLIB_2COOR_ALBE_T_FLT sIAlBe; /* alpha/Beta current [A] */
GMCLIB_2COOR_DQ_T_FLT sIDQ; /* DQ stator current [A] */
GMCLIB_2COOR_DQ_T_FLT sIDQReq; /* required DQ current [A] */
GMCLIB_2COOR_DQ_T_FLT sIDQErr; /* DQ current error [A] */
GMCLIB_2COOR_ALBE_T_FLT sUAlBe; /* alpha/Beta stator voltage */
GMCLIB_2COOR_ALBE_T_F16 sUAlBeCmpFrac; /* DC-bus ripple elim. voltage */
GMCLIB_2COOR_ALBE_T_FLT sUAlBeDTComp; /* alpha/Beta stator voltage */
GMCLIB_2COOR_DQ_T_FLT sUDQReq; /* req. DQ voltage [V] */
GMCLIB_2COOR_DQ_T_FLT sUDQReqScalar; /* req. DQ scalar voltage [V] */
GMCLIB_2COOR_SINCOS_T_FLT sSCFOC; /* S&C of rotor flux angle [-] */
float_t fltDutyLim; /* max. allowable duty cycle [-] */
float_t fltUDcBus; /* DC-bus voltage [V] */
float_t fltUDcBusFilt; /* filtered DC-bus voltage [V] */
frac16_t f16UDcBus; /* DC-bus voltage (FRAC16) */
uint16_t ui16SectorSVM; /* SVM sector (sector) */
bool_t bFlagPIIdStopInt; /* d-axis PI ctrl stop int. flag */
bool_t bFlagPIIqStopInt; /* q-axis PI ctrl stop int. flag */
bool_t bFlagSpdStart; /* motor startup flag */
bool_t bFlagDTComp; /* dead-time compensation ctrl */
} MCS_ACIM_FOC_A1_T;

Example 1 shows the field-oriented current control structure content. This structure encapsulates all the
necessary variables or sub-structures for the field-oriented control algorithm implementation. The data
types used in this structure are defined in RTCESL. Here is the description of items used in this
application:
• Rotor flux observer—input structure for the rotor flux observer function.
• Speed estimator—input structure for the speed estimator structure.
• 𝑑𝑑 and q-axis current PI controllers—used to control the direct and quadrature current.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 35
Software design

• DC-Bus voltage first order IIR filter—used to filter the DC-Bus voltage.
• Phase currents—measured 3-phase current; input to the algorithm.
• Alpha and beta currents—currents transformed into the 𝛼𝛼𝛼𝛼 frame.
• 𝑑𝑑𝑞𝑞 currents—currents transformed into the 𝑑𝑑𝑑𝑑 frame.
• Required 𝑑𝑑𝑑𝑑 currents—currents required in the 𝑑𝑑𝑑𝑑 frame; input to the algorithm.
• 𝑑𝑑𝑞𝑞 current error—error (difference) between the required and measured 𝑑𝑑𝑑𝑑 currents.
• Phase duty cycles—3-phase duty cycles; output from the algorithm.
• Required alpha and beta voltages—voltages required in the 𝛼𝛼𝛼𝛼 frame.
• Required 𝛼𝛼𝛼𝛼 voltages after the dead time compensation—voltages required in the 𝛼𝛼𝛼𝛼 frame with
the compensation of the inverter non-linearity.
• Compensated required alpha and beta voltages—the previous item recalculated on the actual
level of the DC-Bus voltage.
• Required 𝑑𝑑𝑑𝑑 voltages—voltages required in the alpha/beta frame; outputs from the PI
controllers.
• Sin & Cos angle—sine and cosine of the rotor flux electrical angle.
• Duty-cycle limit—this variable limits the maximum value of the phase duty cycles.
• DC-Bus voltage—measured DC-Bus voltage.
• Filtered DC-Bus voltage—filtered value of the previous item.
• SVM sector—sector information; output from the SVM algorithm.
• 𝑑𝑑-axis current saturation flag—saturation flag for the 𝑑𝑑-axis current PI controller.
• 𝑞𝑞-axis current saturation flag—saturation flag for the 𝑞𝑞-axis current PI controller.
• Speed startup flag—indicates that the motor is in the startup.
• Dead-time compensation flag—dead-time compensation enable (true) and disable (false) flag.

4.5.2. Scalar control


The scalar control (V/Hz) is another control function. It is implemented for the tuning and debugging
purposes. Similar to the previous algorithms, this control mode is optimized into one function, which has
two input/output pointers to a structure. The prototype of the function is:
void MCS_ACIMOpenLoopScalarCtrlA1(MCS_ACIM_FOC_A1_T *psFocACIM, MCS_SCALAR_A1_T
*psScalarACIM)

The first structure referred to by the I/O structure pointer is the same as for the current control mode
described in the previous section. The second structure has the scalar control variables defined in this
example:
Example 2. Scalar control structure
typedef struct
{
GFLIB_RAMP_T_FLT sRampParSpdMe; /* scalar speed ramp structure */
float_t fltSpdMeReq; /* speed command [rpm] */
float_t fltSpdMeRamp; /* speed command ramped [rpm] */

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


36 NXP Semiconductors
Software design

float_t fltPosEl; /* scalar position [rad]*/


float_t fltGainSpdMe2PosEl; /* scalar integration constant */
float_t fltGainRpm2Volt; /* V/rpm constant */
float_t fltUMin; /* minimal stator voltage [V] */
} MCS_SCALAR_A1_T;

This structure contains the additional variables or sub-structures necessary for the scalar control
algorithm implementation. The types used in this structure are defined in RTCESL. Here is a description
of the items used in this application:
• Speed ramp—parameters for the speed ramp generation.
• Speed command—required mechanical speed, commanded by the user application.
• Ramped speed—output from the speed ramp algorithm.
• Scalar position—generated electrical position of the stator voltage.
• Scalar integration gain—integration gain used when integrating speed.
• V/rpm gain—factor to calculate the required q-axis voltage from the mechanical speed.
• Minimal q-axis voltage—minimum phase voltage to produce a sufficient rotor flux.
This routine calculates the q-axis voltage from the actual electrical rotor frequency. The inputs to this
routine are the required mechanical speed and the V/rpm factor. The outputs of this routine are the
3-phase duty cycle and the SVM sector. The filters have structures that must be initialized before using
this routine. This routine is called in the fast-loop state machine.

4.5.3. FOC slow control loop


The speed loop is calculated within the slow control loop ISR in the Spin sub-state of the Run state (the
M1_StateRunSpinSlow function). The structure that contains all necessary speed and flux control
variables is defined in this example:
Example 3. Speed and flux control structure
typedef struct
{
GFLIB_CTRL_BETA_IP_P_AW_T_FLT sPIParSpdMe; /* speed controller structure */
AMCLIB_CTRL_FLUX_WKNG_T_FLT sFluxWkng; /* flux-weakening controller */
GFLIB_FLEXSRAMP_T_FLT sRampParSpdMe; /* speed S-ramp structure */
float_t fltSRampDuration; /* default S-ramp duration */
float_t fltSpdMeFilt; /* filtered mechanical speed [rpm] */
float_t fltSpdMeRamp; /* ramped mechanical speed [rpm] */
float_t fltSpdMeReq; /* required mechanical speed [rpm] */
float_t fltSpdMeErr; /* speed error [rpm] */
float_t fltIdStart; /* speed FOC startup current [A] */
float_t fltIdStartMinPct; /* startup current threshold [%] */
float_t fltIdReqMin; /* d-axis minimal required current */

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 37
Software design

float_t fltIdReqMax; /* q-axis minimal required current */


float_t fltIdMTPA; /* MTPA d-axis current */
float_t fltIdMTPAFiltCoef; /* d-axis current filter */
float_t fltSpdMeReqMax; /* max mechanical req. speed [rpm] */
float_t fltSpdMeReqMin; /* min mechanical req. speed [rpm] */
bool_t bFlagPISpdMeStopInt; /* speed PI ctrl saturation flag */
bool_t bFlagPIFWStopInt; /* flux controller saturation flag */
bool_t bStartupDone; /* startup done flag */
} MCS_SPEED_FLUX_A1_T;

The speed and flux control structure contains these items:


• Speed PI controller structure—controls the rotor speed.
• Flux-weakening controller structure—flux-weakening algorithm.
• Speed S-ramp structure—speed ramp for the acceleration and jerk limitation.
• S-ramp duration—duration of the ramp acceleration (a very low value leads to the maximal set
acceleration).
• Filtered speed—filtered speed of the motor.
• Ramped speed—speed ramp algorithm output.
• Speed command—mechanical speed requested by the user or a higher layer of the application.
• Speed error—error between the required and actual speeds.
• Startup d-axis current—d-axis current during startup.
• Startup d-axis current threshold—d-axis current level to proceed into the Spin sub-state.
• Minimal d-axis current—minimal required d-axis current.
• Maximal d-axis current—maximal required d-axis current.
• MTPA d-axis current—d-axis current calculated by MTPA.
• MTPA d-axis current filter coefficient—MTPA d-axis current exponential filter coefficient.
• Maximal required speed—upper limit of the required speed.
• Minimal required speed—lower limit of the required speed.
• Speed PI controller saturation flag—shows whether the speed PI controller is in saturation.
• Speed PI controller integration flag—determines whether the integral part of the speed controller
should be limited.
• Startup done flag—set when the speed startup is done.
The routine calculates the MTPA and flux-weakening algorithms first to determine the required direct
axis current. The lower output value of both algorithms is used in the end. If the minimal speed was not
reached yet and the motor is still accelerating, the direct axis current is set to its startup value and the
MTAP and flux weakening are not calculated. The speed control process includes the calculation of the
S-ramp, the PI controller integration flag, the speed error, and the speed PI controller itself.

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


38 NXP Semiconductors
Revision history

5. References
For a current list of all documents, see www.nxp.com.
• Real-Time Control Embedded Software Libraries located at www.nxp.com/rtcesl
• Sensorless ACIM Field-Oriented Control on Kinetis® KV and KE (document AN5051)

6. Revision history
The following table summarizes the changes done to this document since the initial release.
Table 2. Revision history
Revision number Date Substantive changes
0 01/2016 Initial release.
1 01/2017 -Added sections on MTPA and FW
algorithms
-Updated graphics

Sensorless ACIM Field-Oriented Control, Design Reference Manual, Rev. 1, 01/2017


NXP Semiconductors 39
How to Reach Us: Information in this document is provided solely to enable system and software
implementers to use NXP products. There are no express or implied copyright licenses
Home Page:
nxp.com granted hereunder to design or fabricate any integrated circuits based on the
information in this document. NXP reserves the right to make changes without further
Web Support:
notice to any products herein.
nxp.com/support
NXP makes no warranty, representation, or guarantee regarding the suitability of its
products for any particular purpose, nor does NXP assume any liability arising out of the
application or use of any product or circuit, and specifically disclaims any and all
liability, including without limitation consequential or incidental damages. “Typical”
parameters that may be provided in NXP data sheets and/or specifications can and do
vary in different applications, and actual performance may vary over time. All operating
parameters, including “typicals,” must be validated for each customer application by
customer’s technical experts. NXP does not convey any license under its patent rights
nor the rights of others. NXP sells products pursuant to standard terms and conditions
of sale, which can be found at the following address:
nxp.com/SalesTermsandConditions.

NXP, the NXP logo, NXP SECURE CONNECTIONS FOR A SMARTER WORLD,
Freescale, the Freescale logo, Kinetis, Tower System, and Freedom are trademarks of
NXP B.V. All other product or service names are the property of their respective
owners. ARM, the ARM Powered logo, Keil, µVsion, and Cortex are registered
trademarks of ARM Limited (or its subsidiaries) in the EU and/or elsewhere. IAR
Embedded Workbench is a registered trademark of IAR Systems. All rights reserved.

© 2016-2017 NXP B.V.

Document Number: DRM150


Rev. 1
01/2017

You might also like