> 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/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/machines/generic-machines.md).

# Generic Machines

## Description

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-3d70849330fc9411beff9fd7ab200f66a35db15c%2Fmachine-block-ehs-sps.png?alt=media" alt="" width="195"><figcaption></figcaption></figure>

The **Machine** blocks, located in the **eFPGAsim/External circuit editor workflow/Machines** library, processes the communication and configuration between the RT-LAB CPU-based model and the FPGA-based Electrical Machine model.

This section describes **six different blocks** and their functionality:

* Synchronous Machine
* Doubly-fed Induction Machine
* Squirrel-cage Induction Machine
* Permanent Magnet Synchronous Machine DQ (PMSM)
* Brushless DC Motor (BDC)
* Generic Machine

## Mask parameters

{% columns %}
{% column %}

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-7ae463febb95dc778793d9a086b527d6b4e6a066%2Fehs-synchrnousmachine-mask-general.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endcolumn %}

{% column %}

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-1fdec6299e630b6606cfbc5d6b9f5c2f586dfa1d%2Fehs-synchrnousmachine-mask-machine.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endcolumn %}
{% endcolumns %}

{% tabs %}
{% tab title="General" %}

<table data-search="false"><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Block mode</strong></td><td><p>Select which type of FPGA-based machine model that is available in the firmware. It supports:</p><ul><li><strong>Quad generic machine model</strong> mode for simulation of up to 4 Synchronous Machine or Asynchronous machine models.</li><li><strong>Dual PMSM Variable DQ</strong> mode for simulation of up to 2 Permanent Magnet Synchronous Machine or Brushless DC motor models.</li></ul><p>Once selected, the available model types are refreshed in all machine tabs. This parameter applies globally to the block</p></td></tr><tr><td><strong>Number of Machines</strong></td><td>Number of machines (up to 4 for Generic Machine mode, up to 2 for PMSM modes) can be selected.</td></tr><tr><td><strong>Solver Time Step [Ts(sec)]</strong></td><td>Time step of the FPGA solver of the Generic Machines in seconds. It is 500ns by default.</td></tr><tr><td><strong>Hardware Controller Name (OpCtrl)</strong></td><td>FPGA controller name that refers to the motor model bitstream (in OpCtrl or Oplnk block). It is usually 'OpCtrl'.</td></tr><tr><td><strong>FPGA Clock Period [Tfpga(sec)]</strong></td><td>The clock period of the FPGA. It is 5ns by default.</td></tr><tr><td><strong>CPU Clock Period [Tcpu(sec)]</strong></td><td>The time step of the CPU model. It is 20μs by default.</td></tr><tr><td><strong>Communications Settings Automatic Configuration</strong></td><td>Enable the automatic setting of the communications ports.<br>The *.conf file linked to the *.bin file selected in the OpCtrl Controller will be parsed and the communications settings will be set accordingly.<br>If unchecked, the fields become modifiable for manual user settings.</td></tr><tr><td><strong>Machine Core</strong></td><td>If Communications Settings Automatic Configuration is enabled, Machine Core allows the selection of which machine defined in the *.conf to use for automatic configuration.</td></tr><tr><td><strong>Configuration Port Number: Data In/Load In/Data Out port</strong></td><td>Number of communication ports from/to FPGA to send/receive solver data. Port numbers depend on the bitstream. See the associated bitstream *.conf file to get the right port numbers. These parameters should be updated at every firmware update.</td></tr></tbody></table>

The **description keys** to look depend on the selected block mode:

* For Generic machine mode, the description key used is IM\_SM
* For PMSM Vdq mode, the description key used if PMSMVDQ
  {% endtab %}

{% tab title="Machine #1" %}
Based on the number of machines selected in the General tab, a corresponding machine tab is created for each machine. Each machine tab contains the following sections: Configuration, Electrical Parameters, Mechanical Parameters, Resolver Parameters, and Encoder Parameters.

<table><thead><tr><th valign="top">Parameter / Button</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><strong>Machine Type</strong></td><td><p>Machine and its rotor type can be selected.</p><p>When the <strong>Quad generic machine model</strong> is selected</p><ul><li>Synchronous Machine Round Rotor</li><li>Synchronous Machine Salient-pole Rotor</li><li>Doubly-fed Induction Machine</li><li>Induction Machine with Squirrel-cage or Double Squirrel-cage</li></ul><p>If <strong>Dual PMSM Constant DQ</strong> is selected:</p><ul><li>"Fixed Ld Lq values" for PMSM with salency simulation</li><li>"BLDC" for brushless dc motor emulation with trapezoidal back emf.</li></ul></td></tr><tr><td valign="top"><strong>Configure Machine Inputs</strong></td><td><p>Opens a voltage mapping table for each machine as follows:</p><ul><li><strong>Input Name</strong> shows the stator and rotor (if applicable) supply voltage names for the selected machine type and rotor type,</li><li>I<strong>nput Source</strong> gives the option of selecting between different available eHS sources,</li><li><strong>Measurement Index</strong> is to assign the eHS indexed measurement to the corresponding machine input.</li></ul><p>For Synchronous Machine:</p><p>For Doubly-fed (Wound Rotor) Induction Machine:</p><p><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-f82fa957d518c518b588ad6f2900f8e7f67fc364%2Fehs-syncghrounousmachine-config-machine-2.png?alt=media" alt="" data-size="original"></p><p>For Induction Machine with Squirrel-cage Rotor, PMSM or BLDC</p><p><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-625d38e206775c2b61cd0c2bab18b02a658f37e6%2Fehs-syncghrounousmachine-config-machine-1.png?alt=media" alt="" data-size="original"></p></td></tr><tr><td valign="top"><strong>Electrical parameters</strong></td><td>Depend on the machine type. Refer to the relevant section for more information about the parameters.</td></tr><tr><td valign="top"><strong>Mechanical parameters</strong></td><td>Depend on the machine type. Refer to the relevant section for more information about the parameters.</td></tr><tr><td valign="top"><strong>Resolver and encoder parameters</strong></td><td>Depend on the machine type. Refer to the relevant section for more information about the parameters.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

### Configure eHS inputs

In the [**eHS CPU**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/ehs-cpu-block.md) block, go to the **Inputs** tab and click **Configure Inputs** to open the **eHS Input Configuration** window.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-7cfc9a104977c7eec4dcc43ff77afa3b68646bba%2Fehs-machine-inputs-config.png?alt=media" alt="" width="389"><figcaption></figcaption></figure>

eHS inputs mapping could be different for each type of machine.

<details>

<summary>For Synchronous Machine</summary>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-7c87bab4d478806ee1bfba8f816555afeadeb8f5%2Fehs-genericmachine-ehsmapping-synchromachine.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>For Doubly-fed (Wound Rotor) Induction Machine</summary>

Stator currents and rotor currents should be mapped.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a439be96a3ed0cdf3e43afa83db8fc7583bc8332%2Fehs-genericmachine-ehsmapping-dfim.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>For Induction Machine with Squirrel-cage Rotor</summary>

Stator currents should be mapped.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-135b4b9d0cf56482f48e6af534189d1d48f3f337%2Fehs-genericmachine-ehsmapping-im.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

<details>

<summary>For PMSM or BLDC</summary>

Stator currents should be mapped. Since the model supports only balanced mode, only 2 currents needs to be injected to the eHS.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-146d9c4466fd9ce399808464b43dbe4a88dddc4f%2Fehs-genericmachine-ehsmapping-pmsm-bldc.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

For measurement index, eight current measurements channels are assigned for each machine, while up to the first six of them could output current values during real-time simulation. Refer to the following tables for the right signal indexes.

<details>

<summary>Generic machines</summary>

<table data-search="false"><thead><tr><th>Index</th><th>Current Sources</th><th>notes</th></tr></thead><tbody><tr><td><strong>1</strong></td><td>Machine #1 Ia Stator Current</td><td><br><br></td></tr><tr><td><strong>2</strong></td><td>Machine #1 Ib Stator Current</td><td><br><br></td></tr><tr><td><strong>3</strong></td><td>Machine #1 Ic Stator Current</td><td><br><br></td></tr><tr><td><strong>4</strong></td><td>Machine #1 Ia Rotor Current</td><td>SM #1 Field Rotor Current</td></tr><tr><td><strong>5</strong></td><td>Machine #1 Ib Rotor Current</td><td>Not available for SM #1</td></tr><tr><td><strong>6</strong></td><td>Machine #1 Ic Rotor Current</td><td>Not available for SM #1</td></tr><tr><td><strong>7/8</strong></td><td>Reserved for internal use</td><td><br><br></td></tr><tr><td><strong>9</strong></td><td>Machine #2 Ia Stator Current</td><td><br><br></td></tr><tr><td><strong>10</strong></td><td>Machine #2 Ib Stator Current</td><td><br><br></td></tr><tr><td><strong>11</strong></td><td>Machine #2 Ic Stator Current</td><td><br><br></td></tr><tr><td><strong>12</strong></td><td>Machine #2 Ia Rotor Current</td><td>SM #2 Field Rotor Current</td></tr><tr><td><strong>13</strong></td><td>Machine #2 Ib Rotor Current</td><td>Not available for SM #2</td></tr><tr><td><strong>14</strong></td><td>Machine #2 Ic Rotor Current</td><td>Not available for SM #2</td></tr><tr><td><strong>15/16</strong></td><td>Reserved for internal use</td><td><br><br></td></tr><tr><td><strong>17</strong></td><td>Machine #3 Ia Stator Current</td><td><br><br></td></tr><tr><td><strong>18</strong></td><td>Machine #3 Ib Stator Current</td><td><br><br></td></tr><tr><td><strong>19</strong></td><td>Machine #3 Ic Stator Current</td><td><br><br></td></tr><tr><td><strong>20</strong></td><td>Machine #3 Ia Rotor Current</td><td>SM #3 Field Rotor Current</td></tr><tr><td><strong>21</strong></td><td>Machine #3 Ib Rotor Current</td><td>Not available for SM #3</td></tr><tr><td><strong>22</strong></td><td>Machine #3 Ic Rotor Current</td><td>Not available for SM #3</td></tr><tr><td><strong>23/24</strong></td><td>Reserved for internal use</td><td><br><br></td></tr><tr><td><strong>25</strong></td><td>Machine #4 Ia Stator Current</td><td><br><br></td></tr><tr><td><strong>26</strong></td><td>Machine #4 Ib Stator Current</td><td><br><br></td></tr><tr><td><strong>27</strong></td><td>Machine #4 Ic Stator Current</td><td><br><br></td></tr><tr><td><strong>28</strong></td><td>Machine #4 Ia Rotor Current</td><td>SM #4 Field Rotor Current</td></tr><tr><td><strong>29</strong></td><td>Machine #4 Ib Rotor Current</td><td>Not available for SM #4</td></tr><tr><td><strong>30</strong></td><td>Machine #4 Ic Rotor Current</td><td>Not available for SM #4</td></tr><tr><td><strong>31/32</strong></td><td>Reserved for internal use</td><td></td></tr></tbody></table>

</details>

<details>

<summary>PMSM Constant DQ</summary>

| Index | Current Sources              | Notes           |
| ----- | ---------------------------- | --------------- |
| 1     | Machine #1 Ia Stator Current | <p><br><br></p> |
| 2     | Machine #1 Ib Stator Current | <p><br><br></p> |
| 3     | Machine #2 Ia Stator Current | <p><br><br></p> |
| 4     | Machine #2 Ia Rotor Current  |                 |

{% hint style="info" %}
Ic current is not available for coupling eHS with PMSM VDQ model since the model supports balanced mode only.
{% endhint %}

</details>

### Electrical Parameters

<details>

<summary>Synchronous Machine with Round Rotor</summary>

This configuration enables the dynamic modeling of a **Round Rotor Synchronous Machine**, including the stator, field winding, and up to three damper windings: one on the **D-axis (Kd)** and two on the **Q-axis (Kq1 and Kq2)**. All rotor parameters are referred to the stator side and are denoted by a prime (′) symbol. Selecting the **Open Winding** option allows the star-connected stator winding to include a neutral-point connection. The mask and electrical parameters of the **Round Rotor Synchronous Machine** are presented below.

<table data-search="false"><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="79.5968017578125">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Lls</strong></td><td>Stator leakage inductance</td><td>Per-phase stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Lmd</strong></td><td>D-axis magnetizing inductance</td><td>Magnetizing inductance in direct-axis direction</td><td>H</td></tr><tr><td><strong>Lmq</strong></td><td>Q-axis magnetizing inductance</td><td>Magnetizing inductance in quadrature-axis direction</td><td>H</td></tr><tr><td><strong>Rfd'</strong></td><td>Field resistance</td><td>Direct-axis field winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llfd'</strong></td><td>Stator leakage inductance</td><td>Direct-axis field winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Rkd'</strong></td><td>D-axis damper resistance</td><td>Direct-axis damper winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llkd'</strong></td><td>D-axis damper leakage inductance</td><td>Direct-axis damper winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Rkq1'</strong></td><td>1st q-axis damper resistance</td><td>1st quadrature-axis damper winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llkq1'</strong></td><td>1st q-axis damper leakage inductance</td><td>1st quadrature-axis damper winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Rkq2'</strong></td><td>2nd q-axis damper resistance</td><td>2nd quadrature-axis damper winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llkq2'</strong></td><td>2nd q-axis damper leakage inductance</td><td>2nd quadrature-axis damper winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Nsf</strong></td><td>Stator to field turn ratio</td><td>This turn ratio is used when the voltage ratio between the stator and the field is not unitary</td><td>-</td></tr><tr><td><strong>R0</strong></td><td>Zero-sequence resistance</td><td>Zero-sequence stator winding resistance</td><td>Ω</td></tr><tr><td><strong>L0</strong></td><td>Zero-sequence inductance</td><td>Zero-sequence stator winding leakage inductance</td><td>H</td></tr></tbody></table>

</details>

<details>

<summary>Synchronous Machine with Salient-pole Rotor</summary>

This configuration enables the dynamic modeling of a **Salient-Pole Rotor Synchronous Machine**, including the stator, field winding, and up to two damper windings: one on the **D-axis (Kd)** and one on the **Q-axis (Kq1)**. All rotor parameters are referred to the stator side and are denoted by a prime (′) symbol. Selecting the **Open Winding** option allows the star-connected stator winding to include a neutral-point connection.

<table data-search="false"><thead><tr><th width="80.20001220703125">Symbol</th><th>Name</th><th>Description</th><th width="79.596923828125">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Lls</strong></td><td>Stator leakage inductance</td><td>Per-phase stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Lmd</strong></td><td>D-axis magnetizing inductance</td><td>Magnetizing inductance in direct-axis direction</td><td>H</td></tr><tr><td><strong>Lmq</strong></td><td>Q-axis magnetizing inductance</td><td>Magnetizing inductance in quadrature-axis direction</td><td>H</td></tr><tr><td><strong>Rfd'</strong></td><td>Field resistance</td><td>Direct-axis field winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llfd'</strong></td><td>Stator leakage inductance</td><td>Direct-axis field winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Rkd'</strong></td><td>D-axis damper resistance</td><td>Direct-axis damper winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llkd'</strong></td><td>D-axis damper leakage inductance</td><td>Direct-axis damper winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Rkq1'</strong></td><td>1st q-axis damper resistance</td><td>1st quadrature-axis damper winding resistance, referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llkq1'</strong></td><td>1st q-axis damper leakage inductance</td><td>1st quadrature-axis damper winding leakage inductance, referred to the stator</td><td>H</td></tr><tr><td><strong>Nsf</strong></td><td>Stator to field turn ratio</td><td>This turn ratio is used when the voltage ratio between the stator and the field is not unitary</td><td>-</td></tr><tr><td><strong>R0</strong></td><td>Zero-sequence resistance</td><td>Zero-sequence stator winding resistance</td><td>Ω</td></tr><tr><td><strong>L0</strong></td><td>Zero-sequence inductance</td><td>Zero-sequence stator winding leakage inductance</td><td>H</td></tr></tbody></table>

</details>

<details>

<summary>Induction Machine with Squirrel-Cage Rotor</summary>

This configuration enables the dynamic modeling of a **Squirrel-Cage Induction Machine**, including the stator winding and squirrel-cage rotor. All rotor parameters are referred to the stator and are denoted by a prime (′) symbol. Selecting the **Open Winding** option provides access to each stator winding terminal, enabling neutral (wye) or delta stator connections.

<table data-search="false"><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="79.596923828125">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Lls</strong></td><td>Stator leakage inductance</td><td>Per-phase stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Rr'</strong></td><td>Rotor resistance</td><td>Per-phase equivalent rotor winding resistance referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llr'</strong></td><td>Rotor leakage inductance</td><td>Per-phase equivalent rotor winding leakage inductance referred to the stator</td><td>H</td></tr><tr><td><strong>Lm</strong></td><td>Mutual inductance</td><td>Stator-rotor mutual (magnetizing) inductance</td><td>H</td></tr><tr><td><strong>R0</strong></td><td>Zero-sequence resistance</td><td>Zero-sequence stator winding resistance</td><td>Ω</td></tr><tr><td><strong>L0</strong></td><td>Zero-sequence inductance</td><td>Zero-sequence stator winding leakage inductance</td><td>H</td></tr></tbody></table>

</details>

<details>

<summary>Induction Machine with Double Squirrel-cage Rotor</summary>

This configuration enables the dynamic modeling of a **Double Squirrel-Cage Induction Machine**, including the stator winding and the two rotor squirrel cages. All rotor parameters are referred to the stator and are denoted by a prime (′) symbol.

<table data-search="false"><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="79.596923828125">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Lls</strong></td><td>Stator leakage inductance</td><td>Per-phase stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Rr1'</strong></td><td>Cage 1 rotor resistance</td><td>Cage 1 per-phase equivalent rotor winding resistance referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llr1'</strong></td><td>Cage 1 rotor leakage inductance</td><td>Cage 1 per-phase equivalent rotor winding leakage inductance referred to the stator</td><td>H</td></tr><tr><td><strong>Rr2'</strong></td><td>Cage 2 rotor resistance</td><td>Cage 2 per-phase equivalent rotor winding resistance referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llr2'</strong></td><td>Cage 2 rotor leakage inductance</td><td>Cage 2 per-phase equivalent rotor winding leakage inductance referred to the stator</td><td>H</td></tr><tr><td><strong>Lm</strong></td><td>Mutual inductance</td><td>Stator-rotor mutual (magnetizing) inductance</td><td>H</td></tr></tbody></table>

</details>

<details>

<summary>Doubly-fed Induction Machine</summary>

This configuration enables the dynamic modeling of a **Doubly-Fed Induction Machine (DFIM)**, including both the stator and rotor windings. All rotor parameters are referred to the stator and are denoted by a prime (′) symbol.

<table data-search="false"><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="80.39697265625">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Lls</strong></td><td>Stator leakage inductance</td><td>Per-phase stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Rr'</strong></td><td>Rotor resistance</td><td>Per-phase rotor winding resistance referred to the stator</td><td>Ω</td></tr><tr><td><strong>Llr'</strong></td><td>Rotor leakage inductance</td><td>Per-phase rotor winding leakage inductance referred to the stator</td><td>H</td></tr><tr><td><strong>Lm</strong></td><td>Mutual inductance</td><td>Stator-rotor mutual (magnetizing) inductance</td><td>H</td></tr><tr><td><strong>Nsr</strong></td><td>Stator to rotor turn ratio</td><td>Stator to rotor turn ratio</td><td>-</td></tr><tr><td><strong>Rs0</strong></td><td>Zero-sequence resistance (Stator)</td><td>Zero-sequence stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Ls0</strong></td><td>Zero-sequence inductance (Stator)</td><td>Zero-sequence stator winding leakage inductance</td><td>H</td></tr><tr><td><strong>Rr'0</strong></td><td>Zero-sequence resistance (Rotor)</td><td>Zero-sequence rotor winding resistance</td><td>Ω</td></tr><tr><td><strong>Lr'0</strong></td><td>Zero-sequence inductance (Rotor)</td><td>Zero-sequence rotor winding leakage inductance</td><td>H</td></tr></tbody></table>

</details>

<details>

<summary>PMSM Fix Ld Lq mode</summary>

This configuration is used for dynamic modeling of a PMSM with constant parameters.

<table><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="80.3968505859375">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Ld</strong></td><td>Direct-axis inductance</td><td>Stator winding phase to neutral inductance on the D-Axis</td><td>H</td></tr><tr><td><strong>Lq</strong></td><td>Quadrature-axis inductance</td><td>Stator winding phase to neutral inductance on the Q-Axis</td><td>H</td></tr><tr><td><strong>FluxPM</strong></td><td>Permanent magnet flux linkage</td><td>The constant flux per pole pairs induced in the stator windings by the rotor magnets</td><td>Wb</td></tr><tr><td><strong>DqTheta</strong></td><td>Rotor flux position at theta = 0</td><td>Offset angle applied to the dq transform to have magnet flux aligned or 90degree behind phase A</td><td>Deg</td></tr></tbody></table>

</details>

<details>

<summary>BLDC mode</summary>

This configuration is used for dynamic modeling of a BLDC with constant parameters.

<table><thead><tr><th>Symbol</th><th>Name</th><th>Description</th><th width="79.596923828125">Unit</th></tr></thead><tbody><tr><td><strong>Rs</strong></td><td>Stator resistance</td><td>Per-phase stator winding resistance</td><td>Ω</td></tr><tr><td><strong>Ls</strong></td><td>Stator leakage inductance</td><td>Stator winding phase to neutral inductance</td><td>H</td></tr><tr><td><strong>FluxPM</strong></td><td>Permanent magnet flux</td><td>The constant flux per pole pairs induced in the stator windings by the rotor magnets</td><td>Wb</td></tr><tr><td><strong>BEMFFlatArea</strong></td><td>Back EMF flat area</td><td>Electrical angle width of the flat area of the trapezoidal back EMF</td><td>Deg</td></tr><tr><td><strong>DqTheta</strong></td><td>Rotor flux position at theta = 0</td><td>Offset angle applied to the dq transform to have magnet flux aligned or 90degree behind phase A</td><td>Deg</td></tr></tbody></table>

</details>

### Mechanical Parameters

**Mechanical Mode**: Three options

* **Speed**, which excludes the mechanical model to run the machine in speed mode. In this mode, Enable Mechanical Port gives the option of setting the speed command as a constant parameter in the mask, or as an external port at the input of the block.
* **Mechanical Torque**, which includes the mechanical model to run the machine in torque mode. In this mode, Enable Mechanical Port gives the option of setting the torque command as a constant parameter in the mask, or as an external port at the input of the block. The machines can operate in both motor mode, when the torque (load) is positive, and generating mode, when the torque (input) is negative.
* **External mode**, which allows controlling the mechanical mode from outside of the block specially when the mechanical mode change during the simulation is required. By selecting this option three ports of Mechanical Mode, Speed, and Torque will appear at the input of the block. Mechanical Mode input constant of 0 or 1 corresponds to the speed or mechanical torque mode, respectively.

<table><thead><tr><th width="80">Symbol</th><th>Name</th><th>Description</th><th width="109.996826171875">Unit</th></tr></thead><tbody><tr><td><strong>pp</strong></td><td>Pole Pair</td><td>Number of pole pairs<br>Max number of pole pair supported: 127</td><td>-</td></tr><tr><td><strong>J</strong></td><td>Rotor Inertia</td><td>Rotor moment of inertia</td><td>kg.m^2</td></tr><tr><td><strong>Fv</strong></td><td>Viscous Friction Coefficient</td><td>Viscous friction coefficient</td><td>N.m.s/rad</td></tr><tr><td><strong>Fs</strong></td><td>Static Friction Torque</td><td>Static friction torque</td><td>N.m</td></tr><tr><td><strong>W0</strong></td><td>Initial Speed</td><td>Initial speed</td><td>rpm</td></tr></tbody></table>

### Resolver and encoder parameters

When the **Enable Resolver/Encoder** option is selected, the resolver or encoder parameters become available in the block mask.

Two encoder modes are supported: **Quadrature** and **Hall Effect**. The **Direction of Sensor Rotation** parameter specifies whether the sensor rotation is **clockwise** or **counterclockwise**.

For resolver operation, the **Excitation Source Type** parameter defines how the resolver excitation signal is generated. The following excitation source options are available:

* **AC**: The excitation signal is generated internally by the FPGA at the specified frequency.
* **DC**: The excitation signal is generated internally with a 90° phase shift relative to the rotor position.
* **External**: The excitation signal is provided from an external source through the assigned **Analog In** channel.

The **Resolver Sine Gains** and **Resolver Cosine Gains** parameters are each specified as a **4 × 1 vector**.

For Resolver Sine and Cosine Gains \[Rk], four parameters are Sin.Sin, Sin.Cos, Cos.Sin and Cos.Cos. The resolver Sine and Cosine outputs are calculated by using the following two equations. To simulate the resolver ideally, set Sin.Sin and Cos.Cos to 1 while Sin.Cos and Cos.Sin to 0.

$$
\text{Sine Output} = \left\[ \text{Sin.Sin},\sin!\big(pp(\theta\_m-\theta\_{\mathrm{offset}})\big) + \text{Sin.Cos},\cos!\big(pp,\theta\_m-\theta\_{\mathrm{offset}}\big) \right] \times \text{Excitation} \\\[8pt]
\text{Cosine Output} = \left\[ \text{Cos.Sin},\sin!\big(pp(\theta\_m-\theta\_{\mathrm{offset}})\big)  + \text{Cos.Cos},\cos!\big(pp,\theta\_m-\theta\_{\mathrm{offset}}\big) \right] \times \text{Excitation}
$$

<table data-search="false"><thead><tr><th>Symbol</th><th>Name</th><th>Description</th><th width="79.596923828125">Unit</th></tr></thead><tbody><tr><td><strong>Rpp</strong></td><td>Number of Pole Pairs of the Resolver and Encoder</td><td><p>Number of pole pairs of the resolver and encoder</p><p>Note: Only disabled when both Resolver and Encoder are disabled</p></td><td>-</td></tr><tr><td><strong>Roffset</strong></td><td>Resolver Angle Offset</td><td>Angle offset between the resolver and the rotor position from 0 to 360 degrees</td><td>deg</td></tr><tr><td><strong>Rk</strong></td><td>Resolver Sine and Cosine Gains</td><td>Vector of 4 sine/cosine modulation output sine/cosine component amplitude between 0 and 1</td><td>-</td></tr><tr><td><strong>Ef</strong></td><td>Excitation Frequency</td><td>Frequency of the excitation when the source is in AC mode</td><td>Hz</td></tr><tr><td><strong>Ets</strong></td><td>Excitation Time Shift</td><td>This parameter is used to compensate the time offset between the carrier generation's input in the system and modulated signals' output</td><td>s</td></tr><tr><td><strong>Qppr</strong></td><td>Number of pulses per revolution</td><td>Number of pulses in one full revolution of the encoder</td><td>-</td></tr><tr><td><strong>Roffset</strong></td><td>Encoder Angle Offset</td><td>Angle offset between the encoder and the rotor position from 0 to 360 degrees</td><td>deg</td></tr><tr><td><strong>Hpos</strong></td><td>Hall effect sensor positions</td><td>Vector of 3 elements that give in electrical angle the positions of the Hall effect sensors A B C in this order</td><td>deg</td></tr></tbody></table>

## Inputs

<table><thead><tr><th width="199.79998779296875" valign="top">Input</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><strong>Mechanical Mode</strong></td><td>This port allows controlling the mechanical mode from outside of the block specially when the mechanical mode change during the simulation is required. Mechanical Mode input constant of 0 or 1 corresponds to the speed or mechanical torque mode, respectively.</td></tr><tr><td valign="top"><strong>Speed</strong></td><td>This port is used for the speed command. It is available when the mechanical mode is set to external, or it is set to speed and the Enable Mechanical Port is set to external port.</td></tr><tr><td valign="top"><strong>Torque</strong></td><td>This port is used for the load torque command. It is available when the mechanical mode is set to external, or it is set to torque and the Enable Mechanical Port is set to external port.</td></tr></tbody></table>

## Outputs

### **Generic machine model**

<table data-search="false"><thead><tr><th width="201.39996337890625" valign="top">Output</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><strong>Vsq</strong></td><td>Quadratic stator voltage.</td></tr><tr><td valign="top"><strong>Vsd</strong></td><td>Direct stator voltage.</td></tr><tr><td valign="top"><strong>Vrq</strong></td><td>Quadratic rotor voltage, seen from stator.<br>Exception: Seen from rotor field voltage for synchronous machine.</td></tr><tr><td valign="top"><strong>Vrd</strong></td><td>Direct rotor voltage, seen from stator.<br>Exception: Unused for synchronous machine.</td></tr><tr><td valign="top"><strong>Phisq</strong></td><td>Quadratic stator flux.</td></tr><tr><td valign="top"><strong>Phisd</strong></td><td>Direct stator flux.</td></tr><tr><td valign="top"><strong>Phirq</strong></td><td>Quadratic rotor flux, seen from stator.<br>Exception: Field flux for synchronous machine.</td></tr><tr><td valign="top"><strong>Phird</strong></td><td>Direct rotor flux, seen from stator.<br>Exception: Damper Kd flux for synchronous machine.</td></tr><tr><td valign="top"><strong>Isq</strong></td><td>Quadratic stator current.</td></tr><tr><td valign="top"><strong>Isd</strong></td><td>Direct stator current.</td></tr><tr><td valign="top"><strong>Irq</strong></td><td>Quadratic rotor current, seen from stator.<br>Exception: Field current for synchronous machine.</td></tr><tr><td valign="top"><strong>Ird</strong></td><td>Direct rotor current, seen from stator.<br>Exception: Damper Kd current for synchronous machine.</td></tr><tr><td valign="top"><strong>isa</strong></td><td>First stator phase current.</td></tr><tr><td valign="top"><strong>isb</strong></td><td>Second stator phase current.</td></tr><tr><td valign="top"><strong>isc</strong></td><td>Third stator phase current.</td></tr><tr><td valign="top"><strong>ira</strong></td><td>First rotor phase current, seen from stator.<br>Exception: Seen from rotor for doubly-fed induction machine.<br>Exception: Seen from rotor field current for synchronous machine</td></tr><tr><td valign="top"><strong>irb</strong></td><td>Second rotor phase current, seen from stator.<br>Exception: Seen from rotor for doubly-fed induction machine.<br>Exception: Unused for synchornouc machine</td></tr><tr><td valign="top"><strong>irc</strong></td><td>Third rotor phase current, seen from stator.<br>Exception: Seen from rotor for doubly-fed induction machine.<br>Exception: Unused for synchornouc machine</td></tr><tr><td valign="top"><strong>Torque</strong></td><td>Electrical torque</td></tr><tr><td valign="top"><strong>w</strong></td><td>Motor speed in rpm</td></tr><tr><td valign="top"><strong>thetam</strong></td><td>Mechanical rotor angle in degrees</td></tr><tr><td valign="top"><strong>Resolver sin</strong></td><td>sin waveform from the resolver</td></tr><tr><td valign="top"><strong>Resolver cos</strong></td><td>cos waveform from the resolver</td></tr><tr><td valign="top"><strong>Resolver carrier</strong></td><td>carrier waveform from the resolver</td></tr></tbody></table>

### **PMSM Constant DQ**

<table data-search="false"><thead><tr><th width="199.800048828125">Output</th><th>Description</th></tr></thead><tbody><tr><td><strong>Ia</strong></td><td>First stator phase current.</td></tr><tr><td><strong>Ib</strong></td><td>Second stator phase current.</td></tr><tr><td><strong>Ic</strong></td><td>Third stator phase current.</td></tr><tr><td><strong>VaFiltered</strong></td><td>First stator phase voltage filtered.</td></tr><tr><td><strong>VbFiltered</strong></td><td>Second stator phase voltage filtered.</td></tr><tr><td><strong>VcFiltered</strong></td><td>Third stator phase voltage filtered.</td></tr><tr><td><strong>ActivePower</strong></td><td>Instantaneous active power.</td></tr><tr><td><strong>ReactivePower</strong></td><td>Instantaneous reactive power.</td></tr><tr><td><strong>Id</strong></td><td>D-axis current.</td></tr><tr><td><strong>Iq</strong></td><td>Q-axis current.</td></tr><tr><td><strong>ThetaMec</strong></td><td>Mechanical rotor angle in degrees.</td></tr><tr><td><strong>ThetaElec</strong></td><td>Electrical rotor angle in degrees.</td></tr><tr><td><strong>ElectomagneticTorque</strong></td><td>Electrical torque in Nm.</td></tr><tr><td><strong>SineResolver</strong></td><td>sin waveform from the resolver.</td></tr><tr><td><strong>CosineResolver</strong></td><td>cos waveform from the resolver.</td></tr><tr><td><strong>ExcitationResolver</strong></td><td>carrier waveform from the resolver.</td></tr><tr><td><strong>ThetaResolver</strong></td><td>Resolver angle in degrees use for Sine Cosine modulation.</td></tr><tr><td><strong>SpeedRPM</strong></td><td>Electrical machine speed in Revolution per minutes.</td></tr><tr><td><strong>TotalTorque</strong></td><td>Torque resultant after static friction (electromagnetic torque - torque load - static friction).</td></tr><tr><td><strong>BackEmfA</strong></td><td>Back Emf voltage of phase A in Volts.</td></tr><tr><td><strong>BackEmfB</strong></td><td>Back Emf voltage of phase B in Volts.</td></tr><tr><td><strong>BackEmfC</strong></td><td>Back Emf voltage of phase C in Volts.</td></tr></tbody></table>

## Characteristics and limitations

**Offline simulation:** This block is not capable of offline simulation.

**Communication delays:** The block latency is 2 CPU Time steps.

| Direct Feedthrough   | NO  |
| -------------------- | --- |
| Discrete sample time | YES |
| XHP support          | YES |
| Work offline         | NO  |


---

# 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/rt-lab/simulink-blocks-reference/efpgasim-library/simulink-sps-workflow/machines/generic-machines.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.
