Controller for a fluxbased permanent magnet synchronous motor
Powertrain Blockset / Propulsion / Electric Motor Controllers
The Flux Based PM Controller block implements a fluxbased, fieldoriented controller for an interior permanent magnet synchronous motor (PMSM) with an optional outerloop speed controller. The internal torque control implements strategies for achieving maximum torque per ampere (MTPA) and weakening the magnetic flux. You can specify either the speed or torque control type.
The Flux Based PM Controller implements equations for speed control, torque determination, regulators, transforms, and motors.
The figure illustrates the information flow in the block.
The block implements equations using these variables.
ω 
Rotor speed 
ω* 
Rotor speed command 
T* 
Torque command 
i_{d} i*_{d} 
daxis current daxis current command 
i_{q} i*_{q} 
qaxis current qaxis current command 
v_{d}, v*_{d} 
daxis voltage daxis voltage command 
v_{q} v*_{q} 
qaxis voltage qaxis voltage command 
v_{a}, v_{b}, v_{c} 
Stator phase a, b, c voltages 
i_{a}, i_{b}, i_{c} 
Stator phase a, b, c currents 
To implement the speed controller, select the Control Type
parameter Speed Control
. If you select the
Control Type parameter Torque
Control
, the block does not implement the speed controller.
The speed controller determines the torque command by implementing a state filter, and calculating the feedforward and feedback commands. If you do not implement the speed controller, input a torque command to the Flux Based PM Controller block.
The state filter is a lowpass filter that generates the acceleration command based on the speed command. The discrete form of characteristic equation is given by:
$z+{K}_{sf}{T}_{sm}1$
The filter calculates the gain using this equation.
${K}_{sf}=\frac{1\mathrm{exp}\left({T}_{sm}2\pi E{V}_{sf}\right)}{{T}_{sm}}$
The equations use these variables.
EV_{sf} 
Bandwidth of the speed command filter 
T_{sm} 
Motion controller sample time 
K_{sf} 
Speed regulator time constant 
To generate the state feedback torque, the block uses the filtered speed error signal from the state filter. To filter the speed, the block uses a proportional integral (PI) controller.
$${T}_{cmd}=K{p}_{\omega}({\omega}_{m}^{*}{\omega}_{m})+K{i}_{\omega}\frac{z{T}_{sm}}{z1}({\omega}_{m}^{*}{\omega}_{m})$$
The equations use these variables.
ω_{m} 
Rotor speed 
ω*_{m} 
Rotor speed command 
T_{cmd} 
Torque command 
Kp_{ω} 
Speed regulator proportional gain 
Ki_{ω} 
Speed regulator integral gain 
T_{sm} 
Speed regulator sample rate 
To generate the state feedforward torque, the block uses the filtered speed and acceleration from the state filter. Also, the feedforward torque calculation uses the inertia, viscous damping, and static friction. To achieve zero tracking error, the torque command is the sum of the feedforward and feedback torque commands.
The feedforward torque command uses this equation.
$${T}_{cmd\_ff}={J}_{p}{\dot{\omega}}_{m}+{F}_{v}{\omega}_{m}+{F}_{s}\frac{{\omega}_{m}}{\left{\omega}_{m}\right}$$
where:
J_{p} 
Rotor inertia 
T_{cmd_ff} 
Torque command feedforward 
F_{s} 
Static friction torque constant 
F_{v} 
Viscous friction torque constant 
F_{s} 
Static friction torque constant 
ω_{m} 
Rotor speed 
The block uses lookup tables to determine the daxis and qaxis current commands. The lookup tables are functions of mechanical speed and torque. To determine the lookup tables, you can use an external finite element analysis (FEA) models or dynamometer test results.
$$\begin{array}{l}{i}_{dref}=f(\left{\omega}_{m}\right,\left{T}_{ref}\right)\\ {i}_{qref}=sign({T}_{ref})\ast f(\left{\omega}_{m}\right,\left{T}_{ref}\right)\end{array}$$
The equations use these variables.
ω_{m} 
Rotor speed 
T_{ref} 
Torque command 
i_{dref}, i_{qref} 
d and qaxis reference current, respectively 
The block uses these equations to calculate the voltage in the motor reference frame.
$$\begin{array}{l}{v}_{d}=\frac{d{\psi}_{d}}{dt}+{R}_{s}{i}_{d}{\omega}_{e}{\psi}_{q}\\ {v}_{q}=\frac{d{\psi}_{q}}{dt}+{R}_{s}{i}_{q}+{\omega}_{e}{\psi}_{d}\end{array}$$
$$\begin{array}{l}\frac{d{\psi}_{d}}{dt}+{R}_{s}{i}_{d}=K{p}_{d}({i}_{d}^{*}{i}_{d})+K{i}_{d}\frac{z{T}_{st}}{z1}({i}_{d}^{*}{i}_{d})\\ \frac{d{\psi}_{q}}{dt}+{R}_{s}{i}_{q}=K{p}_{q}({i}_{q}^{*}{i}_{q})+K{i}_{q}\frac{z{T}_{st}}{z1}({i}_{q}^{*}{i}_{q})\\ \\ {v}_{d}=K{p}_{i}({i}_{d}^{*}{i}_{d})+K{i}_{d}\frac{z{T}_{st}}{z1}({i}_{d}^{*}{i}_{d})+{\omega}_{e}{\psi}_{q}\\ {v}_{q}=K{p}_{i}({i}_{q}^{*}{i}_{q})+K{i}_{q}\frac{z{T}_{st}}{z1}({i}_{q}^{*}{i}_{q}){\omega}_{e}{\psi}_{d}\\ \\ {\psi}_{q}=f({i}_{d},{i}_{q})\\ {\psi}_{d}=f({i}_{d},{i}_{q})\end{array}$$
The equations use these variables.
ω_{m} 
Rotor mechanical speed 
ω_{e}  Rotor electrical speed 
R_{s}, R_{r} 
Resistance of the stator and rotor windings, respectively 
i_{q}, i_{d} 
q and daxis current, respectively 
v_{q}, v_{d} 
q and daxis voltage, respectively 
Ψ_{q}, Ψ_{d} 
q and daxis magnet flux, respectively 
T_{st} 
Current regulator sample rate 
Ki_{d} , Ki_{q} 
d and q axis integral gain, respectively 
Kp_{d} , Kp_{q} 
d and q axis proportional gain, respectively 
To calculate the voltages and currents in balanced threephase (a, b) quantities, quadrature twophase (α, β) quantities, and rotating (d, q) reference frames, the block uses the Clarke and Park Transforms.
In the transform equations.
$\begin{array}{l}{\omega}_{e}=P{\omega}_{m}\\ \frac{d{\theta}_{e}}{dt}={\omega}_{e}\end{array}$
Transform  Description  Equations 

Clarke 
Converts balanced threephase quantities (a, b) into balanced twophase quadrature quantities (α, β).  $\begin{array}{l}{x}_{\alpha}=\frac{2}{3}{x}_{a}\frac{1}{3}{x}_{b}\frac{1}{3}{x}_{c}\\ {x}_{\beta}=\frac{\sqrt{3}}{2}{x}_{b}\frac{\sqrt{3}}{2}{x}_{c}\end{array}$ 
Park 
Converts balanced twophase orthogonal stationary quantities (α, β) into an orthogonal rotating reference frame (d, q).  $\begin{array}{l}{x}_{d}={x}_{\alpha}\mathrm{cos}{\theta}_{e}+{x}_{\beta}\mathrm{sin}{\theta}_{e}\\ {x}_{q}={x}_{\alpha}\mathrm{sin}{\theta}_{e}+{x}_{\beta}\mathrm{cos}{\theta}_{e}\end{array}$ 
Inverse Clarke 
Converts balanced twophase quadrature quantities (α, β) into balanced threephase quantities (a, b).  $\begin{array}{l}{x}_{a}={x}_{a}\\ {x}_{b}=\frac{1}{2}{x}_{\alpha}+\frac{\sqrt{3}}{2}{x}_{\beta}\\ {x}_{c}=\frac{1}{2}{x}_{\alpha}\frac{\sqrt{3}}{2}{x}_{\beta}\end{array}$ 
Inverse Park 
Converts an orthogonal rotating reference frame (d, q) into balanced twophase orthogonal stationary quantities (α, β).  $\begin{array}{l}{x}_{\alpha}={x}_{d}\mathrm{cos}{\theta}_{e}{x}_{q}\mathrm{sin}{\theta}_{e}\\ {x}_{\beta}={x}_{d}\mathrm{sin}{\theta}_{e}+{x}_{q}\mathrm{cos}{\theta}_{e}\end{array}$ 
The transforms use these variables.
ω_{m} 
Rotor speed 
P 
Rotor pole pairs 
ω_{e} 
Rotor electrical speed 
Θ_{e} 
Rotor electrical angle 
x 
Phase current or voltage 
The block uses the phase currents and phase voltages to estimate the DC bus current. Positive current indicates battery discharge. Negative current indicates battery charge.
The block uses these equations.
Load power  $L{d}_{Pwr}={v}_{a}{i}_{a}+{v}_{b}{i}_{b}+{v}_{c}{i}_{c}$ 
Source power  $Sr{c}_{Pwr}=L{d}_{Pwr}+Pw{r}_{Loss}$ 
DC bus current  ${i}_{bus}=\frac{Sr{c}_{Pwr}}{{v}_{bus}}$ 
Estimated rotor torque  $${T}_{e}=1.5P[{\psi}_{d}{i}_{q}{\psi}_{q}{i}_{d}]$$ 
Power loss for single efficiency source to load  $$Pw{r}_{Loss}=\frac{100Eff}{Eff}\cdot L{d}_{Pwr}$$ 
Power loss for single efficiency load to source  $$Pw{r}_{Loss}=\frac{100Eff}{100}\cdot \leftL{d}_{Pwr}\right$$ 
Power loss for tabulated efficiency  $Pw{r}_{Loss}=f({\omega}_{m},MtrTr{q}_{est})$ 
The equations use these variables.
v_{a}, v_{b}, v_{c} 
Stator phase a, b, c voltages 
v_{bus} 
Estimated DC bus voltage 
i_{a}, i_{b}, i_{c} 
Stator phase a, b, c currents 
i_{bus} 
Estimated DC bus current 
Eff 
Overall inverter efficiency 
ω_{m} 
Rotor mechanical speed 
L_{q}, L_{d} 
q and daxis winding inductance, respectively 
Ψ_{q}, Ψ_{d} 
q and daxis magnet flux, respectively 
i_{q}, i_{d} 
q and daxis current, respectively 
λ 
Permanent magnet flux linkage 
P 
Rotor pole pairs 
To specify the electrical losses, on the Electrical Losses tab, for Parameterize losses by, select one of these options.
Setting  Block Implementation 

Single efficiency measurement  Electrical loss calculated using a constant value for inverter efficiency. 
Tabulated loss data  Electrical loss calculated as a function of motor speeds and load torques. 
Tabulated efficiency data  Electrical loss calculated using inverter efficiency that is a function of motor speeds and load torques.

For best practice, use Tabulated loss data
instead of Tabulated efficiency data
:
Efficiency becomes ill defined for zero speed or zero torque.
You can account for fixed losses that are still present for zero speed or torque.
[1] Hu, Dakai, Yazan Alsmadi, and Longya Xu. “High fidelity nonlinear IPM modeling based on measured stator winding flux linkage.” IEEE^{®} Transactions on Industry Applications, Vol. 51, No. 4, July/August 2015.
[2] Chen, Xiao, Jiabin Wang, Bhaskar Sen, Panagiotis Lasari, Tianfu Sun. “A HighFidelity and Computationally Efficient Model for Interior PermanentMagnet Machines Considering the Magnetic Saturation, Spatial Harmonics, and Iron Loss Effect.” IEEE Transactions on Industrial Electronics, Vol. 62, No. 7, July 2015.
[3] Ottosson, J., M. Alakula. “A compact field weakening controller implementation.” International Symposium on Power Electronics, Electrical Drives, Automation and Motion, July, 2006.