Permanent Magnet Synchronous Machine with Salient Rotor
Description of the threephase permanent magnet synchronous machine (PMSM) with salient rotor component in Schematic Editor
The Schematic Editor library block from the Machine section, shown in Table 1, models the dynamics of a threephase permanent magnet synchronous machine in realtime. This modeling approach can be used for describing the dynamics of a permanent magnet synchronous machine with a salient or a cylindrical rotor.
component  component dialog window  component parameters 


In the above block, terminals A, B, and C are stator winding terminals, consisting of three identical, sinusoidally distributed phase windings, displaced by 120 degrees. The stator winding arrangement (connection) can be selected by the block parameter star_delta. The model assumes that the stator flux linkage established by the permanent magnets is sinusoidal, which implies that the electromotive forces are sinusoidal.
Electrical subsystem model
The electrical part of the machine is represented by a secondorder statespace model in a synchronously rotating dq reference frame, invariant to the electrical variable amplitudes, as described in [3]. The dq reference frame is attached to the rotor, and the daxis is aligned with the rotor magnets. The modeled dynamics can be represented with following equations:
$\frac{d}{dt}\left[\begin{array}{c}{\lambda}_{ds}\\ {\lambda}_{qs}\end{array}\right]=\left[\begin{array}{cc}\frac{{R}_{s}}{{L}_{d}}& {\omega}_{r}\\ {\omega}_{r}& \frac{{R}_{s}}{{L}_{q}}\end{array}\right]\left[\begin{array}{c}{\lambda}_{ds}\\ {\lambda}_{qs}\end{array}\right]+\left[\begin{array}{ccc}1& 0& \frac{{R}_{s}}{{L}_{d}}\\ 0& 1& 0\end{array}\right]\left[\begin{array}{c}{\nu}_{ds}\\ {\nu}_{qs}\\ {\lambda}_{PM}\end{array}\right]$ $\left[\begin{array}{c}{i}_{ds}\\ {i}_{qs}\end{array}\right]=\left[\begin{array}{cc}\frac{1}{{L}_{d}}& 0\\ 0& \frac{1}{{L}_{q}}\end{array}\right]\left[\begin{array}{c}{\lambda}_{ds}\\ {\lambda}_{qs}\end{array}\right]+\left[\begin{array}{ccc}0& 0& \frac{1}{{L}_{d}}\\ 0& 0& 0\end{array}\right]\left[\begin{array}{c}{\nu}_{ds}\\ {\nu}_{qs}\\ {\lambda}_{PM}\end{array}\right]$symbol  description 

${\lambda}_{ds}$  direct axis component of stator flux 
${\lambda}_{qs}$  quadrature axis component of stator flux 
${\lambda}_{PM}$  flux amplitude established in stator phases by rotor permanent magnets 
${i}_{ds}$  direct axis component of stator current 
${i}_{qs}$  quadrature axis component of stator current 
${v}_{ds}$  direct axis component of stator voltage 
${v}_{qs}$  quadrature axis component of stator voltage 
${R}_{s}$  stator phase resistance 
${L}_{d}$  direct axis inductance 
${L}_{q}$  quadrature axis inductance 
${\omega}_{r}^{}$  rotor electrical speed 
Starting with 2018.2 version of Typhoon HIL Software, a nonlinear model of permanent magnet synchronous machine is supported. If the chosen model type is nonlinear, the electrical subsystem is based on the same equations, the only difference being that fluxes ${\lambda}_{ds}$ and ${\lambda}_{qs}$ , and inductances ${L}_{d}$ and ${L}_{q}$ are dependent on the stator currents ${i}_{ds}$ and ${i}_{qs}$ .
Mechanical subsystem model
The mechanical part of the machine is represented by a secondorder statespace model:
$\stackrel{\u0307}{{\omega}_{m}}=\frac{1}{{J}_{m}}({T}_{e}{T}_{L})$ $\stackrel{\u0307}{{\theta}_{m}}={\omega}_{m}$ ${T}_{e}=\frac{3}{2}p({\lambda}_{ds}{i}_{qs}{\lambda}_{qs}{i}_{ds})$symbol  description 

${\omega}_{m}$  rotor mechanical speed 
${\theta}_{m}$  rotor mechanical angle (between as and ar axis) 
${T}_{e}$  machine developed electromagnetic torque 
${T}_{L}$  shaft mechanical load torque 
${J}_{m}$  combined rotor and load moment of inertia 
${p}_{}$  machine number of pole pairs 
${\lambda}_{ds}$  direct axis component of stator flux 
${\lambda}_{qs}$  quadrature axis component of stator flux 
${i}_{ds}$  direct axis component of stator current 
${i}_{qs}$  quadrature axis component of stator current 
Block dialogue box and parameters
The permanent magnet synchronous machine block dialogue box consists of four tabs for specifying machine model parameters and one general input for specifying the machine label in the circuit schematic.
Tab: "Electrical"
In this block tab, all electrical parameters of the model can be specified. Its layout is shown here:
The permanent magnet synchronous machine electrical parameters
symbol  description 

${Rs}_{}$  stator phase resistance [Ω] 
${Ld}_{}$  direct axis inductance [H] 
${Lq}_{}$  quadrature axis inductance [H] 
${Psi\_pm}_{}$  flux amplitude established in stator phases by rotor permanent magnets [Wb] 
${idvector}_{}$  list of daxis current values 
${iqvector}_{}$  list of qaxis current values 
${psidtable}_{}$  daxis flux linkage lookup table 
${psiqtable}_{}$  qaxis flux linkage lookup table 
${Ldtable}_{}$  daxis inductance lookup table 
${Lqtable}_{}$  qaxis inductance lookup table 
The permanent magnet synchronous machine model can include magnetic saturation effects. In that case, fluxes or inductances are defined as functions of stator currents ${i}_{ds}$ and ${i}_{qs}$ . These functions are represented in the form of lookup tables. The lookup tables use linear interpolation and linear extrapolation.
 fluxes vs stator currents
 absolute inductances vs stator currents
 incremental inductances vs stator currents
Besides the saturation, the permanent magnet synchronous machine model can include flux and torque spatial harmonics. The spatial effects are parametrized using lookup tables. Either the d and q axis currents tables, or the d and q axis fluxes can be provided. In addition a torque table can be used if available.
In case the current tables are used, the corresponding mechanical angle vector and d and q axis flux vectors should be provided. The current tables should be provided in the form of a nested Python lists, as shown in Figure 4.
Similarly, if flux tables are used, the corresponding mechanical angle vector and d and q axis current vectors should be provided. The flux tables should be provided in the form of a nested Python lists, as shown in Figure 5.
If the torque table is used, the corresponding mechanical angle vector and d and q axis current vectors should be provided. The torque table should be provided in the form of a nested Python list, as shown in Figure 6.
In all cases the mechanical angle vector must be given as a list ranging from 0 to 360/pole_pairs. The number of points available for all lookup tables used is 16000. If the total number of points provided in the lookup tables exceeds this number, the tables will be rescaled to work with fewer points. The resulting tables may have lower resolution than the original ones.
If iron losses are included, corresponding d and q axis iron loss currents are calculated as follows:
${v}_{ds}={\omega}_{r}{\lambda}_{qs}$
${v}_{qs}={\omega}_{r}{\lambda}_{ds}$
${R}_{Fe}=\frac{3{\omega}_{r}^{2}\left({\lambda}_{ds}^{2}+{\lambda}_{qs}^{2}\right)}{2{P}_{Fe}}$
${i}_{d,Fe}=\frac{{v}_{ds}}{{R}_{Fe}}$
${i}_{q,Fe}=\frac{{v}_{qs}}{{R}_{Fe}}$
Direct and quadrature axis components of iron loss currents are added to the corresponding components of stator currents, which provide the machine's electromagnetic torque:
${i}_{ds}={i}_{dm}+{i}_{d,Fe}$
${i}_{qs}={i}_{qm}+{i}_{q,Fe}$
symbol  description 

${\lambda}_{ds}$  direct axis component of stator flux 
${\lambda}_{qs}$  quadrature axis component of stator flux 
${v}_{ds}$  direct axis component of stator voltage 
${v}_{qs}$  quadrature axis component of stator voltage 
${i}_{\mathrm{ds}}$  direct axis component of stator current 
${i}_{\mathrm{qs}}$  quadrature axis component of stator current 
${i}_{\mathrm{d,}\mathrm{Fe}}$  direct axis component of iron loss current 
${i}_{\mathrm{q,}\mathrm{Fe}}$  quadrature axis component of iron loss current 
${i}_{\mathrm{dm}}$  direct axis component of stator current which determines torque production 
${i}_{\mathrm{qm}}$  quadrature axis component of stator current which determines torque production 
${R}_{\mathrm{Fe}}$  iron loss resistance 
${P}_{\mathrm{Fe}}$  total iron losses 
${\omega}_{r}^{}$  rotor electrical speed 
An example of a PMSM model including iron losses can be found in the pmsm iron losses.tse example in our Examples Explorer, in the [examples\models\electrical drives\pmsm iron losses].
Tab: "Mechanical"
In this block tab, all mechanical parameters of the model can be specified. Its layout is shown here:
Permanent magnet synchronous machine mechanical parameters
symbol  description 

${pms}_{}$  machine number of pole pairs 
${star\_delta}_{}$  stator winding connection (star or delta) 
${J}_{m}$  combined rotor and load moment of inertia [kgm2] 
${Frictioncoefficient}_{}$  machine viscous friction coefficient [Nms] 
Tab: "Load"
In this block tab, the external load settings can be specified. Its layout is shown here:
Permanent magnet synchronous machine mechanical parameters
symbol  description 

${Externalloadtype}_{}$  External load type: torque or speed 
${Loadaipin}_{}$  HIL analog input address for external torque command 
${Loadaioffset}_{}$  assigned offset value to the input signal representing external torque command 
${Loadaigain}_{}$  assigned gain value to the input signal representing external torque command 
External load enables use of an analog input signal from a HIL analog channel with the address ai_pin_addr as an external torque/speed load. It also allows for assigning an offset to the input signal and gain (Nm/V) according to the formula:
${T}_{L}=gain\bullet \left(AI\right(ai\_pin\_addr)+offset)$Tab: "Feedback"
In this block tab, all parameters relevant to machine model feedback signals can be specified. Its layout is shown here:
Permanent magnet synchronous machine feedback properties
symbol  description 

${Encppr}_{}$  incremental encoder number of pulses per revolution 
${Resolverpolepairs}_{}$  resolver number of pole pairs 
${Resolvercarrsource}_{}$  resolver carrier signal source selection (internal or external) 
${Resolvercarrierfrequency}_{}$  resolver carrier signal frequency (internal carrier) 
${Resolveraipin}_{}$  resolver carrier input channel address 
${Resolveraioffset}_{}$  resolver carrier input channel offset 
${Resolveraigain}_{}$  resolver carrier input channel gain 
Tab: "Advanced"
In this block tab, some advanced features of the machine model can be specified. Its layout is shown here:
Theta_ab specifies the position of the stationary αβ reference frame with regards to the stator phase a axis. In this way, machine model output variables (currents, voltages, and fluxes) can be monitored in a more familiar stationary reference frame. Also, in this way, the initial position of the dq reference frame is specified, having in mind that the daxis of a dq reference frame is displaced by an initial rotor position ${\theta}_{r0}$ with regards to the αaxis of a stationary reference frame. There are usually two machine modeling approaches: the first is where the alpha axis of the stationary reference frame lags by 90 degrees with regards to the stator phase aaxis (used by default, and indicated in a) Figure 12). The second one is where the alpha axis is aligned with the stator phase aaxis (indicated in b) Figure 12). Either of these two situations can be selected.
Tab: "Output"
This block tab enables a single, vectorized signal output from the machine. The output vector contains selected machine mechanical and/or electrical variables in the same order as listed in this tab. Its layout is shown here:
symbol  description 

${Executionrate}_{}$  signal processing output execution rate 
${Electricaltorque}_{}$  machine electrical torque 
${Mechanicalspeed}_{}$  machine mechanical angular speed 
${Mechanicalangle}_{}$  machine mechanical angle 
${Statoralphaaxiscurrent}_{}$  alpha component of stator current 
${Statorbetaaxiscurrent}_{}$  beta component of stator current 
${Statordaxiscurrent}_{}$  direct axis component of stator current 
${Statorqaxiscurrent}_{}$  quadrature axis component of stator current 
${Statoralphaaxisflux}_{}$  alpha component of stator flux 
${Statorbetaaxisflux}_{}$  beta component of stator flux 
${Statordaxisflux}_{}$  direct axis component of stator flux 
${Statorqaxisflux}_{}$  quadrature axis component of stator flux 
Model outputs
symbol  analog output variable name  description 

${\lambda}_{\alpha s}$  psi_als  alpha component of stator flux 
${\lambda}_{\beta s}$  psi_bes  beta component of stator flux 
${\lambda}_{ds}$  psi_ds  direct axis component of stator flux 
${\lambda}_{qs}$  psi_qs  quadrature axis component of stator flux 
${i}_{\alpha s}$  i_als  alpha component of stator current 
${i}_{\beta s}$  i_bes  beta component of stator current 
${i}_{ds}$  i_ds  direct axis component of stator flux 
${i}_{qs}$  i_qs  quadrature axis component of stator current 
${i}_{as}$  i_a  phase a current 
${i}_{bs}$  i_b  phase b current 
${i}_{cs}$  i_c  phase c current 
${v}_{abs}$  v_ab  line voltage between terminals A and B 
${v}_{bcs}$  v_bc  line voltage between terminals B and C 
${T}_{e}$  machine electrical torque  machine electrical torque 
${T}_{L}$  machine load torque  machine load torque 
${\omega}_{m}$  machine mechanical speed  machine mechanical angular speed 
${\theta}_{m}$  machine mechanical angle  machine mechanical angle 
machine sine encoder A  sinusoidal encoder channel A output  
machine sine encoder B  sinusoidal encoder channel B output  
machine resolver A  resolver channel A output  
machine resolver B  resolver channel B output 
Model details
Figure 14 shows some implementation details relevant for the permanent magnet synchronous machine (dq model) block. For this machine block, the stator circuit is substituted with controlled current sources. Voltage measurement blocks in the stator substitute circuit provide inputs for the machine model solver. Stator line voltages (v_abs and v_bcs) are transformed to phase voltages (v_asf, v_bsf and v_csf) using the block parameter star_delta. In astarwinding configuration phase voltages are not equal to line voltages to which the motor is actually connected (to the inverter, for example). The following equations relate stator line voltages v_abs, v_bcs and v_cas to phase voltages v_asf, v_bsf and v_csf (a balanced, symmetrical set of threephase voltages is assumed):
$\left[\begin{array}{c}{v}_{asf}\\ {v}_{bsf}\\ {v}_{csf}\end{array}\right]=\left[\begin{array}{cc}\frac{2}{3}& \frac{1}{3}\\ \frac{1}{3}& \frac{1}{3}\\ \frac{1}{3}& \frac{2}{3}\end{array}\right]\left[\begin{array}{c}{v}_{abs}\\ {v}_{bcs}\end{array}\right]$For a delta stator winding configuration, line (terminal) voltages v_abs, v_bcs and v_cas are equal to phase (winding) voltages v_asf, v_bsf, and v_csf, so the following equation is valid:
$\left[\begin{array}{c}{v}_{asf}\\ {v}_{bsf}\\ {v}_{csf}\end{array}\right]=\left[\begin{array}{cc}1& 0\\ 0& 1\\ 1& 1\end{array}\right]\left[\begin{array}{c}{v}_{abs}\\ {v}_{bcs}\end{array}\right]$In the next step, stator phase voltages are transformed to stationary αβ reference frame components, v_als and v_bes, using the block parameter theta_ab and the following equation:
$\left[\begin{array}{c}{v}_{\alpha s}\\ {v}_{\beta s}\end{array}\right]=\frac{2}{3}\bullet \left[\begin{array}{ccc}cos{\theta}_{ab}& cos\left(\frac{2\pi}{3}{\theta}_{ab}\right)& cos\left(\frac{2\pi}{3}+{\theta}_{ab}\right)\\ sin{\theta}_{ab}& sin\left(\frac{\pi}{3}+{\theta}_{ab}\right)& sin\left(\frac{\pi}{3}{\theta}_{ab}\right)\end{array}\right]\left[\begin{array}{c}{v}_{asf}\\ {v}_{bsf}\\ {v}_{csf}\end{array}\right]$In order to have a change of variables which formulates an amplitude invariant transformation, a multiplier 2/3 is introduced in an abc/αβtransformation. In such a reference frame, all variables have the same amplitude as in the original phase domain. theta_ab determines the position of the used stationary reference frame in regard to the stator phase winding a.
The model is described in a rotating dq reference frame attached to the rotor, and αβ voltages (v_als and v_bes) are transformed to dqcomponents (v_ds nad v_qs) using the wellknown Park's transformation matrix in following form:
$\left[\begin{array}{c}{v}_{ds}\\ {v}_{qs}\end{array}\right]=\left[\begin{array}{cc}cos{\theta}_{r}& sin{\theta}_{r}\\ sin{\theta}_{r}& cos{\theta}_{r}\end{array}\right]\left[\begin{array}{c}{v}_{\alpha s}\\ {v}_{\beta s}\end{array}\right]$The rotor angle ${\theta}_{r}$ is an input for the electrical subsystem model, which comes from the machine mechanical subsystem. In that way, the inputs for the electrical subsystem model equations given in Electrical subsystem model are formed, and state and outputvariables are calculated. State variables are machine stator fluxes on the d and qaxis (psi_ds and psi_qs) and output variables are stator current dqcomponents (i_ds and i_qs). Electrical subsystem equations also use machine mechanical speed ${\omega}_{r}$ from the mechanical subsystem model and the stator flux amplitude value established by the permanent magnet from the user input block parameter Psi_pm.
Output stator current dqcomponents are transformed back to the stationary reference frame αβcomponents, i_als and i_bes, using an inverse Park transformation in the following form:
$\left[\begin{array}{c}{i}_{\alpha s}\\ {i}_{\beta s}\end{array}\right]=\left[\begin{array}{cc}cos{\theta}_{r}& sin{\theta}_{r}\\ sin{\theta}_{r}& cos{\theta}_{r}\end{array}\right]\left[\begin{array}{c}{i}_{ds}\\ {i}_{qs}\end{array}\right]$Stator current αβcomponents, i_als and i_bes, are transformed to phase values using an inverse Clarke's transformation:
$\left[\begin{array}{c}{i}_{asf}\\ {i}_{bsf}\\ {i}_{csf}\end{array}\right]=\left[\begin{array}{cc}cos{\theta}_{ab}& sin{\theta}_{ab}\\ cos\left({\frac{\pi}{3}+\theta}_{ab}\right)& sin\left({\frac{\pi}{3}+\theta}_{ab}\right)\\ cos\left({\frac{\pi}{3}\theta}_{ab}\right)& sin\left({\frac{\pi}{3}\theta}_{ab}\right)\end{array}\right]\left[\begin{array}{c}{i}_{\alpha s}\\ {i}_{\beta s}\end{array}\right]$Finally, stator phase currents, i_asf, i_bsf, and i_csf, are transformed to line values based on the user input block parameter star_delta. For the stator winding starconnection, the most usual configuration, line (terminal) currents i_as, i_bs and i_cs are equal top hase currents i_asf, i_bsf, and i_csf, and the following equation is valid:
$\left[\begin{array}{c}{i}_{as}\\ {i}_{bs}\\ {i}_{cs}\end{array}\right]=\left[\begin{array}{ccc}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]\left[\begin{array}{c}{i}_{asf}\\ {i}_{bsf}\\ {i}_{csf}\end{array}\right]$For the stator winding deltaconnection, line currents are calculated based on phase currents using the following equations:
$\left[\begin{array}{c}{i}_{as}\\ {i}_{bs}\end{array}\right]=\left[\begin{array}{cc}2& 1\\ 1& 1\end{array}\right]\left[\begin{array}{c}{i}_{asf}\\ {i}_{bsf}\end{array}\right]$ ${i}_{cs}=\left[\begin{array}{cc}1& 1\end{array}\right]\left[\begin{array}{c}{i}_{as}\\ {i}_{bs}\end{array}\right]$Calculated line currents i_as and i_bs determine the value of controlled current sources in the substitute stator circuit shown in Figure 14.