> 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/ehs/first-steps/integrate-ehs-into-rt-lab-and-hypersim-models/prepare-an-rt-lab-model.md).

# Prepare an RT-LAB Model

## Overview

In the recommended eHS workflow, the electrical circuit is designed in **Schematic Editor** and executed on the FPGA through the **eHS\_SE\_SFunction\_Drivers** block in RT-LAB.

The RT-LAB model must include the **eHS\_SE\_SFunction\_Drivers** block to:

* Select and load an eHS firmware.
* Open and manage the Schematic Editor circuit.
* Exchange signals between the FPGA and CPU models.

All circuit, firmware, hardware, and signal configuration information is stored in a single **`.ehs3`** project file.

## Recommended workflow procedure

Follow the steps below to create, configure, and run an eHS circuit using the **Schematic Editor + S-Function** workflow, which is the recommended approach for RT-LAB:

{% stepper %}
{% step %}

### Add the eHS solver block to the model

1. Open the CPU model. In RT-LAB, right-click the model and select **Edit** or **Edit with** to choose a MATLAB version. MATLAB will launch with your model.
2. Open the **Simulink Library Browser**
3. Navigate to **RT-LAB I/O > Opal-RT > Common** and drag the **OpCtrl** block into the model
4. Navigate to **eFPGASIM > OPAL-RT Schematic Editor workflow** and drag the **eHS\_SE\_SFunction\_Drivers** block into the model

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-e823ace1def3ec5544794737197d58446e8b7eab%2FSE_eHSblock_new.png?alt=media" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Create a new circuit (or choose an existing one)

When the block is added, you will be prompted to:

* **Create New Circuit**\
  Opens the Schematic Editor with a blank circuit.
* **Choose Existing Circuit**\
  Prompts you to select a valid `.ehs3` file or legacy `.ehs` file and automatically configures the block to match the circuit’s inputs and outputs.

Each project includes a **`.ehs3` file**, which serves as the **single source of truth** for the Schematic Editor circuit. This file contains:

* The electrical eHS circuit model (formerly `.ehs`)
* Simulation setups
* Firmware descriptions
* Hardware configurations
* All required signal connections

The `.ehs3` file can be versioned (e.g., Git), edited in the Schematic Editor, and shared across teams.

Once selected or created, the circuit is opened in the **Schematic Editor** and remains continuously synchronized with the filesystem. To ensure proper synchronization, the `.ehs3` circuit file must be available in the **MATLAB path** at all times.
{% endstep %}

{% step %}

### Model in Schematic Editor

Follow the guidelines in [Model In Schematic Editor](broken://spaces/nVlkMVXjY5bWbFGd9Gyz/pages/aBK8ZFLlzCBwUYs6t8ws) to create and configure the eHS circuit.
{% endstep %}

{% step %}

### Complete the simulation in Simulink and RT-LAB

Finalize the model configuration and simulation in **Simulink** and **RT-LAB** as described in [Power Electronics and Electric Machines with eHS](https://www.opal-rt.com/docs/rt-lab/model-and-simulation/power-electronics-and-electric-machines-with-ehs).

This includes completing the CPU model in Simulink, connecting any required external hardware, and using RT-LAB to build, load, and execute the model on the simulator.
{% endstep %}
{% endstepper %}

## Open Schematic Editor

To edit the circuit, select an eHS firmware (bitstream), or configure interaction with the CPU model and/or an external device under test (DUT), open Schematic Editor. To do so, simply double-click the **eHS\_SE\_SFunction\_Drivers** block.

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-d131ea4122440b8f44add31f064a80a76cca4bb8%2Fopen-se-rtlab.png?alt=media" alt=""><figcaption></figcaption></figure>

## Manage eHS circuit integration

The **eHS\_SE\_SFunction\_Drivers** block also provides several management and configuration options that simplify the integration of an eHS circuit with the CPU model. These options allow you to synchronize the block with circuit changes, choose another circuit file, open the circuit file directory in the file explorer, open the **Build Report**, configure the link with the **OpCtrl** block, and access advanced features.

To access these options, right-click the block and navigate to **eHS**:

<figure><img src="https://3212678799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FABuoXNYgvaoO7wIe3bfO%2Fuploads%2Fgit-blob-9d9f443aa68dd3d7bbbc9cf3cf633dddd07a474e%2Fehs-block-options-rtlab.png?alt=media" alt=""><figcaption></figcaption></figure>


---

# 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/ehs/first-steps/integrate-ehs-into-rt-lab-and-hypersim-models/prepare-an-rt-lab-model.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.
