*Permanent Magnet Synchronous Motors (PMSM) and the actual implementation*

*It’s no news that richer performance vector control drives for AC motors could be beneficial, in terms of dynamics and efficiency as well as for every aspect an ideal control should have. The good news is that the time has come to make wide use of these drives, running low-cost applications with first grade quality.*

*By Stello Matteo Billé, Dino Costanzo, Antonio Cucuccio, STMicroelectronics Alfio Consoli, Mario Cacciato, Giuseppe Scarcella, Giacomo Scelba, University of Catania*

This article presents an investigation in the algorithms for sensorless detection of rotor angular position of Permanent Magnet Synchronous Motors (PMSM) and the actual implementation STMicroelectronics has made in its Field Oriented Control (FOC) firmware library developed for its 32-bit Cortex-M3 microcontroller family, the STM32.

Three phase AC motors (induction and synchronous motors) historically owe their greatest success in adjustable speed application to the advent of vector control drives. In particular, Field Oriented Control (FOC) has guaranteed the highest reachable performances, but its scope of employment has always been in costly drives mainly used in the automation and robotics field. In fact, it requires three essential components, in addition to the converter/ inverter electronic stage: intense computational power, accurate sensors for current, and rotor speed/position measurement. For these reasons, in the last decade, low cost applications (white goods, HVAC, industrial, pumps) have appointed induction motors and V/F controls as best compromise for cost containment and target performance.

### This scenario has rapidly changed.

The always stringent requirement of energy efficiency has been complemented, and complicated, by an almost worldwide commitment to environmental sustainability. PMSM sinusoidal motors have consolidated – because of advancements in magnet chemistry and for their reduced copper content - as viable and robust as induction motors. Powerful 32-bit microcontrollers are now offered as a suitable choice in the same cost area of 8-bits, throwing open the doors to implement more advanced control methods, such as FOC. Some of these microcontroller families, such as the STM32, feature fast and precise ADCs and advanced PWM timers designed specifically for motor control, to the extent that the last two cost barriers – current and speed sensors – have now faded. Current feedback can now be achieved using inexpensive shunt resistors, while speed/position sensors have been replaced by mathematical algorithms that bring additional benefits such as improved reliability and reduced circuit complexity and size. Because of this, low-cost motor control drives can finally take advantage of the intrinsic properties of FOC, i.e. closed loop current control (and hence stringent over-current protection, which in turn means a more focused choice of power devices), best efficiency and dynamics (even during transients), and quiet operations.

This article presents an investigation in the algorithms for sensorless detection of rotor angular position of Permanent Magnet Synchronous Motors (PMSM) and the actual implementation STMicroelectronics has made in its Field Oriented Control (FOC) firmware library. Two methods will be shown in details, as representatives of the two categories to which they belong: a flux estimator, and a closed-loop Luenberger’s state observer. They both use the mathematical model of the machine, while the second one also exploits current feedback. The aim is to compare them, on the basis of computational effort, performances, and robustness to parameter variations.

### PMSM equations

With reference to the figure, the motor voltage and flux-linkage equations of a PMSM (isotropic magnetic structure) are generally expressed as:

where :

r_{s} is the stator phase winding resistance

L_{ls} s the stator phase winding leakage inductance

L_{ms} is the stator phase winding magnetizing inductance

θ_{r }is the rotor electrical angle

Φ_{m} is the flux linkage due to permanent magnets

The complexity of these equations is apparent, as the three stator flux linkages are mutually coupled, and what is more, as they are dependent on the rotor position, which is time-varying and a function of the electromagnetic and load torques. The reference frame theory simplifies the PMSM motor equations, by making a change of variables that refers the stator quantities abc (spatially displaced by 120°) to qd components, directed along axes each 90° apart, rotating at an arbitrary speed ω.

### Open-loop flux estimator equations

In particular, if the qd reference frame is stationary (the so-called Clarke transformation on the αβ frame, ω=0) we’ll get to:

where L_{s} is the synchronous inductance, L_{s} = L_{ls} + 3L_{ms}/2, Let’s define the back-EMFs (Electro-Motive Forces) as:

Substituting the flux linkages equations in the voltage equations and solving:

These equations give us the possibility of an open-loop estimation of the rotor flux that goes through known motor parameters and measured terminal voltage and currents. As can be seen, rotor angular position information is held directly and can be extrapolated by means of an arctangent function, recursive algorithm, or PLL (Phase Locked Loop).

Going into time-discrete domain, it gives:

and whose block diagram is depicted below:

### The observer

To understand how a state observer works and why it can be considered a closed loop approach; let’s start from the definition of ‘observability.’ In control theory, a system is said to be ‘observable’ if it is possible to fully reconstruct the system state starting from its output measurements. The ‘state observer’ (or simply the ‘observer’) is then the system that provides the estimation ^X of the observed system internal state (X) given its input (U) and output (Y) measurements.

The state observer thus allows the reconstruction of the internal state of a system (on condition that it is observable) without having direct access of it but simply starting from the knowledge of system inputs and outputs.

As shown in the above figure, the observer is composed of two blocks. The first block is constituted by a model of the plant whose internal state we want to know. Due to unavoidable inaccuracies on plant model and to parameters’ deviations or uncertainties, the states ^X would be destined to diverge from real state X if we computed it by simply applying input U to our plant model. On the contrary, this can be avoided by ‘closing the loop’ - that is, by feeding back the error between the measured and observed outputs.

In fact, multiplying this error by the observer gain K and reporting it as input to our plant reproduction allows a continuous adjustment of the plant model guaranteeing the coherency between X and ^X.

For all these reasons, a state observer can be considered a closed loop system. We can now apply these concepts to PMSM equations in order to get an estimation of its internal state starting from its input and from the measurement of its output. Let’s consider PMSM motor equations:

In order to make this system linear, we introduce two new state variables:

Supposing now the mechanical quantities slowly changing versus the electrical ones, we can write that:

This is, under the position x = [iα iβ eα eβ ]^{t}, u = [vα vβ]^{t}, y = [iα iβ]^{t}, the canonical ISO representation of a linear time-invariant system:

It is possible to demonstrate that the PMSM, so represented, is an ‘observable’ system; then starting from the measurement of its currents iα iβ and knowing the applied voltages vα vβ, it is possible to reconstruct the B-emfs values eα eβ:

The feedback given by the error between estimated and measured currents allows adjusting the motor equation, strongly decreasing the sensitivity to motor parameters’ uncertainties and inaccuracies.

In order to have a clear idea of the computational complexity of this approach, let’s write the observer equations:

Going into time-discrete domain, it gives:

### Comparative Flux estimator vs Observer

In order to compare the performances of the flux estimator with ones of the state observer, two aspects have been taken into consideration: the computational complexity and the robustness to motor parameters’ uncertainties and inaccuracies.

To evaluate the computational complexity of the two algorithms, the number of mathematical operations which compose the two schemes has been taken into account:

As reported in the table, it is possible to see that the number of operations required by the proposed state observer algorithm is about double of those required by the VI flux estimator. However, it has to be pointed out that such an advantage of the VI flux estimator can not be completely exploited in terms of a smaller Ts as both the rotor position sensor-less detection algorithms are often executed with the same sampling rate of the vector control (i.e. with the same or with an integer sub-multiple of PWM frequency).

Now, let’s evaluate robustness of both of the algorithms to motor parameters’ uncertainties. Different simulations have been carried out to measure the error on rotor position angle introduced by a poor understanding of motor parameters. The figure 6 shows to this purpose the error on rotor position angle when the stator resistance utilized by the algorithm is the double the real one:

The graph in Figure 6 shows a clear and strong sensitivity of VI flux estimator to stator resistance deviation especially at low speed while the closed loop approach utilized by the state observer algorithm allows a full compensation of the stator resistance uncertainty. On the contrary, as shown in Figure 7, both algorithms are pretty sensitive to stator inductance uncertainty even if the error introduced by the state observer is still a bit lower (5% at low speed):

**Conclusions**

Due to its performance in terms of robustness to motor parameters’ deviation (e.g. stator resistance), the state observer described in this article had been chosen for implementation on the STM32 microcontroller and included in the STM32 FOC PMSM firmware library The STM32 takes advantage of the powerful Cortex^{TM}-M3 computational capabilities. In fact, the highly efficient 3-stage pipeline with branch speculation, the single cycle 32bit multiply, and the hardware divide instructions allows keeping, in spite of the number of mathematic operations, the overall state observer routine execution time low - around 3.5µs (CPU running at 72MHz), thus limiting the CPU load contribution of the sensor-less algorithm to just 3.5% at 10 kHz PWM frequency.

Moreover, because of the high density of the Thumb2 instruction set, the code size of the overall state observer routine is quite reduced.