> 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/power-electronics-example-models/dual-active-bridge.md).

# Dual Active Bridge

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

The **Dual Active Bridge** project demonstrates the use of the **Gen5 eHSx128 solver** to compute the outputs of a FPGA-based Dual Active Bridge circuit in real time, that runs on a Versal FPGA board. The FPGA-based circuit is a bidirectional DC-DC converter with two bridges separated by a Single phase ideal two winding transformer. This circuit is created using the OPAL-RT Schematic Editor. With this example project, the user is able to control the simulation parameters in real-time via the RT-LAB console.

## Detailed explanation

The RT model is composed of the following two main subsystems: the Console (SC) and the Master (SM).

* The **console subsystem**, which runs on the host computer, manages the communication between the host computer and the target simulator. It is used as a user interface during the real time simulation to control the model and visualize the outputs of the eHS solver.
* The **master subsystem**, which runs in real time on the target simulator, manages the communication between the CPU model and the eHS solver running on the FPGA. For example, the V\_ref, Phase shift and Control mode sent from the console are processed in the **Controller** subsystem into frequency and duty cycle control values, which are subsequently sent as a PWM signal to the Digital-Out.

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

RT-LAB and the eHS Power Electronics Toolbox must be installed in order to successfully run this example project.

{% hint style="info" %}
In S-Function workflow, example models support any chassis. You can contextualize your example model by selecting the chassis in the Chassis selection block.
{% endhint %}

Since the Versal chassis contains a Bi-directional digital IO card with internal loopback mechanism, no cable is needed for the loopback; the Digital Out and Digital In mapping have been done on the same subsection. This project has the capability to accommodate an external Digital Out to Digital In loopback connection to control the gates.

This project utilizes a hardware configuration where a Versal Board is connected to another Chassis through PCI-Express. The default value of the Board Index of the Versal Board is set to 0.

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

## Simulation and results

<details>

<summary><strong>S-function Workflow</strong></summary>

The **Mezzanine Option block** is an RT-LAB block used in the **S-Function workflow** to configure the settings of the I/O cards for each mezzanine. The available settings depend on the specific type of I/O card.

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

</details>

<details>

<summary><strong>OpalBoard workflow</strong></summary>

[OPAL-RT Board](https://www.opal-rt.com/docs/rt-lab/configure-ios/analog-digital-and-sfp-ios/opal-rt-board-workflow.md) allow the configuration of I/O card settings for each mezzanine.

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

If, for a given I/O mezzanine, this block is not used, then the corresponding settings will be kept at their default values. These default values are dependent on particularities of the bitstream, and they are not guaranteed to be exposed to the user loading their model. Further, the default values populating the Mezzanine Option block do not necessarily correspond to the default settings that will be seen if the Mezzanine Option block is not used.

Note that if a Mezzanine Option block is used, and the choice of mezzanine type is incorrect for the given slot, the model will still load and run. However, there will be errors in the load log in RT-LAB. For example, the following error is observed in the case that slot 1A on the simulator holds an OP5330-3, when we place a Mezzanine Option block that attempts to configure an OP5369 on slot 1A:

{% code overflow="wrap" lineNumbers="true" %}

```
Mezzanine configurator: OP5369 Threshold configuration.
ERROR: OPAL-RT Board: The threshold control register for slot 1A is in an unexpected state. Please reprogram the bitstream.
ERROR: Mezzanine configurator: Threshold configuration failed...
```

{% endcode %}

Further, as documented in the aforementioned RT-LAB page, the block outputs its status: a 0 in the case when the block’s settings have been correctly applied, and a -1 otherwise. For example, in the below model I incorrectly configured one block by giving it the wrong I/O card, and set the other correctly. The result when we load the model reflects this:

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-a4fe002fb70685f86d0a022ad92068069ae7264d%2Fehs-opalboard-block-workflow.png?alt=media" alt="" width="188"><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-635a0707a1e24ec9979ba91be578dae9fe0d6dac%2Fehs-opalborad-model-blocks.png?alt=media" alt=""><figcaption></figcaption></figure>

</details>

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

This model must be run with both the Hardware Synchronized and XHP modes enabled. The CPU model simulation time step is set to 50 microseconds and all the variables required for controller is defined in the "initDABcontroller.m" file that is automatically loaded during simulation.

### Run the model <a href="#running-the-model" id="running-the-model"></a>

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

1. If you have eFPGASim installed, add the example project to RT-LAB by selecting **File>>New>>RT-LAB Project>>eFPGASim>>Schematic Editor workflow>>Power Electronics>>Dual Active Bridge**.
2. Compile the RT Model by clicking on **Build** in RT-LAB.
3. Once the model has been successfully built, **Load** and **Execute** the model in RT-LAB in order to begin the real-time simulation.
4. Once the real-time model and the eHS are running, observe the results of the eHS simulation in the Simulink Console:

* If the Control mode is set to “Open Loop”, the V\_out does not converge to the V\_Ref :

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

* When the control mode is set to “Closed Loop”, the V\_Out converges to V\_Ref :

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

* Voltmeter measurement before and after the transformer are also sent to Analog Out output. By comparing both signals with a scope we can see the following result :\
  We can see the phase switch between the voltage waveforms of around 250ns in the fast AOUT:

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-13d426a5c3a23e7eb99599914dce2b387505c7e1%2Fehs-dualactivebridge-scopeview.png?alt=media" alt=""><figcaption><p>This waveform was captured using FPGA Scope</p></figcaption></figure>

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-14dc5d0579d0e1702d6f0a432166265a1f7d7d4a%2Fehs-dualactivebridge-oscillo.png?alt=media" alt=""><figcaption><p>This waveform was captured using a Siglent SDS 1102X Oscilloscope.</p></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/rt-lab/example-models/ehs-example-models/power-electronics-example-models/dual-active-bridge.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.
