> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/machine-section/pmsm-sh-section.md).

# PMSM SH Section

## Overview

The PMSM SH model defines the Inductance Matrices Ld and Lq within a three-dimensional table stored in an RTT motor model file. Because the tables are three-dimensional rather than two-dimensional, the PMSM SH model can provide higher fidelity than the PMSM BLDC model. Please see [Permanent Magnet Synchronous Machine Models Comparison](broken://pages/4f4b84bf93421a920cb8d5389848b6a0a0f89a0d) for a comparison of the PMSM SH and PMSM BLDC models.

## Model Description

Permanent Magnet Synchronous Machines are common electrical machines in the the automotive and transportation industry. The PMSM is usually chosen because of its excellent power density (produced power over size or weight) or its capability to reach higher speed than other machine types. However, controlling a PMSM is usually more challenging when compared to other machine types. Since it is a synchronous machine, the controller must be aware of the rotor position at all times in order to properly control the torque. In addition, there is a chance of de-fluxing the magnet if the control is not stable, which would lead to a modification of the machine properties.

The following figures illustrate the equivalent circuits of the PMSM machine model in the *abc* frame and in the *dq* frame.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2Fk1YmRh0lMcOCmGh76Qpj%2F1f58655d-34a0-4a43-bd65-1c9409a613d0.png?alt=media&amp;token=8627dc87-b323-4773-8791-ff8080fe87bb" alt=""><figcaption><p>Figure 1. Electrical model for the PMSM in the three-phase domain (left) and in the dq reference frame (right)</p></figcaption></figure>

### General Equation <a href="#general-equation" id="general-equation"></a>

The equation of the PMSM model can be expressed as follows:

$$
\\\[8pt]
I\_{abc}
\= \left\[L\_{abc}(\theta\_e)\right]^{-1}
\left{
\int \left(V\_{abc} - R\_{abc} I\_{abc}\right), dt

* \psi\_{abc}
  \right}
  \\\[8pt]
  $$

where **L**<sub>**abc**</sub> is the time-varying inductance matrix (global inductance for Constant Ld/Lq and Variable Ld/Lq models), **I**<sub>**abc**</sub> is the stator current inside the winding, **R**<sub>**abc**</sub> are the stator resistances and **V**<sub>**abc**</sub> is the voltage across the stator windings. **ψ**<sub>**abc**</sub> defines the magnet flux linked into the stator windings.

### Electrical Angle <a href="#inlineextension-electrical-angle" id="inlineextension-electrical-angle"></a>

The electrical angle is expressed as follows:

$$
\theta\_e = pp \* \theta\_m
$$

### Reference Frame Transformation <a href="#inlineextension-reference-frame-transformation" id="inlineextension-reference-frame-transformation"></a>

A Park-Clarke transformation, described below, is applied to the three-phase (*abc*) signals to obtain a direct-quadrature *(dq*) rotating reference frame locked to the **Electrical Angle**, **θ**<sub>**e**</sub>. An offset may be applied to the transform angle using the **DQ Transform Angle Offset** parameter, **θ**<sub>**offset**</sub>.

$$
\begin{pmatrix} V\_d \ V\_q \end{pmatrix} = T \begin{pmatrix} V\_a \ V\_b \ V\_c \end{pmatrix} \\\[8pt] T = \sqrt{\frac{2}{3}} \begin{pmatrix} \cos(\theta\_e + \theta\_{offset}) & \sin(\theta\_e + \theta\_{offset}) \ -\sin(\theta\_e + \theta\_{offset}) & \cos(\theta\_e + \theta\_{offset}) \end{pmatrix} \begin{pmatrix} 1 & -\tfrac{1}{2} & -\tfrac{1}{2} \ 0 & \tfrac{\sqrt{3}}{2} & -\tfrac{\sqrt{3}}{2} \end{pmatrix} \\\[8pt]
$$

The transformation reduces sinusoidal varying quantities of inductances, flux, current, and voltage to constant values in the *dq* frame, thus greatly facilitating the analysis and control of the device under study.\
It is important to note that there are many different types of transforms and this often leads to confusion when interpreting the machine states in the *dq* frame. The one used here, which is typically standard in Japan, presents the advantage of being orthonormal (notice the $$\sqrt{\frac{2}{3}} \\\[8pt]$$ factor). This particular orthonormal transform is power-invariant, meaning that the power computed in the *dq* frame by performing a dot product of currents and voltages is equivalent to the one computed in the three-phase domain, namely:

$$
V\_{abc}, I\_{abc} = V\_{dq}, I\_{dq} \\\[8pt]
$$

The principle of the reference frame transformation is illustrated in Figure 2. Consider a fixed, three-phase reference frame *abc* with all machine quantities rotating at the electric frequency **ω**. If we observe these quantities in a *dq* frame rotating at the same speed, the quantities will remain constant. In this figure, the angle **θ** represents the angular position of the rotating frame, whose *d*-axis is aligned with Phase A at **t** = 0. This indicates that the **DQ Transform Angle Offset** is 0°. The back-EMF voltage ***V***<sub>***bemf***</sub> directly follows the *q*-axis because the magnet flux is aligned with the *d*-axis by definition. The machine current ***I*** leads ***V***<sub>***bemf***</sub> and the *q*-axis by an angle called ***β***.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2Fw4veVe0YT8rQQHgoqwzB%2F12f80b4e-c1e6-4908-b002-c74cf81f938a.png?alt=media&amp;token=6679aaff-90bb-4c79-8c09-22c8a5b15800" alt=""><figcaption><p>Figure 2: <em>abc</em> to <em>dq</em> reference frame transformation</p></figcaption></figure>

### Torque <a href="#inlineextension-torque" id="inlineextension-torque"></a>

For the transform described in the previous equations, the **Electromagnetic Torque** can be expressed by the following equation, where ***pp*** is the number of **Pole Pairs** and $$\frac{\partial \psi\_{abc}}{\partial \theta\_r} \\\[8pt]$$is the partial derivative of the instantaneous permanent magnet flux.

$$
T\_e = pp \left\[ I\_{abc}, \frac{\partial \psi\_{abc}}{\partial \theta\_r} + (L\_d - L\_q), i\_d, i\_q \right] \\\[8pt]
$$

If the back EMF of the machine is sinusoidal, as is the default case for PMSM machines, the torque can be further simplified.

$$
T\_e = pp \left\[ \sqrt{\frac{3}{2}}, \psi\_M, i\_q + (L\_d - L\_q), i\_d, i\_q \right] \\\[8pt]
$$

Because this model uses the orthonormal *abc* to *dq* transform, the previous equations do not contain the $$\frac{3}{2} \\\[8pt]$$ factor typically present in other PMSM torque equations.

### Power <a href="#inlineextension-power" id="inlineextension-power"></a>

The instantaneous active and reactive power, **P** and **Q**, are calculated in the model as follows:

$$
P = V\_a I\_a + V\_b I\_b + V\_c I\_c \\\[8pt]

Q = \frac{1}{\sqrt{3}}
\left\[
(V\_b - V\_c), I\_a

* (V\_c - V\_a), I\_b
* (V\_a - V\_b), I\_c
  \right]
  \\\[8pt]
  $$

where V<sub>a</sub>, V<sub>b</sub>, and V<sub>c</sub> are the instantaneous stator voltages.

The results are processed through low-pass filters before being written to the **Three-Phase Active Power** and **Three-Phase Reactive Power** channels. The cutoff frequency of the filters is calculated as follows, where **T**<sub>**s**</sub> is the machine timestep. If the machine timestep is 120ns, for instance, the cutoff frequency is 133Hz.

$$
f\_c
====

# \frac{1}{1 \times 10^{4} \times T\_s \times 2\pi}

# \frac{1}{1 \times 10^{4} \times 120 \times 10^{-9} \times 2\pi}

133,Hz
\\\[8pt]
$$

## Parameters

In the **System Explorer** window configuration tree, expand the **Power Electronics Add-On** custom device and select **Circuit Model >> PMSM SH** to display this page and configure the PMSM SH machine model.

This page includes the following components, configurable at edit-time only:

### Machine Model Settings

<table><thead><tr><th width="200.28887939453125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Specifies the name of the machine model.</td></tr><tr><td><strong>Description</strong></td><td>Specifies a description for the machine model.</td></tr></tbody></table>

### Machine Configuration

<table><thead><tr><th width="199.66668701171875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Model File</strong></td><td><p>Specifies the path to the 3D Machine Model file on disk. Refer to <a href="https://www.opal-rt.com/docs/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/machine-section/machine-configuration-files/jmag-rt-rtt-file-generation-recommendations.md"><strong>JMAG-RT RTT File Generation Recommendations</strong></a> for details regarding the file format. The following standards are supported:</p><ul><li>JMAG (.rtt)</li><li>ANSYS (.json) (Please contact <a href="https://www.opal-rt.com/contact-technical-support/"><strong>OPAL-RT Support</strong></a> for more information about the ANSYS option)</li></ul></td></tr><tr><td><strong>Enable</strong></td><td><p>Indicates whether the selected machine model is enabled. When a machine is enabled, it computes and generates output data at the specified <strong>Applied Solver Timestep</strong>.</p><p>It is recommended to disable unused machines, as the number of enabled machines impacts the minimum achievable timestep of the solver.</p><p>(Default Value: True).</p></td></tr><tr><td><strong>Initial Angle</strong></td><td><p>Initial Angle of the machine</p><p>This may be useful when simulating two separate 3-phase machines that require a phase shift between them,</p><p>θ<sub>0</sub> (deg) (Default Value: 0<strong>°</strong>).</p></td></tr><tr><td><strong>Enable Advanced Channels</strong></td><td><p>Allows certain parameters to be exposed as tunable VeriStand Channels. See the <strong>Advanced Channels</strong> section below for more details.</p><p>This checkbox is only available when the machine is enabled. Otherwise, the option is greyed out.</p></td></tr><tr><td><strong>Applied Solver Timestep</strong></td><td><p>The timestep at which the machine model executes.</p><p>New outputs are computed by the FPGA machine model at each timestep.</p><p>If <strong>Optimize Solver Timesteps</strong> is enabled in the Circuit Model page, the <strong>Applied Solver Timestep</strong> is automatically set to an optimal value and cannot be edited.</p><p>If <strong>Optimize Solver Timesteps</strong> is disabled, this value must be set to a multiple of 50ns equal to or greater than the <strong>Minimum Solver Timestep (s)</strong> (400ns), and less than 2.5us, T<sub>s</sub> (s).</p></td></tr><tr><td><strong>Minimum Solver Timestep</strong></td><td>The minimum achievable timestep at which the machine model can execute, T<sub>sm</sub> (s).</td></tr><tr><td><strong>Table Max Current</strong></td><td>Maximum current value that will be used to interpolate the model file. Use this feature to increase the resolution of the machine at lower Current operating points. This will reduce the machine operating range. Use -1 to use the full range available in model file, (A)</td></tr><tr><td><strong>DQ Angle Offset</strong></td><td><p>The electrical angle offset applied to the Reference Frame Transformation.</p><p>Setting this parameter to 0° indicates that the <em>d</em>-axis is aligned with Phase A when the electrical angle <strong>θ</strong><sub><strong>e</strong></sub> = 0°. This is illustrated in Figure 2.</p><p>Setting this parameter to -90° indicates that the <em>q</em>-axis is aligned with Phase A when the electrical angle <strong>θ</strong><sub><strong>e</strong></sub> = 0°,</p><p>θ<sub>offset</sub> (deg) (Default Value: 0<strong>°</strong>).</p></td></tr></tbody></table>

### Input Mapping Configuration

Use the Input Mapping Configuration to route signals to the **Voltage Phase A**, **Voltage Phase B**, and **Voltage Phase C** inputs of the machine model. Available routing options may vary depending on the selected [**Hardware Configuration**](https://www.opal-rt.com/docs/pe-add-on-simulink/hardware-configurations-reference/default-hardware-configurations.md).

<table><thead><tr><th width="199.5333251953125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Group</strong></td><td><p>Specifies the group that will be routed to the input voltages of the machine. The available routing options are defined by the selected Hardware Configuration, however it is typical to see the following options by default:</p><ul><li><strong>Measurements</strong> - eHS circuit model measurements</li></ul></td></tr><tr><td><strong>Element</strong></td><td>Specifies the index of the measurement in the group that has been selected as the input voltage of the machine.</td></tr></tbody></table>

## Section Channels

This section includes the following custom device channels:

<table><thead><tr><th width="201.022216796875">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Current Phase A</strong></p><p><strong>(Output)</strong></p></td><td>Phase A current measured at the stator, I<sub>a</sub> (A).</td></tr><tr><td><p><strong>Current Phase B</strong></p><p><strong>(Output)</strong></p></td><td>Phase B current measured at the stator, I<sub>b</sub> (A).</td></tr><tr><td><p><strong>Current Phase C</strong></p><p><strong>(Output)</strong></p></td><td>Phase C current measured at the stator, I<sub>c</sub> (A).</td></tr><tr><td><p><strong>Average Voltage Phase A</strong></p><p><strong>(Output)</strong></p></td><td><p>Averaged Phase A voltage measured at the stator. The voltage is processed through a low-pass filter with a cutoff frequency of 159 Hz, V<sub>a,avg</sub> (V).</p><p><span class="math">\\[8pt] f_c = \frac{1}{2\pi \times 1e-3} = 159\,\text{Hz} \\[8pt]</span></p></td></tr><tr><td><p><strong>Average Voltage Phase B</strong></p><p><strong>(Output)</strong></p></td><td>Averaged Phase B voltage measured at the stator. The voltage is processed through a low-pass filter with a cutoff frequency of 159 Hz, V<sub>b,avg</sub> (V).</td></tr><tr><td><p><strong>Average Voltage Phase C</strong></p><p><strong>(Output)</strong></p></td><td>Averaged Phase C voltage measured at the stator. The voltage is processed through a low-pass filter with a cutoff frequency of 159 Hz, V<sub>c,avg</sub> (V).</td></tr><tr><td><p><strong>Three-Phase Active Power</strong></p><p><strong>(Output)</strong></p></td><td>Three-phase instantaneous active electrical power. See the <a href="#Power">Power</a> section for more information on how this value is calculated, P (W).</td></tr><tr><td><p><strong>Three-Phase Reactive Power</strong></p><p><strong>(Output)</strong></p></td><td>Three-phase instantaneous reactive electrical power. See the <a href="#Power">Power</a> section for more information on how this value is calculated, Q (VAR).</td></tr><tr><td><p><strong>Direct Axis Stator Current</strong></p><p><strong>(Output)</strong></p></td><td>Direct-axis stator current in the dq reference frame aligned with the rotor. For a description of the abc to dq transform used to compute this value, see Reference Frame Transformation, I<sub>d</sub> (A).</td></tr><tr><td><p><strong>Quadrature Axis Stator Current</strong></p><p><strong>(Output)</strong></p></td><td>Quadrature-axis stator current in the dq reference frame aligned with the rotor. For a description of the abc to dq transform used to compute this value, see Reference Frame Transformation, I<sub>q</sub> (A).</td></tr><tr><td><p><strong>Electrical Angle</strong></p><p><strong>(Output)</strong></p></td><td>Position of the rotating magnetic field, as defined by the Electrical Angle Equation. If this signal is routed to a <strong>Waveform Channel</strong> or an <strong>Analog Output Channel</strong>, its value is expressed in Turns. The signal ranges in value from 0 to 1, with 1 representing a full rotation, θ<sub>e</sub> (deg).</td></tr><tr><td><p><strong>Electromagnetic Torque</strong></p><p><strong>(Output)</strong></p></td><td>Torque generated through power at the stator. Refer to the <strong>Torque</strong> section for more information, T<sub>e</sub> (Nm).</td></tr></tbody></table>

### Advanced Channels

The following VeriStand channels are displayed under the **Advanced** section when the **Enable Advanced Channels** option is enabled on the PMSM SH configuration page. The value of an input channel can be modified dynamically at execution time.

<table><thead><tr><th width="198.5333251953125">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Enable Resistance Override</strong></p><p><strong>(Input)</strong></p></td><td><p>Enables the <strong>Resistance Phase A Override, Resistance Phase B Override,</strong> and <strong>Resistance Phase C Override</strong> channels, allowing the user to modify the phase resistances of the machine while the simulation is running. When True, the phase resistances of the machine are read from the override channels. When False, the phase resistances are read from the table in the 3D Motor Model File. Enabling these channels allows the user to reduce the machine signal error in high impedance conditions.</p><p>Refer to <a href="https://www.opal-rt.com/docs/pe-add-on-simulink/simulation-control-monitoring-and-logging/reduce-pmsm-sh-signal-error-in-high-impedance-conditions.md">Reduce PMSM SH Signal Error In High Impedance Conditions</a> for more information. (Default Value: False)</p></td></tr><tr><td><p><strong>Resistance Phase A Override</strong></p><p><strong>(Input)</strong></p></td><td>Phase A resistance of the machine. When <strong>Enable Resistance Override</strong> is True, this value overrides the Phase A resistance value defined in the 3D Motor Model File. When False, this channel is not used. This channel value can be modified while the simulation is running, R<sub>a</sub> (Ω) (Default Value: 0.12)</td></tr><tr><td><p><strong>Resistance Phase B Override</strong></p><p><strong>(Input)</strong></p></td><td>Phase B resistance of the machine. When <strong>Enable Resistance Override</strong> is True, this value overrides the Phase B resistance value defined in the 3D Motor Model File. When False, this channel is not used. This channel value can be modified while the simulation is running, R<sub>b</sub> (Ω) (Default Value: 0.12)</td></tr><tr><td><p><strong>Resistance Phase C Override</strong></p><p><strong>(Input)</strong></p></td><td>Phase C resistance of the machine. When <strong>Enable Resistance Override</strong> is True, this value overrides the Phase C resistance value defined in the 3D Motor Model File. When False, this channel is not used. This channel value can be modified while the simulation is running, R<sub>c</sub> (Ω) (Default Value: 0.12)</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/machine-section/pmsm-sh-section.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
