PMSM Field-Oriented Control in Simulink: The Practical Steps
How PMSM field-oriented control works: Clarke and Park transforms, current loops, MTPA and field weakening, built step by step in Simulink.
· Aura Volt Engineering Team
Most electric cars use a permanent-magnet synchronous motor (PMSM), and almost all of them control it with field-oriented control (FOC). FOC turns a three-phase AC motor into something that can be controlled as simply as a DC motor: one current sets the torque, and another sets the magnetic field. This guide walks through the parts of an FOC drive and the order in which to build them in Simulink.
The idea in one paragraph
A PMSM's three phase currents are sinusoidal and rotate with the rotor. If we look at them from a frame that rotates with the rotor, they become two steady values: the d-axis current, aligned with the magnet, and the q-axis current, at right angles to it. Torque comes mainly from the q-axis current. So instead of controlling three AC currents, we control two DC-like values with two ordinary PI controllers.
Step 1: Clarke and Park transforms
- Clarke transform: converts the three phase currents (ia, ib, ic) into two stationary components (iα, iβ).
- Park transform: rotates (iα, iβ) by the rotor's electrical angle θe to give (id, iq).
The rotor angle comes from a position sensor (resolver or encoder) or an estimator. Remember that the electrical angle is the mechanical angle multiplied by the number of pole pairs, a common source of errors.
Step 2: Current loops
Two PI controllers compare id and iq with their references and produce voltage commands vd and vq. Two details matter in practice:
- Decoupling: the d and q axes affect each other through terms proportional to speed (ω·L·i). Adding feed-forward terms that cancel them makes the loops much easier to tune.
- Tuning: the current loops should be the fastest loops in the drive, typically ten times faster than the speed loop. A good starting point sets each loop's zero to cancel the motor's electrical pole (L/R).
Step 3: Back to three phases and PWM
The inverse Park and inverse Clarke transforms turn (vd, vq) back into three phase voltage commands. Space-vector PWM (SVPWM) then sets the inverter's switching, using the DC-link voltage about 15% better than simple sine-triangle PWM. In Simulink you can start with an averaged inverter for speed, then switch to a switched inverter model in Simscape Electrical to see ripple and switching effects.
Step 4: Choosing the current references (MTPA)
For a surface-mounted PMSM, the best choice is simple: id = 0, and all current goes into iq. An interior PMSM (IPMSM), common in EVs, also produces reluctance torque. A negative id then adds torque, and maximum torque per ampere (MTPA) gives the id–iq pair that makes the most torque for each ampere. MTPA is usually stored as lookup tables computed offline from the motor's parameters.
Step 5: Field weakening at high speed
As speed rises, the motor's back-EMF approaches the voltage the inverter can supply. To keep going faster, the controller pushes id more negative to weaken the magnet's field. This is field weakening. Implement it with a voltage-limit check, and add anti-windup to the controllers so they recover cleanly when they hit their limits.
Step 6: The speed loop and the vehicle
A slower outer PI loop turns a speed error into a torque or iq reference. In an EV, the outer loop is often a torque command from the driver's pedal instead. Connect the drive to a vehicle model (mass, tyre radius, gear ratio, road load) and run a drive cycle such as WLTP to see energy use and range.
Build it in this order
- Motor model plus an ideal current source: check torque against id and iq.
- Add the current loops with an averaged inverter: tune them and check their step responses.
- Add SVPWM and a switched inverter: check current ripple.
- Add MTPA and field weakening: run a full speed sweep.
- Add the speed or torque loop and the vehicle: run drive cycles.
Testing each layer before adding the next saves a lot of debugging time.
Where to go next
Our Virtual Lab includes a 23-level cascaded H-bridge inverter driving an IPMSM with FOC and MTPA over a WLTP cycle, and a BLDC six-step drive for comparison. To learn FOC step by step, join our live course, PMSM Motor Control (FOC) in Simulink. If you need an FOC model or drive study for your own motor, talk to us about EV motor drives.