> 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/features-example-models/buck-converter-thermal-model.md).

# Buck Converter Thermal Model

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

The **Buck Converter Thermal** model illustrates the use of the thermal loss in eHS solver. User can see the different type of thermal loss based on the voltage, current, temperature and switching characteristics of one inverter leg in real-time from CPU.

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

## Detailed explanation

For each inverter leg configured in the Thermal Losses CPU block, four outputs are available for each of the three output ports of the block (“THERMAL LOSSES”, “CONDUCTING LOSSES”, “SWITCHING LOSSES”): the upper diode losses, the upper switch losses, the lower diode losses, and the lower switch losses. In this example model, the total losses of each component are injected into the thermal model (Cauer model). The power dissipated by the components is then injected into the case and into the heat sink.

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

By inspecting the parameters of the Thermal Losses CPU block mask, it can be observed that the thermal parameters are configured using variables loaded by the initialization script, which reads an XML file containing data extracted from the component datasheets.

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

When the model is compiled in Simulink, the configuration of the eHS solver will be generated according to the Schematic Editor 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;

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

The RT-LAB, Schematic Editor/Unified Database and eFPGASIM toolboxes must be installed on the host and target computers in order to run this example model properly. Please refer to the product documentation for details on version compatibility.

This example model does not require any IO connection.

## Simulation and results

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>Schematic\_Editor\_Workflow>>Features >>Thermal losses**.
2. From Simulink, Verify that the VC707 board ID is set correctly in the OpCtrl block in the RT-LAB model SM\_eHS subsystem.
3. Compile the RT Model by clicking on **Build** in RT-LAB.
4. Once the model has been successfully built, **Load** and **Execute** the model in RT-LAB in order to begin the real-time simulation.
5. Once the real-time model and the eHS are running, observe the results of the eHS simulation by opening the **measurements** subsystem in the Simulink Console.

<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 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. It does not require any external I/O hardware except the active control card.

Please note that following setup:

* The VC707 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 20 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

1. To run a simulation including the eHS solver in real time, create a RT-LAB project and add the RT-LAB model of this example into the project. Compile the model, then assign a target node to run it in real time, then load the model onto it;
2. Execute the real-time simulation, changing the Vdc, Iac, PWM frequency, and temperature will affect the loose. The following results have been obtained from the original model.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-99d3c53c9223c104e564062516618a72347fb0f2%2Fehs-model-buckconveterthermal-4.png?alt=media" alt=""><figcaption><p>Losses in each component</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-f9996f4d935fc3c58a5a55a64b2fc892dd3a13c6%2Fehs-model-buckconveterthermal-5.png?alt=media" alt=""><figcaption><p>Temperature for each component, case, and heat sink.</p></figcaption></figure>

In the result, the blue waveforms show the expected losses based on the current, voltage and temperature. The yellow waveforms show the result obtained, in real-time, when adding switching information. Yellow waveforms should either be 0 or superimposed with the blue waveform


---

# 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/features-example-models/buck-converter-thermal-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.
