> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/smart-power-simulation-software-sps/example-models/motor-drives/field-oriented-control-of-a-surface-mounted-permanent-magnet-synchronous-motor.md).

# Field Oriented Control of a Surface Mounted Permanent Magnet Synchronous Motor

This example shows the speed regulation of a surface-mounted permanent magnet synchronous motor (PMSM) using field-oriented control (FOC).

<figure><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-3f1cb6d5ed49e8c556538b010af09fff2b85a710%2Ffieldorientedcontrol_surfacemounted_PMSM.png?alt=media" alt=""><figcaption></figcaption></figure>

## Description

PMSMs are AC synchronous motors with permanent magnets mounted on their rotor surfaces (surfaced-mounted PMSMs) or buried into the rotor (interior-mounted PMSMs). While a BLDC motor has a trapezoidal back-EMF, PMSMs have a sinusoidal back-EMF.

PMSM motors are typically controlled using the field-oriented control scheme and fed with sinusoidal currents.

### Electrical Model

A DC bus, modeled as an ideal DC source of 400 V, is connected to a three-phase, two-level converter. This converter generates the appropriate three-phase voltages for the speed regulation of the 3 kW, 3000 rpm PMSM motor.

The converter is controlled by a FOC controller that generates the voltage references to a space-vector PWM modulator.

### Field-Oriented Control Theory

FOC is a control scheme in which a d-q coordinates reference frame that is locked to the motor flux space vector is used to achieve decoupling between the motor flux and torque. Consequently, they can be separately controlled by stator direct-axis and quadrature-axis currents, respectively.

The torque is at maximum when the flux produced by the magnets is perpendicular to the stator flux produced by the stator currents. In field-oriented control scheme, the angle between these two fluxes is maintained at 90 degrees to produce maximum torque.

The torque developed by the motor is given by:

$$
T\_e = \frac{3}{2} p \left\[ \lambda, i\_q + (L\_d - L\_q), i\_d, i\_q \right]
$$

where

*p* is the number of pole pairs.

$$\lambda$$ is the flux induced by the permanent magnets in the stator windings.

*L*<sub>*d*</sub> and *L*<sub>*q*</sub> are the d-axis and q-axis inductances.

*i*<sub>*d*</sub> and *i*<sub>*q*</sub> are the d-axis and q-axis stator currents.

Note that the equation is expressed in the rotor reference frame (dq frame) and all quantities in the rotor reference frame are referred to the stator.

Because the permanent magnets of the motor are mounted on the rotor surface, the direct and quadrature-axis inductances have the same value (Ld = Lq in our example). The equation above can then be simplified to:

$$
T\_e = \frac{3}{2} p \left\[ \lambda, i\_q  \right]
$$

This new equation shows that the direct-axis current component Id has no influence on the torque. The motor torque can then be controlled by the stator Iq component.

### Field-Oriented Control System

Based on the rotor position (represented by the signal theta in the motor model), the measured three-phase stator currents are converted into their d-q coordinates in the rotor reference frame.

The motor speed $$\omega\_m$$ and the speed reference $$\omega\_{ref}$$ are fed to the speed regulator to produce a current reference, *Iq*<sub>*ref*</sub>. The role of the speed regulator is to keep the motor speed equal to the speed reference by producing more or less torque to accelerate or decelerate the motor.

The *Iq*<sub>*ref*</sub> current reference and the *Id*<sub>*ref*</sub> current reference (which are set to zero when field weakening is not required) are fed to the current regulators. The regulators process the measured and reference currents to produce the three-phase reference signals. The signals are connected to the PWM modulator that generates pulses for the motor inverter. The modulator uses the space vector PWM method with pulse averaging and a switching frequency of 8 kHz.

## Simulation

Run the simulation and observe waveforms on the scope blocks. The motor rapidely reaches its reference speed of 2000 rpm. At 0.25 s, the motor rotation is reversed by setting the speed reference to -2800 rpm. To respect this new set point, the control system produces a large negative torque. Notice that the active power transferred back to the DC source during the deceleration. At 0.65 s, a negative load torque of -8 N.m is applied to the motor. In order to maintain the motor speed at -2800 rpm, the control system changes the reference current to produce a negative torque of about -10 N.m.

## Command

Example model name: power\_motordrive\_PMSM\_FOC

{% code lineNumbers="true" %}

```matlab
open('power_motordrive_PMSM_FOC')
```

{% endcode %}

## References

Cirrincione, M., M. Pucci, G. Vitale. Power Converters and AC Electrical Drives with Linear Neural Networks. CRC Press, 2012.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/smart-power-simulation-software-sps/example-models/motor-drives/field-oriented-control-of-a-surface-mounted-permanent-magnet-synchronous-motor.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
