This technical note presents a common control technique for Permanent Magnets Synchronous Machines (PMSM). The Field-Oriented Control (FOC) method orients the stator current vector in a rotating reference frame of the machine.

First, the note introduces the general operating principles of the Field-Oriented Control and then, details a possible design methodology.

Finally, a practical control implementation is introduced, targeting the B-Box RCP or B-Board PRO with the ACG SDK on Simulink.

Software resources

  File Modified
ZIP Archive Requires Matlab Simulink ≥2016a and imperix ACG SDK ≥ Feb 23, 2021 by Julien Orsinger

Note: For PLECS users, a model is available for download in the TN114.

General principles

The Field Oriented Control (FOC) is a form a vector control [1]. The currents, voltages and magnetic fluxes of the machine are expressed as space vectors inside a Rotating Reference Frame (RRF). In the case of a synchronous machine, the stator and rotor fluxes are synchronous [2]. Therefore, a natural choice is to orient the RRF such as its d-axis is aligned with the rotor flux.

The position of the rotor must be known in order to orient the RRF. The position is either measured with an encoder or estimated with a sensorless technique. Both options are presented in PN104 and TN136, respectively.

The working principle of FOC relies on the machine's equations in that RRF. Let us first consider the stator equations of a PMSM in the RRF [2]:

\begin{array}{l}(1) \qquad \begin{cases} \begin{align*} \displaystyle U_{ds} &= R_s I_{ds} + \frac{d \Psi _{ds}}{dt} - \omega _s \Psi _{qs}\\[5pt] \displaystyle U_{qs} &= R_s I_{qs} + \frac{d \Psi _{qs}}{dt} + \omega _s \Psi _{ds}\\[5pt] \displaystyle \Psi _{ds} &= L_d I_{ds} + \Psi _{PM} \\[5pt] \displaystyle \Psi _{qs} &= L_q I_{qs} \end{align*} \end{cases}\end{array}

Let us also consider the expression of the torque [2]:

\begin{array}{l}\displaystyle (2) \qquad T_{em} = \frac{3}{2} p (\Psi _{ds} I_{qs} - \Psi _{qs} I_{ds})\end{array}

The equations from (1) and (2) can be re-arranged as such:

\begin{array}{l}(3) \qquad \begin{cases} \begin{align*} \displaystyle I_{ds}^* &= \frac{\Psi _{ds}^* - \Psi _{PM}}{L_s} \\[5pt] \displaystyle I_{qs}^* &= \frac{T_{em}^*}{\frac{3}{2} p \Psi _{PM}} \end{align*} \end{cases}\end{array}

It appears in equation (3) that the stator flux (d-axis component) and the torque can be controlled independently by the current \begin{array}{l}I_{ds}\end{array} and \begin{array}{l}I_{qs}\end{array}, respectively. The q-axis component of the stator flux is fixed by the torque control, since it proportional to \begin{array}{l}I_{qs}\end{array}.

System-level modeling

The independent control of \begin{array}{l}I_{ds}\end{array} and \begin{array}{l}I_{qs}\end{array}  can consist of two PI regulators with a decoupling network, as any vector control strategy [1]. The FOC algorithm usually generates voltage references that a PWM modulator transforms into gating signals for a voltage source inverter. In the present implementation, the rotor position measurement is derived from an incremental encoder. The figure below shows the complete block diagram of the implementation, with a carrier-based PWM modulator and an encoder/decoder module.
Field oriented control block diagram

Figure 1: FOC block diagram

A more intuitive approach

The d and q axes of a rotating reference frame have a physical meaning in the case of an electrical machine: the d-axis is directly aligned on a rotor magnetic pole and the q-axis is shifted from 90°E (electrical degrees), thus the name quadrature axis. As always, two magnetic poles of opposite polarity are shifted by 180°E.

Direct and quadrature axes
Figure 2: Direct and quadrature axes

If the magnetic poles of the stator are aligned with their opposite poles on the rotor, the system is at equilibrium and the stator flux vector is aligned on the d-axis. Conversely, if the magnetic poles of the stator are not aligned with their opposite counter-part, their attractive and repulsive forces generate a torque on the rotor. In this case, the stator flux is not aligned with the d-axis and the angle difference between the two - commonly called the load angle (or power angle) [3] - is non-zero.

Alignment of the magnetic flux vector


Alignment of the magnetic flux vector

Figure 3: Alignment of the magnetic flux vector: (a) zero torque (b) maximal torque

In summary, the q-axis component of the stator flux contributes to the torque generation and the d-axis component only magnetizes the machine.

Flux and torque control


To control effectively the stator currents generated by the voltage source inverter, the relation between the stator voltages and currents needs to be determined. The phases of a PMSM at the stator being essentially RL circuits, the transfer functions linking the voltage to the current are:

\begin{array}{l}(4) \qquad \begin{cases} \begin{align*} \displaystyle H_d(s) &= \frac{I_{ds}(s)}{U_{ds}(s)} = \frac{1/R_s}{1 + s \space L_d/R_s} = \frac{K_1}{1 + s \space T_1}\\[5pt] \displaystyle H_q(s) &= \frac{I_{qs}(s)}{U_{qs}(s)} = \frac{1/R_s}{1 + s \space L_q/R_s} = \frac{K_2}{1 + s \space T_2} \end{align*} \end{cases}\end{array}


The control of the stator currents can simply consist of two digital PI controllers, followed by some basic mathematical operations to compute the PWM duty cycles. Since the d and q axes are coupled, a decoupling network is necessary in order to achieve independent control of each current components, as developed in TN106.

The PI regulators can be tuned using the magnitude optimum criterion [4][5]:

\begin{array}{l}(5) \qquad \begin{cases} \begin{align*} \displaystyle T_n &= T_1\\[5pt] \displaystyle T_i &= 2 \space K_1 \space T_{tot} \\[5pt] \displaystyle K_p &= T_n \space / \space T_i \\[5pt] \displaystyle K_i &= 1 \space / \space T_i \end{align*} \end{cases}\end{array}

The parameter \begin{array}{l}T_{tot}\end{array} represents the sum of all the small delays in the system. The product note PN142 explains how to determine the total delay of the system. A numerical example is given below.

Flux reference

The FOC is mainly used as a torque controller. Therefore the d-axis current reference is usually set to zero, in order to maximize the torque production [1].

The d-axis current may be set to a non-zero reference when using a flux optimization technique. For example, field weakening techniques reduce the stator flux on the d-axis in order operate above the nominal speed.

B-Box / B-Board implementation

Current controller

The figure below shows a possible implementation of a current controller for FOC with Simulink. One can identify the two PIs for the d and q axes and the decoupling network in-between. The saturation limits of the PIs are set dynamically, depending on the DC bus voltage.

dq current PI controller

Tuning of the PI controllers

Here is a complete numerical example on how to tune the PI controllers of the FOC. The machine parameters are presented in the Experimental results section.

Since the available PMSM is isotropic, the inductance is the same on the d and q axes. Therefore, both PIs have the same following transfer function and the same tuning.

\begin{array}{l}\displaystyle (6) \qquad H_d(s) = H_q(s) = \frac{1/R_s}{1 + s \space L_d/R_s} = \frac{K_1}{1 + s \space T_1} = \frac{0.294 \space \Omega ^{-1}}{1 + s \space 3.57 \,\text{ms}}\end{array}

As explained in the PN142, the execution of the digital control is affected by a delay along the control chain. It can be subdivided into the following delays:

\begin{array}{l}(7) \qquad \begin{cases} \begin{align*} \displaystyle T_{sens} &= 0 \,\text{µs} \\[5pt] \displaystyle T_{ctrl} &= T_s = \frac{1}{20 \, \text{kHz}} = 50 \,\text{µs}\\[5pt] \displaystyle T_{PWM} &= \frac{T_{sw}}{2} = \frac{1}{2 \times 20 \, \text{kHz}} = 25 \,\text{µs} \end{align*} \end{cases}\end{array}

According to the Timing info tab in BB Control, the cycle delay is less than 20% of a sampling period. Since the sampling phase was set to \begin{array}{l}\phi _s = 0.5\end{array}, the condition \begin{array}{l}T_{cy} < (1 - \phi _s) T_s\end{array} is true. That is why the control delay is only 1 switching period.

The total delay is then the sum of the small time constants

\begin{array}{l}\displaystyle (8) \qquad T_{tot} = T_{sens} + T_{ctrl} + T_{PWM} = 75 \,\text{µs}\end{array}

According the magnitude optimum criterion the parameters of the PIs are computed as:

\begin{array}{l}(9) \qquad \begin{cases} \begin{align*} \displaystyle T_n &= T_1 = 3.57 \,\text{ms} \\[5pt] \displaystyle T_i &= 2 \space K_1 \space T_{tot} = 4.41 \times 10^{-5} \,\Omega ^{-1}\,\text{s}\\[5pt] \displaystyle K_p &= T_n \space / \space T_i = 80.95 \,\Omega\\[5pt] \displaystyle K_i &= 1 \space / \space T_i = 22675.7\,\Omega\,\text{s}^{-1} \end{align*} \end{cases}\end{array}

Experimental results

The experimental setup consists of a PMSM supplied by voltage source inverter controlled by a B-Box prototyping controller. The FOC control is implemented using the graphical programming of ACG SDK library for Simulink. The power converter is built from 4x PEB 8032 phase-leg modules (3 phases and 1 braking chopper leg). Another PMSM connected to 3 power resistors is used a brake to generate a load torque.

Programmable drive inverterPower converter and controller

Motor and brake

Motor and brake

Machine parameters

The FOC algorithm was validated experimentally on the following PMSM.

Model: Control techniques 095U2B300BACAA100190




Rated power



Pole pairs



Rated phase voltage



Rated phase current



Rated mechanical speed



Rated torque



Stator resistance



Stator inductance (d and q axis)



Permanent magnet flux



Moment of inertia (PMSM only)


kg cm2

Test conditions

  • Load torque: 3.9 Nm (PMSM with resistors as load)

  • DC link voltage: 500 V

  • Interrupt and sampling frequency: 20 kHz

  • Sampling phase: 0.5

  • PWM outputs: carrier-based

  • Current measurements filtered with a 1.6 kHz cut-off frequency (using the front panel of the B-Box RCP)


The tracking performance of the torque control was validated experimentally by performing a reference step from -1 Nm to 3.9 Nm (nominal torque). The current controllers on both axes can follow their respective references with fast dynamics and no overshoot.

Current tracking performance

The corresponding phase currents are also shown below. Since the current on the d-axis is zero, the q-axis current corresponds to the envelop of the phase currents.

Motor phase currents

Academic references

[1] Nguyen Phung Quang, Jörg-Andreas Dittrich, "Vector Control of Three-Phase AC Machines", Springer, 2015, ISBN 978-3-662-46914-9

[2] Slobodan N. Vukosavic, "Electrical Machines", Springer, 2013, DOI 10.1007/978-1-4614-0400-2

[3] Jan A. Melkebeek, "Electrical Machines and Drives : Fundamentals and Advanced Modelling", Springer, 2018, ISBN 978-3-319-72729-5

[4] Hansruedi Bühler, "Réglage de systèmes d'électronique de puissance - Volume 1: théorie", Presses Polytechniques et Universitaires Romandes, 1997, ISBN-10: 2-88074-341-9

[5] Karl J. Åström and Tore Hägglund; “Advanced PID Control”; 1995