> 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/1-mw-grid-connected-pv-farm.md).

# 1 MW Grid-Connected PV Farm

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

The **1 MW Grid-Connected PV Farm** model illustrates a grid-connected four PV system 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 power network involving converters and transformers is simulated on FPGA, and the MPPT controller and the four PV arrays are simulated on CPU in real-time.

This example comprises a RT-LAB project using dashboard to change the irradiance and demonstrate the results in real-time.

## Detailed explanation

The RT-LAB model consists of a model with a master subsystem (i.e. "SM\_eHS"), and a dashboard (i.e. "main").

The **master subsystem** has a power network interface ("eHS1"), models for four PV arrays ("Four PV"), their control ("Inverter Control1\_2\_3\_4"), and some auxiliary subsystems to calculate P/Q ("PQ Calculation"), to change testing cases ("Scenario Settings"), and to automatically run test and record results ("opElectricEventSelector" and etc.).

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-1639805a06b8e7d0b0b32706c361dd3475b43867%2Fehs-model-1MWgridconnected-1.png?alt=media" alt=""><figcaption><p>SM_eHS in Model</p></figcaption></figure>

The **Console** is used to manually set the irradiance (W/m2) for four PV arrays during real-time simulation. Users can also monitor P and Q of four PV arrays and at PCC, the irradiance, and a phase-to-phase fault on PV One bus during the simulation. When irradiance is set to “-1”, a repeating pattern varying between 400 and 500 is used

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

The **"eHS1" 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. Four PV arrays are represented as equivalent DC voltage sources here. They are calculated in "Four PV" and controlled by "Inverter Control1\_2\_3\_4" using MPPT on CPU. Their currents are solved with eHS solver on FPGA.

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

eFPGASIM allows multiple parameter sets for elements. In this case, a phase-to-phase fault is achieve by varying the resistor between phases A and B on PV One bus.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-c215b95be577721e4947ae18ab6f1a66ae878a60%2Fehs-model-1MWgridconnected-4.png?alt=media" alt=""><figcaption><p>Fault insertion using parameter set</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.

**MPPT control of individual PV array** is implemented on the CPU which runs at a sampling time of 50 micro-sec.

**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-1d69646dc1a64a1661cc649e2eb9352acb52b058%2Fehs-model-1MWgridconnected-5.png?alt=media" alt=""><figcaption><p>Gating pulses from Digital In Card in "eHS1”</p></figcaption></figure>

The OPAL-RT hardware chassis and FPGA module has to be chosen in the schematic editor prior to the building of the model. Goto: Simulation- 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-60213882f8732a115faddfd624519a9620e8389e%2Fehs-model-1MWgridconnected-6.png?alt=media" alt=""><figcaption><p>Simulator Setup and Solver Settings in "eHS1”</p></figcaption></figure>

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

RT-LAB, Schematic Editor/Unified Database and the eHS Power Electronics Toolbox must be installed in order to successfully run this example project.

<details>

<summary><strong>OP5607 and OP5707 simulators</strong></summary>

In this configuration, an external Digital Output–to–Digital Input **loopback connection** must be used to control the gate signals. Connect a loopback cable from a digital output to the corresponding digital input on the simulator. This connection is required for the simulation to run successfully.

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

</details>

<details>

<summary><strong>OP4512 and OP4610 simulators</strong></summary>

When configured in **bi-directional mode**, the OP5369 card supports an internal Digital Output–to–Digital Input loopback. This allows a Digital Input assigned to a channel to directly read the signal generated by the Digital Output on the same channel.

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

</details>

{% hint style="info" %}
If your IO Configuration contains bi-directional OP5369 card, you can always use its internal loopback capability.
{% endhint %}

## Simulation and results

The following procedure will help the user to understand the functionality and linking between eFPGASIM, RT-LAB and Schematic Editor. A Hardware-in-the-loop based RT-LAB model is provided to illustrate the exchange of information between CPU and FPGA.

If eFPGASIM is installed, add the example project to RT-LAB by selecting **File>>New>>RT-LAB Project>>eFPGASIM>>Schematic\_Editor\_Workflow>>Energy>>Four PV**.

### 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 use 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 50 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>

{% 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 %}

### Run the model

During real-time execution in Dashboard of RT-LAB:

#### 1- Automatic irradiance mode

If the irradiances are set at default value (-1), the model will run automatically with a cycle of 2.5 sec. The model mimics a cloud moving from PV One to PV Four decreasing their irradiance from 500 to 400 W/m2 leading to the change of P of PV arrays. If the fault is set to 1, every cycle, a phase-to-phase fault will happen to PV1-bus lasting 0.06 sec and impacting P and Q of PV1 and PCC.

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

#### 2- Manual irradiance mode

If the Irradiances value is manually set between 0 to 1000, the irradiance of four PV arrays can be set to different values. Fault can also happens, or not, in the manual mode.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-649132fb23b4545462742b80b65ccee468e2ae87%2Fehs-model-1MWgridconnected-8.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/rt-lab/example-models/ehs-example-models/energy-example-models/1-mw-grid-connected-pv-farm.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.
