> 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/hypersim/examples/transportation/fpga-based-pmsm-drive.md).

# FPGA Based PMSM Drive

## Description

The **FPGA-Based PMSM Drive** example, located in **File > Open an Example File > Transportation**, illustrates closed-loop speed control of the FPGA-based Permanent Magnet Synchronous Machine (PMSM) interconnected with a two-level voltage source converter. Two example files are available, corresponding to the FPGA simulator configuration (Virtex-7 or Kintex-7).

In this example, the plant model is built with the FPGA-based schematic circuit editor, the PMSM and the two-level converter is simulated on FPGA, while the controller is implemented in HYPERSIM on a CPU core with a 50 µs time step.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-6d4bfe42f45daf60632e3ed59be7ffc3a34d5cd4%2Fimage%20(997).png?alt=media" alt=""><figcaption></figcaption></figure>

## Requirements

This example requires a real-time simulator equipped with FPGA capability and Digital I/O modules. A digital loopback connection must be configured on the simulator, linking Digital Input channels 0–15 to the corresponding Digital Output channels.

<mark style="background-color:yellow;">An eHS solver license is needed with this specific keys</mark>:

* EHS\_TOTAL\_PERFORMANCE minimum 1,
* EHS\_CORE\_TOKEN minimum 16,
* XSG\_EHS,
* EHS\_MACHINE\_CORE\_TOKEN minimum 1

Two example files are available:

* for OP5707-OP5607 with Virtex-7 FPGA\
  To use the model in **FPGA-Based\_PMSM\_DRIVE.ecf** as is, the unit must have a Virtex-7 FPGA, with the Digital Outputs module in slot 2B and the Digital Inputs module in slot 2A.
* for OP4510-OP4610XG with a Kintex-7 FPGA\
  To use the model in **FPGA-Based\_PMSM\_DRIVE\_4610.ecf** as is, the unit must have a Kintex-7 FPGA, with the Digital Outputs module in slot 1A and the Digital Inputs module in slot 3A.
* for other configuration or chassis\
  Use the model in **FPGA-Based\_PMSM\_DRIVE.ecf** and follow the documentation to run the model on another chassis to update circuit in schematic editor and the I/O modules interface

## Detailed explanation

The machine ratings and parameters represent an electric motor typically used in passenger electric vehicles.

<details>

<summary>More information on machine parameters</summary>

| Parameter                             | Value        |
| ------------------------------------- | ------------ |
| Rated power of machine                | 75 kW        |
| Rated speed                           | 3000 rpm     |
| Rated torque                          | 200 N-m      |
| Rated current of machine              | 200 A        |
| Dc bus voltage                        | 950 V        |
| Switching frequency                   | 20 kHz       |
| Number of poles                       | 12           |
| Stator resistance                     | 6.2 mΩ       |
| D axis inductance (Ld)                | 1.034 mH     |
| Q axis inductance (Ld)                | 1.034 mH     |
| IGBT On-State Resistance \[IGBT\_Ron] | 1 mΩ         |
| IGBT Snubber Resistance \[IGBT\_Rs]   | No snubber   |
| IGBT Snubber Capacitance \[IGBT\_Cs]  | No snubber   |
| Machine Snubber R                     | 1 kΩ         |
| Machine Snubber C                     | 100 nF       |
| Inertia of the Machine                | 0.1863 Kg-m2 |

</details>

### **Controller**

Field-Oriented Control (FOC) runs on the CPU with a 25 µs sampling time. The architecture uses an outer speed loop and inner current loops. Quadrature transformation is applied with the d-axis aligned to the phase A axis (Original Park).

The OPAL-RT Board I/O interface generates PWM pulses for the converter; modulation signals are clamped between 0 and 1. The controller’s PWM carrier frequency is 10 kHz, and data exchange between controller and plant uses digital loopback connections.

Machine phase currents, speed, and electrical angle (theta) are provided to the controller as inputs via the FPGA-based circuit block in the HYPERSIM model.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-24fcff1e52df34cb6187e4d2abc4265b1b5009bf%2Fimage%20(1000).png?alt=media" alt=""><figcaption></figcaption></figure>

### **Simulator setup and I/O configuration**

Create a digital loopback on the simulator between Digital Inputs and Digital Outputs, channels 0 to 15. The plant model (PMSM\_Drive\_OP4510) reads PWM pulses from the simulator’s Digital In I/O module. Simulator settings (platform, solver form factor, bitstream) must be selected in the Schematic Editor to match the intended platform; <mark style="background-color:yellow;">the example uses an OP4510 with eHSx64</mark>.

In HYPERSIM, configure the I/O to generate complementary PWM pulses for the two-level converter implemented in the FPGA-based schematic editor.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-83eb3b7fdb15a16fe05e80f6edd1953de8a8d125%2Fimage%20(1001).png?alt=media" alt=""><figcaption></figcaption></figure>

A dead time of 1 µs is applied between complementary pulses. Route the modulation signals and carrier frequency to the PWM duty and frequency inputs.

## Simulation and results

Use ScopeView to visualize the results.

The simulation starts in a null state with all inputs and outputs at 0. At 0.5 s, the DC bus is applied to the two-level converter, then the controller is enabled to regulate the machine to 1000 rpm and 50 N-m. The reference speed and mechanical load torque are varied to assess transient response and speed control performance. The operating sequence is shown below.

| **Operating points** | **From** | **To** | **Speed Ref (RPM)** | **Load Torque (N-m)** |
| -------------------- | -------- | ------ | ------------------- | --------------------- |
| 1                    | 0 s      | 0.75 s | 1000                | 50                    |
| 2                    | 0.75 s   | 1.25 s | 2500                | 50                    |
| 3                    | 1.25 s   | 1.85 s | 2500                | 150                   |
| 4                    | 2.00 s   | 2.50 s | 1000                | 50                    |

The first set of results includes the machine three-phase currents, reference and measured speed, load torque, electromagnetic torque, and mechanical angle. The graphs described below are provided in a template.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-7d1045c34e513b39c4d0de02b3248bf7058cf47c%2Fimage%20(998).png?alt=media" alt=""><figcaption></figcaption></figure>

The second set shows d–q axis currents, active power, and reactive power over the defined operating range. The machine tracks the reference speed during load changes.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-f0e1a2d3af3570169f7cf10e4abec98466b739d4%2Fimage%20(999).png?alt=media" alt=""><figcaption></figcaption></figure>

## References

\[1] Ming-Hung Chen and Hao-Ting Tseng, *Development of Digital control for high power Permanent - magnet Synchronous motor drive*, Hindawi Publishing Corporation Mathematical Problems in Engineering volume, June 2014

\[2] Krishna Kumari N., Ravi Kumar D. (2018)\_ Torque Ripple Minimization of a FOC-Fed PMSM with MRAS Using Popov’s Hyper-Stability Criterion\_. In: Bhuvaneswari M., Saxena J. (eds) Intelligent and Efficient Electrical Systems. Lecture Notes in Electrical Engineering, vol 446. Springer, Singapore


---

# 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/hypersim/examples/transportation/fpga-based-pmsm-drive.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.
