> 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/energy-example-models/wind-turbines.md).

# Wind Turbines

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

The **Wind Turbines** model illustrates the closed-loop control of Doubly Fed Induction Machine (DFIM) using back-to-back PWM converters developed in Schematic Editor software and solved using the eHS solver. This example is based on OPAL-RT's real-time simulator, which has CPU and FPGA as two major processing units: the DFIM and the converter are simulated on FPGA and the controller is simulated on CPU in real-time. One RT-LAB model and one Schematic Editor model is provided to illustrate the exchange of information between the controller and plant. This example uses a DFIM with saturation model.

## Detailed explanation

The RT-LAB model consists of a master subsystem (i.e. "sm\_computation") and a console subsystem (i.e. "sc\_user\_interface").

* The **master subsystem** has power network interface ("eHS\_SE\_SFunction\_Drivers") and control of the machine

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

* The **console subsystem** is used to control set points, such as magnitude and frequency of source voltages, speed reference, mechanical torque, and control activation during real-time simulation. Users can also monitor voltages, currents, machine torque and speed of the machine at any point during the simulation. For this example the role of each set points are as following:

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

where:

* Vdc\_Ref: This sets the DC bus reference voltage for the outer loop of grid side converter control.
* Kp Ki rotor: These are the Kp and Ki values of outer loop active and reactive power control of the rotor side converter control.
* Kp Ki DC-link: These are the Kp and Ki values of inner loop active and reactive power control of grid side converter control.
* Iq\_related: This generates Iq reference value manually when PQ control of rotor side converter is disabled.
* P ref: This block is used to set reference active power in PU to the rotor side converter outer loop control. This block holds a feature of generating reference value as a constant or a square wave with perturbation or a triangular wave with perturbation.
* Q ref: This block is used to set reference reactive power in PU to the rotor side converter outer loop control
* PQ\_Control: This block, upon setting a value 0, enables all controls with respect to back-to-back PWM converters. It disables active and reactive power control of rotor side converter upon setting its value to 1. The value of Iq is given manually from "Iq\_related".
* Rotor speed: The rotor speed of DFIM is set in per unit.
* Rotor speed type: The rotor speed continuously varies between sub and super synchronous mode upon setting a value 0. If the value is set to 1 then the speed mentioned in "Rotor speed" is considered.
* Frequency: Grid frequency

The **"eHS\_SE\_SFunction\_Drivers" solver** solves the power network built using schematic editor software during the real time simulation. The circuit built in schematic editor can be edited or viewed by choosing the edit option available in the solver block.

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

eFPGASIM allows to simulate two different models for the doubly-fed induction machine:

* linear (or unsaturated) induction machine;
* saturated induction machine.

In the **linear machine model** the effects of magnetic saturation are neglected, in contrast with the **induction machine with saturation**, where these effects are taken into account. Each model has its own block in OPAL-RT Schematic Editor Library Browser, with different parameters to be set, as shown in the figures below.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-2a2dc96821d48d90e4dc756b8d4e6d1b34be006b%2Fehs-model-wind-turbines-4.png?alt=media" alt=""><figcaption><p><strong>Linear doubly-fed induction machine</strong> and its parameters in OPAL-RT Schematic Editor.</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-1a906b826ff09ec1e375e521bcfda07d6ec73ff5%2Fehs-model-wind-turbines-5.png?alt=media" alt=""><figcaption><p><strong>Doubly-fed induction machine with saturation</strong> and its parameters in OPAL-RT Schematic Editor.</p></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 in .mat files that will be transferred into the solver when the model is run from the RT-LAB interface. Matrices are generated during model compilation in RT-LAB.

**Back-to-back converter control of DFIM** is implemented on the CPU which runs at a sampling time of 20 micro-sec.

**Rotor side converter (RSC)** shown below provides the excitation for the induction machine rotor. With this PWM converter it is possible to control the torque, hence the real power, and power factor at the stator terminals. The DFIM is controlled in a synchronously rotating dq axis frame, with d axis oriented along the stator flux vector position. In this way a decoupled control between the electrical torque and the rotor excitation current is obtained. Consequently, the active and reactive power are controlled independently.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-160954d0c699500279614bc69622a4d0e86cc4f8%2Fehs-model-wind-turbines-6.png?alt=media" alt=""><figcaption><p>Reference: Dr John Fletcher and Jin Yang "Introduction to Doubly-Fed Induction Generator for Wind Power Applications"</p></figcaption></figure>

**Grid side converter (GSC) control** shown below controls the flow of real and reactive power to the grid. The objective of GSC is to keep the DC Link voltage constant regardless of the magnitude and direction of the rotor power flow. The vector control method is used with the reference frame oriented along th stator voltage vector position, enabling independent control of the active and reactive power flowing between the grid and the GSC.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-08b13dfe051f0a42ff2c421a66e178b4a457a741%2Fehs-model-wind-turbines-7.png?alt=media" alt=""><figcaption><p>Reference: Dr John Fletcher and Jin Yang "Introduction to Doubly-Fed Induction Generator for Wind Power Applications"</p></figcaption></figure>

Modulating waveforms generated by the controller are converted to PWM via pwmo IO block of OPAL-RT. These pwm pulses are fed back through digital loop-back cable to fire the eHS converter internally. Here, the gating pulses are chosen to receive from Digital In card of the OPAL-RT simulator. Here, to receive the pwm in schematic editor, slot 1A channels 00 to 05 and 08 to 13 are configured.

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

The OPAL-RT hardware chasis and FPGA module has to be chosen in the schematic editor prior to the building of the model. Goto: File - Simulator Setup - Choose the Simulator - Choose the Firmware. Mark the "Use this setup" to fit your simulation requirement.

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

## 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.

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 255.

{% hint style="info" %}
The user should change the Board Index from 255 to the Board Index Value of their Versal system, as specified in the System Description document.
{% endhint %}

## 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>>Energy>>Wind Turbines**.
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 by opening the **measurements** subsystem in the Simulink Console.

### 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 firmware used in this model is generated using the RT-XSG tool, and it can be modified to generate firmware to fit another I/O hardware configuration. The CPU model simulation time step is set to 20 microseconds and all the variables required for controller is defined in the "ParameterInitialization.m" file that is automatically loaded during simulation.

Digital loop-back (internal or external) is used to transfer the gating pulses.

<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>

### Run the model

During real-time execution;

1. Set reference active power in PU to the rotor side converter controller **P ref** in the console.
2. Set reference reactive power in PU to the rotor side converter controller **Q ref** in the console.
3. Set Vdc reference to the grid side converter controller **Vdc\_Ref** 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-08c906d019aae5d402a3afd13ec528aee563143e%2Fehs-model-wind-turbines-10.png?alt=media" alt=""><figcaption><p>Simulation results for the saturated doubly-fed induction machine.</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-1c15c429c1c459b96771dc64db435845a29d86d1%2Fehs-model-wind-turbines-11.png?alt=media" alt=""><figcaption><p>Stator (left) and rotor (right) currents for both linear (blue) and saturated (red) doubly-fed induction machine.</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/energy-example-models/wind-turbines.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.
