# How is PWM implemented in Field Oriented Control (FOC) ?

Joined Nov 4, 2018
28
Hi everyone,

I am trying to understand and implement FOC algorithm in MATLAB for a PMSM. I understand we are converting the 3 phase stator currents into 2 time-invariant stator currents: (direct and quadrature currents or Id and Iq, respectively). But I do not unsderstand how PWM is applied here since PWM can only alternate between High and Low currents but I do not understand why this is required or how it will help in torque control since. I thought the PI controllers adjusted Id and Iq to be the same as the reference currents and then inverse Park transform and inverse Clarke transfroms would be applied to get 3 phase voltages. PWM shouldn't be used since we are feeding 3 phase voltages into the stator. So what is the function of PWM here ? What does it do ? Please your help would be really appreciated since I am struggling a lot with this. Thank you in advance.

Also could someone explain me how the PI controllers manage to convert currents into voltages to be fed into the inverse Park transform ?

Also why is SPWM employed ? what makes is that good ? (Could you also point me to a source (preferably academic) which explains SPWM ?

#### TechWise

Joined Aug 24, 2018
151
I think you misunderstand the role of the PWM. It is just a way of turning the DC voltage at the input of the motor drive into the AC voltage that you need to push an AC current into the motor. The current controller will output a dq voltage reference which is then transformed back into an abc voltage reference which is input to the modulator to produce three currents.

Almost any academic paper mentioning "current control" or "voltage source converter" will get you started. I especially recommend "Voltage Sourced Converters in Power Systems" by Amirnaser Yazdani and Reza Iravani for a comprehensive explanation of how a current controller works. There is also the truly excellent "Teaching Old Motors New Tricks" series by Texas Instruments available on youtube which goes through the control of a PMSM pretty clearly. Note that there is a companion blog on the TI website and also a related "Teaching Your PI Controller to Behave" blog.

As for why we use SPWM - it is a simple way to produce a sinusoidal voltage from a DC voltage. The alternative is Space Vector Modulation which has a few advantages but is a bit more complicated. For an extraordinarily detailed analysis of precisely what happens during SPWM, you should read "Pulse Width Modulation for Power Converters: Principles and Practice" by
D. Grahame Holmes and Thomas A. Lipo. It goes into the harmonic spectrum of both.

Don't try to run before you can walk with this stuff. Also don't blindly take models from the Mathworks Forum and then try to reverse engineer them. Start from the fundamentals and learn it properly.

Joined Nov 4, 2018
28
@TechWise Thank you a lot for your answers. Do you also have a good, academic, source explaining SVPWM ? I am having issues understanding this one too.

#### TechWise

Joined Aug 24, 2018
151
"High Power Converters and AC Drives" by Bin Wu has some good material on Space Vector Modulation. The "Teaching Old Motors New Tricks" series that I mentioned also discusses it. Most textbooks on grid-connected converters will still be useful to you as the grid-voltage is basically the same as the back-EMF from the motor and the control approach is very similar.