# Permanent Magnet Synchronous Machine with Salient Rotor

Description of the three-phase 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 three-phase permanent magnet synchronous machine in real-time. This modeling approach can be used for describing the dynamics of a permanent magnet synchronous machine with a salient or a cylindrical rotor.

Table 1. Permanent magnet synchronous machine component in HIL Toolbox
component component dialog window component parameters
• Property tabs:
• Electrical
• Mechanical
• Feedback
• Snubber

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 sub-system model

The electrical part of the machine is represented by a second-order state-space 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 d-axis 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]$
Table 2. The permanent magnet synchronous machine electrical subsystem model variables
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 sub-system model

The mechanical part of the machine is represented by a second-order state-space model:

$\stackrel{̇}{{\omega }_{m}}=\frac{1}{{J}_{m}}\left({T}_{e}-{T}_{L}\right)$ $\stackrel{̇}{{\theta }_{m}}={\omega }_{m}$ ${T}_{e}=\frac{3}{2}p\left({\lambda }_{ds}{i}_{qs}-{\lambda }_{qs}{i}_{ds}\right)$
Table 3. The permanent magnet synchronous machine mechanical subsystem model variables
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 d-axis current values
${iqvector}_{}$ list of q-axis current values
${psidtable}_{}$ d-axis flux linkage lookup table
${psiqtable}_{}$ q-axis flux linkage lookup table
${Ldtable}_{}$ d-axis inductance lookup table
${Lqtable}_{}$ q-axis 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.

Saturation can be parametrized in the following ways:
1. fluxes vs stator currents
2. absolute inductances vs stator currents
3. incremental inductances vs stator currents
In each of these cases the d-axis and q-axis flux or inductance can depend on both stator currents or only on the corresponding stator current. When fluxes or inductances are functions of both d-axis and q-axis currents, it is important to define the lookup tables as nested Python lists where the number of inner lists must be equal to the number of elements in the current id vector and the number of elements of each inner list must be equal to the number of elements in the current iq vector. Examples of parametrization using the Model Initialization script are given below.

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}_{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}$

Table 4. The permanent magnet synchronous machine iron losses variables
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
Note: The iron losses option is available only if nonlinear - spatial harmonic is chosen as model type.

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]
machine viscous friction coefficient [Nms]

In this block tab, the external load settings can be specified. Its layout is shown here:

## Permanent magnet synchronous machine mechanical parameters

symbol description
External load type: torque or speed
assigned offset value to the input signal representing external torque command
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\left(ai_pin_addr\right)+offset\right)$

## 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
incremental encoder number of pulses per revolution
resolver number of pole pairs
resolver carrier signal source selection (internal or external)
resolver carrier signal frequency (internal carrier)
resolver carrier input channel offset
resolver carrier input channel gain
Note: This part does not specify model output variables like machine voltages, currents and fluxes.
Note: While the machine speed is positive, the encoder channel B signal leads the encoder channel A signal.

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 d-axis 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 a-axis (used by default, and indicated in a) Figure 12). The second one is where the alpha axis is aligned with the stator phase a-axis (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:

Table 5. Permanent magnet synchronous machine output parameters
symbol description
signal processing output execution rate
machine electrical torque
machine mechanical angular speed
machine mechanical angle
alpha component of stator current
beta component of stator current
direct axis component of stator current
quadrature axis component of stator current
alpha component of stator flux
beta component of stator flux
direct axis component of stator flux
quadrature axis component of stator flux

## Model outputs

Table 6. Variables for permanent magnet synchronous machine model
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 astar-winding 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 three-phase 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 dq-components (v_ds nad v_qs) using the well-known 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 sub-system model are formed, and state- and output-variables are calculated. State variables are machine stator fluxes on the d- and q-axis (psi_ds and psi_qs) and output variables are stator current dq-components (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 dq-components 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 star-connection, 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 delta-connection, 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.