> 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/example-models/ehs-example-models/sps-software-example-models/three-level-npc-converter-op4510.md).

# Three-level NPC Converter - OP4510

## Description <a href="#description" id="description"></a>

The **Three-level NPC Converter for OP4510** model illustrates the use of the eHS solver to compute the outputs of a three-phase three-level Neutral Point Clamped converter with a RLE load. It is intended to demonstrate the interconnection of the eHS solver with advanced I/O capabilities enabling the direct control of the eHS solver with an external device.

The typical application is the connection of voltage and current measurements computed in eHS to an external controller through a certain number of analog output channels. The circuit switches are controlled by this external devices and are connected to the solver through the digital input interface.

## Requirements <a href="#requirements" id="requirements"></a>

The **RT-LAB**, **RT-EVENTS**, **SPS Software** and **eFPGASIM toolboxes** must be installed on the host and target computers to run this example model properly. Please refer to the product documentation for details on version compatibility.

The eHS solver requires an FPGA-based hardware board. This board will be configured with the attached binary file automatically when the model is loaded in the RT-LAB interface. This model uses a OP4510 as its active carrier board.

## Simulation and results

### Setup and connections <a href="#setup-and-connections" id="setup-and-connections"></a>

This model must be run with the Hardware Synchronized option, with the XHP mode enabled. The I/O interfaces for this model are as follows:

| **IO Group 1 Section A** | OP5353 Digital Input board (32 channels)    |
| ------------------------ | ------------------------------------------- |
| **IO Group 1 Section B** | OP5360-2 Digital Output board (32 channels) |
| **IO Group 2 Section A** | OP5340 Analog Input board (16 channels)     |
| **IO Group 2 Section B** | OP5330-3 Analog Output board (16 channels)  |

The Simulink simulation step time is set to 30 microseconds as the variable "Ts" in the RT-LAB model "InitFcn" and "PostLoadFcn" callbacks. To modify it, double-click on the "Model Initialization" block in the root of the RT-LAB model and modify accordingly the definition of the variable "Ts".

### Simulation with RT-LAB-based controller <a href="#simulation-with-rt-lab-based-controller" id="simulation-with-rt-lab-based-controller"></a>

In order to run the example, follow the procedure below:

1. If eFPGASIM is installed, add the example project to RT-LAB by selecting **File>>New>>RT-LAB Project>>eFPGASIM>>SimPowerSystems\_Workflow>>NPC Inverter>>OP4510**.
2. Compile the RT Model by clicking on **Build** in RT-LAB.
3. Verify that the TE0741 board ID is set correctly in the OpCtrl block in the RT-LAB model SM\_Controller\_eHS\_IOs subsystem. In the “OpCtrl” block parameter panel, select the "Board ID" corresponding to the hardware on which eHS is executed. To get this information, select “Tools > Get I/O infos” on the target context menu in RT-LAB and find the index of your hardware.
4. Observe the SPS Software (formerly SimPowerSystems) model. You will find in it a three-phase NPC converter. This converter has twelve IGBT/Diode switches and six diodes and can implement either a DC/AC converter (inverter mode) or AC/DC converter (rectifier mode). You will also see an LC filter and a RL + Back-EMF load on each phase, and various voltage and current measurement blocks.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-32196a0b06ee6a0337d0f67060067beb8c4c239a%2Fehs-model-sps-3levelMPC-op4510-1.png?alt=media" alt=""><figcaption></figcaption></figure>

5. The voltage of the DC source in input (Vdc) will be controlled from the RT-LAB console during the real-time simulation. The console also controls the PWM modulator reference frequency, as well as the PWM carrier frequency and the Back-EMF amplitude and phase (relative to the PWM modulator phase). Similarly, all fourteen voltage and current measurements will be sent back to the RT-LAB model console. Open both the RT-LAB console and master subsystem to see how the twelve switch control signals are generated from parameters in the console.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-39d04e15b01671bea29d08f32135873e6547b9c5%2Fehs-model-sps-3levelMPC-op4510-2.png?alt=media" alt=""><figcaption></figcaption></figure>

6. When the model is compiled in Simulink, the configuration of the eHS solver will be generated according to the SPS Software (formerly SimPowerSystems) circuit characteristics. Elements will be put into matrices and stored into .mat files that will be transferred into the solver when the model is run from the RT-LAB interface. To generate the matrices, the user can either open the "Dual eHS" block parameter panel or select the “Generate matrices” checkbox. This step is not mandatory, as matrices are regenerated during model compilation in RT-LAB.
7. To run a simulation including the eHS solver in real time, create an RT-LAB project and add the RT-LAB model of this example into the project. The SPS Software (formerly SimPowerSystems) model should not be added to the RT-LAB project, as it does not need to be transferred to the target computer for execution. Compile the model, then assign a target node to run it in real time, then load the model onto it.
8. Execute the real-time simulation and enjoy the results, changing the PWM modulator and carrier characteristics, and the voltage of the DC input and Back-EMF characteristics to suit your interests. The following results have been obtained with the original model by setting the RT-LAB Probe control to acquire 2500 samples per signal for acquisition group #1.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a2ccc03dbd251b5d97d0a9516ea603b17a371400%2Fehs-model-sps-3levelMPC-op4510-3.png?alt=media" alt=""><figcaption></figcaption></figure>

9. The RT-EVENT blocks in the model have a maximum number of events per time step per channel set to 4. This is adequate for any simulation step size up to twice of the PWM carrier period. If the PWM carrier runs faster than twice the simulation rate, more events per simulation steps are needed (twice the number of PWM periods that can be present in one single simulation step). All RT-EVENTS blocks and the eHS controller block have to be configured accordingly.
10. Note: The eHS outputs that are saved in the file NPCResults.mat by the OpWriteFile block during execution (for a limited duration - see the block parameters) , and are transferred to the folder .\Converter3Phase3LevelNPC\_OP4510\_rtlab\_SM\_Controller\_eHS\_IOs\OpREDHAWKtarget upon model reset. This .mat file can be used to visualize more accurately the outputs, or to compare the results of several simulations together.

### Simulation with external controller <a href="#simulation-with-external-controller" id="simulation-with-external-controller"></a>

The NPC converter can be used in a HIL simulation environment with an external controller. This controller uses some Current/Voltage measurements in the circuit and controls the circuit gating signals. Hence, a typical application uses the Analog Output interface of the simulator for the measurements in the circuit and Digital input interface for the switch control feedback.

1. Configure the Analog Output interface to sent the voltage and current measurements with a scale appropriate to the external controller. This is done through the Analog Output Mapping and Rescaling block Control Panel, located in the RT-LAB model console. An typical example of this is already included in the model, providing these signal mapping and scaling

| **IO Group 2 Section B ch00** | Y05 Ia  | 0.1 V/A  |
| ----------------------------- | ------- | -------- |
| **IO Group 2 Section B ch01** | Y06 Ib  | 0.1 V/A  |
| **IO Group 2 Section B ch02** | Y07 Vab | 0.05 V/V |
| **IO Group 2 Section B ch03** | Y08 Vbc | 0.05 V/V |

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-c2fcd3ea95a0370ccd15404973a278a26a445284%2Fehs-model-sps-3levelNPC-op5707-4.png?alt=media" alt=""><figcaption></figcaption></figure>

2. In the RT-LAB model, click Configure **Switch Gates** button to map first 12 gating signals to DI.This will open the eHS Gate Control Selection dialog window where each switch can be configured with a Switch Control Type and Index.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-0be7bda6591cac47127d5dc842c7e4d0cded7d94%2Fehs-model-sps-3levelMPC-op4510-4.png?alt=media" alt="" width="480"><figcaption></figcaption></figure>

3. The digital input assignation is set by the "DIn <=> eHS Assignation panel (IO groups 1A)" block, located in the RT-LAB model SC\_Console subsystem, as follows:

| **DI Group 1 Section A ch01** | eHSx64 Solver SW01-18\_01 |
| ----------------------------- | ------------------------- |
| **DI Group 1 Section A ch02** | eHSx64 Solver SW01-18\_02 |
| **DI Group 1 Section A ch12** | eHSx64 Solver SW01-18\_12 |
| **CPU gating signal**         | eHSx64 Solver SW01-18\_13 |
| **CPU gating signal**         | eHSx64 Solver SW01-18\_18 |

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-1f4af904b12cae85b8ac481637c1d054d38012ee%2Fehs-model-sps-3levelMPC-op4510-5.png?alt=media" alt=""><figcaption></figcaption></figure>

4. Connect the Analog Output DB37 interface (IO Group 2B ch 0 to ch 15) to the external controller inputs.
5. Connect the Digital Input DB37 interface (IO Group 1A ch 0 to ch 15) to the external controller outputs.
6. Build and load the model from the RT-LAB interface.

**Note:** As the eHS circuit gate control signals are also sent to the Digital Output interface "IO Group 1B", the Gates control parameter can be tested by connecting a loopback DB37 cable between IO Groups 1A and 1B. Also, to visualize the rescaled analog output signals in the RT-LAB model console during the simulation, connect a loopback DB37 cable between IO Groups 2A and 2B.


---

# 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/example-models/ehs-example-models/sps-software-example-models/three-level-npc-converter-op4510.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.
