> 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/two-level-inverter.md).

# Two-level Inverter

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

The **Two-level Inverter** model illustrates the use of the eHS solver to compute the outputs of a two-level DC/AC converter. User-defined switching characteristics of the six switches of the inverter are controlled in real-time from the CPU using open-loop control.

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

To run your model properly, the following software must be installed:

* RT-LAB
* RT-EVENTS
* eFPGASIM
* SPS Software

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 either a VC707, TE0741 as its active carrier board (OP5607/OP5700 or OP4510 simulators). Please refer to the product documentation for details on version compatibility.

## Simulation and results

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

This model must be run with the Hardware Synchronized option, with the XHP mode enabled. It does not require any external I/O hardware except the active control card, which can be either a VC707 or TE0741 (OP5607 / OP5700 or OP4510 simulators).

Please note that following setup:

* The VC707/TE0741 kit must be connected to the target PCIe bus and detected through the RT-LAB interface “Tools > Get I/O Infos” procedure.
* The Simulink simulation step time is set to 25 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”.

### Run the model

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>>Two-level Inverter**.
2. Compile the RT Model by clicking on **Build** in RT-LAB.
3. Select the appropriate platform according to your system documentation, then select OK. Go to SM\_eHS\eHs\eHS CommBlk and select the name of the SPS Software (formerly SimPowerSystems) model in circuit file name section. The RT-LAB model using the eHS solver will open automatically, as well as the SPS Software (formerly SimPowerSystems) model describing the circuit to be solved. Note that depending on the platform selected, a different RT-LAB model is opened, with an appropriately configured OpCtrl block, but both versions refer to the same SPS Software (formerly SimPowerSystems) circuit.
4. Verify that the ML605EX1, OP7161EX1, VC707 or OP4500 board ID is set correctly in the OpCtrl block in the RT-LAB model SM\_Controller subsystem.
5. You will find two SPS Software (formerly SimPowerSystems) models for the same circuit. In each model, you will find a three-phase bridge with IGBT/Diode switches that implements a DC/AC converter. You will also see a RL load on each phase, and various voltage and current measurement blocks. For more information on components supported by eHS, please consult section 3 of the eHS user guide.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-9ff6bd30e6b8d253b95f938cfb8b73d42d55d05e%2Fehs-mdel-sps-2levelinverter-1.png?alt=media" alt=""><figcaption></figcaption></figure>

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

6. 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 frequency as well as the PWM carrier frequency. Similarly, all eight 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 PWM signals are generated from parameters in the console as three equally .

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

7. 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, go to SM\_eHS\eHS\eHS Gen3 CommBlk and select “Update eHS matrices”. This step is facultative, as matrices are regenerated during model compilation in RT-LAB.
8. 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.
9. Execute the real-time simulation, changing the PWM modulator and carrier characteristics and the voltage of the DC input to suit your interests. The following results have been obtained from the original model by setting the RT-LAB Probe control to acquire 2000 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-67dd5103b7f9fd0b56ab20467073cac108526671%2Fehs-mdel-sps-2levelinverter-4.png?alt=media" alt=""><figcaption></figcaption></figure>

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 the period of the PWM carrier. If the PWM carrier runs faster than the simulation step size, more events per simulation step are needed (twice the number of PWM periods that can be present in one single simulation step). All RT-EVENTS blocks and the eHS have to be configured accordingly.


---

# 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/two-level-inverter.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.
