> 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/mmc-example-models/mmc-statcom.md).

# MMC STATCOM

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

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

The **MMC STATCOM** example can be created by starting a new RT‑LAB project. From the menu bar, select **File > New > RT‑LAB Project**. Enter a name and location for your project, then click **Next**. From the available templates list, navigate to **MMC** and select **MMC\_STATCOM**, then click **Finish**.

### Model overview

The demo is organized into two main subsystems, representing the console interface and the combined control–plant model of the MMC‑based STATCOM.

#### Computation subsystem

**SM\_sys:**\
This subsystem contains both the **high‑level control** and the **plant model** of the MMC‑STATCOM. It includes:

* The full STATCOM electrical model (transformer, breakers, AC system, and fault element)
* The **MMCValves** block, which implements the detailed MMC behavior
* The corresponding **MMCValvesLowLvlCtrl** block for gate‑level and balancing functions

Together, these components model the complete dynamic behavior of the MMC‑based STATCOM, including its response to grid disturbances, voltage regulation, and reactive‑power support.

The STATCOM implementation is composed of the **MMCValvesParam** block and the **MMCValves** block.

* The **MMCValvesParam** block computes all required internal quantities and settings for the MMC.
* The **MMCValves** block uses these calculated parameters to emulate the behavior of each valve.
* All interactions between the parameter calculation block and the valve model are handled internally.

In this demo, **three valves** are modeled, consistent with the structure of a three‑phase MMC‑STATCOM.

#### Console subsystem

**SC\_Console:**\
This subsystem serves as the user interface for interacting with the running simulation. It includes:

* Displays and scopes for visualizing key waveforms
* Constant and parameter blocks for setting reference values
* The **MMCValvesParam** blocks, used to configure selected parameters of the MMC during simulation

Using the console, the user can set power references, adjust STATCOM operating points, and monitor system behavior directly through the provided scopes.

### Test system and parameters <a href="#testsystemandparameters" id="testsystemandparameters"></a>

The MMC‑STATCOM is evaluated using the following test system:

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-fbe67acbdba3f5365701dfade56db7481ae2edf0%2Fmmc-statcom-ex2.png?alt=media" alt=""><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-d51a12f5b21e7bee2f0d659bc6a0435ee426d524%2Fmmc-statcom-ex3.png?alt=media" alt=""><figcaption></figcaption></figure>

A **100 MVA load** with a power factor of **0.95** is connected at the point of common coupling (PCC). The short‑circuit ratio (SCR) at the PCC is approximately **4**, indicating that the STATCOM is connected to a relatively **weak grid**.

The PWM carrier frequency is intentionally kept low (five times the line frequency), and the arm inductance is set to **0.1 p.u.**

{% hint style="info" %}
In this demo, the STATCOM is connected in a **star** configuration.\
The same model can also be used for a **delta**‑connected version, but the user must manually modify the STATCOM terminal connections accordingly.
{% endhint %}

The test system parameters are:

| Parameter                                 | Value               |
| ----------------------------------------- | ------------------- |
| System frequency                          | 60 Hz               |
| Voltage (rms) at source bus               | 77 kV               |
| Voltage (rms) at PCC bus                  | 77 kV               |
| Load at PCC bus                           | 95 + j0.3122 MVA    |
| Impedance between source and PCC (Lx, Rx) | 39.3 mH and 2.117 Ω |

The MMC STACOM parameters are:

| Parameter               | Value    |
| ----------------------- | -------- |
| Number of SM per arm    | 30       |
| PWM carrier frequency   | 300 Hz   |
| Arm inductance (Ls)     | 15.7 mH  |
| Arm inductor resistance | 0.5929 Ω |
| SM capacitance          | 3 mF     |
| Apparent power rating   | 100 MVA  |

\*The demo is set to **30** submodules (SMs) per valve (can be adjusted in the initialization file **`init_MMC_STATCOM.m`**, located in the Simulink model directory).

{% hint style="info" %}
**Performance note:** For >50 SMs per valve, use FPGA. On CPU, multiple MMC blocks can be stacked to exceed 50 SMs/valve, but with real‑time performance limitations.
{% endhint %}

This implementation can run on either the **CPU** or the **FPGA**, and the execution mode is selected in the initialization file **`init_MMC_STATCOM.m`** by uncommenting the appropriate model‑type settings for each MMC before running the simulation, depending on the requirements of their study.

* On the **CPU**, both the **Switching Function (SWF)** detailed model and the **Average Value Model (AVM)** are available.
* On the **FPGA**, only the detailed **SWF** model is supported.

To continue:

* For **CPU implementation**, refer to the **CPU implementation** tab on this page.
* For **FPGA implementation**, refer to the **FPGA implementation** tab on this page.

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

{% tabs %}
{% tab title="CPU implementation" %}

#### Simulator license

[Verify that an active RT-LAB license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/simulator-license.md) with the following features is installed on the simulator to run this example model:

<table><thead><tr><th width="259.63629150390625">Feature Name</th><th width="109.5455322265625">Required Status</th><th>Description</th></tr></thead><tbody><tr><td>ARTEMIS_RT</td><td>enabled</td><td>Real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_NUM_CORES</td><td>1 enabled (or more)</td><td>Activated cores for real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_NBSTATE</td><td>20 enabled (or more)</td><td>Activated electrical states for real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_MMC_CONTROLLER</td><td>enabled</td><td>MMC high-level control blocks on CPU</td></tr></tbody></table>
{% endtab %}

{% tab title="FPGA implementation" %}

#### FPGA

This example model is designed for simulators and/or expansion units equipped with **VC707** FPGA boards. Refer to your **System Description Document** for details specific to the FPGA board used in your system.

#### Simulator license

[Verify that an active RT-LAB license](https://www.opal-rt.com/docs/rt-lab/licensing-reference/simulator-license.md) with the following features is installed on the simulator to run this example model:

<table><thead><tr><th width="259.63629150390625">Feature Name</th><th width="109.5455322265625">Required Status</th><th>Description</th></tr></thead><tbody><tr><td>ARTEMIS_RT</td><td>enabled</td><td>Real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_NUM_CORES</td><td>1 enabled (or more)</td><td>Activated cores for real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_NBSTATE</td><td>20 enabled (or more)</td><td>Activated electrical states for real-time simulation with ARTEMiS toolbox</td></tr><tr><td>ARTEMIS_MMC_CONTROLLER</td><td>enabled</td><td>MMC high-level control blocks on CPU</td></tr><tr><td>XSG_MMC_VALVES</td><td>3 (or more)</td><td>Activated MMC valves on FPGA</td></tr><tr><td>XSG_MMC_VALVES_CONTROLLERS</td><td>3 (or more)</td><td>Activated MMC valve controllers on FPGA</td></tr><tr><td>XSG_MMC_CELLS_PER_VALVE</td><td>512<strong>*</strong> (or more)</td><td>Activated MMC cells per valve on FPGA</td></tr></tbody></table>

**\***&#x43;orresponds to the limit set in the file **`init_MMC_STATCOM.m`**, located in the Simulink model directory. You may open this file and set the variable **`lib_nb_cells`** equal to **`NbSM`**, which is set to **30**. In this case, **`XSG_MMC_CELLS_PER_VALVE`** must be **30 or greater**.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-829f710a09c5547a2fbba26368c3fa1c6193e9c9%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

## Detailed explanation <a href="#detailedexplanation" id="detailedexplanation"></a>

{% tabs %}
{% tab title="CPU implementation" %}

#### Steps to run the model <a href="#modeloverviewandselection" id="modeloverviewandselection"></a>

1. **Adjust the initialization file**\
   Open the file **`init_MMC_STATCOM.m`** located in the Simulink model directory.\
   Modify parameters as needed, comment/uncomment the desired model‑type settings and save your changes:

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

2. **Adapt the Simulink model**\
   Open the Simulink model and **run it once** to automatically load and apply the changes defined in the initialization file to the **SM\_sys** subsystem. Then, go to the **SC\_Console** subsytem and select the desired **Model Type** in the **MMCValvesParam** block.
3. **Build the model in RT‑LAB**\
   Save changes in Simulink. Then, build the model in RT-LAB.
4. **Set the execution mode**\
   For real‑time operation in RT‑LAB, set **Real‑Time mode** to **Software synchronized**.
5. **Load and execute the model**\
   In RT‑LAB, **Load** and **Execute** the model.
6. **Control and monitor the system**\
   Use the **console subsystem** to interact with the model and observe simulation results.

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

**Controls**

* **para:**\
  Sets the MMC parameters.
* **load\_shed:**\
  Connects (**1**) or disconnects (**0**) the load.
* **ac\_no\_fault:**\
  Enables a **3‑phase‑to‑ground fault** at the PCC for 0.05 s (duration adjustable in the model).
  * **1** = no fault
  * **0** = fault applied
* **voltage\_sag:**\
  Applies a voltage sag at the source bus.
  * **0** = no sag
  * **0.1** = 0.1 p.u. voltage sag
* **ctrl\_mode:**\
  Selects the STATCOM operating mode:
* **Voltage mode:** regulates PCC voltage to 1 p.u., limited by available reactive power.
* **Q mode:** regulates reactive power to the reference **q\_ref**.

{% hint style="info" %}
After starting the simulation, the **Enable pulse** checkbox inside the MMC (CPU or FPGA) parameter block must be checked to activate the STATCOM.
{% endhint %}

**Monitoring**\
The **ScopeMeas** scope displays the following signals (from top to bottom):

* **STATCOM voltages** in phases a, b, c, and neutral (4 signals)
* **Capacitor‑voltage metrics:** maximum, minimum, average, and the value of the first cell (4 signals)
* **Average capacitor voltages** for phases a, b, and c (3 signals)
* **Source‑bus voltages** in phases a, b, and c (3 signals)
* **PCC voltages** (3‑phase)
* **PCC currents** (3‑phase)
* **Active and reactive powers** at PCC (3‑phase)
  {% endtab %}

{% tab title="FPGA implementation" %}
{% hint style="info" %}
In FPGA mode, the number of SMs per valve is limited by the license; the **standard firmware supports up to 511 SMs per valve** (higher counts available upon request).
{% endhint %}

#### Steps to run the model <a href="#modeloverviewandselection" id="modeloverviewandselection"></a>

1. **Adjust the initialization file**\
   Open the file **`init_MMC_STATCOM.m`** located in the Simulink model directory.\
   Modify parameters as needed, uncomment the **MMC1 in FPGA** line, comment the other model‑type lines, and save your changes:

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

2. **Adapt the Simulink model**\
   Open the Simulink model and **run it once** to automatically load and apply the changes defined in the initialization file to the **SM\_sys** subsystem. Then, go to the **SC\_Console** subsytem and select the desired **Model Type** in the **MMCValvesParam** block.
3. **Build the model in RT‑LAB**\
   Save changes in Simulink. Then, build the model in RT-LAB.
4. **Set the execution mode**\
   For real‑time operation in RT‑LAB, set **Real‑Time mode** to **Hardware synchronized**.
5. **Load and execute the model**\
   In RT‑LAB, **Load** and **Execute** the model.
6. **Control and monitor the system**\
   Use the **console subsystem** to interact with the model and observe simulation results.

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

**Controls**

* **para:**\
  Sets the MMC parameters.
* **load\_shed:**\
  Connects (**1**) or disconnects (**0**) the load.
* **ac\_no\_fault:**\
  Enables a **3‑phase‑to‑ground fault** at the PCC for 0.05 s (duration adjustable in the model).
  * **1** = no fault
  * **0** = fault applied
* **voltage\_sag:**\
  Applies a voltage sag at the source bus.
  * **0** = no sag
  * **0.1** = 0.1 p.u. voltage sag
* **ctrl\_mode:**\
  Selects the STATCOM operating mode:
* **Voltage mode:** regulates PCC voltage to 1 p.u., limited by available reactive power.
* **Q mode:** regulates reactive power to the reference **q\_ref**.

{% hint style="info" %}
After starting the simulation, the **Enable pulse** checkbox inside the MMC (CPU or FPGA) parameter block must be checked to activate the STATCOM.
{% endhint %}

**Monitoring**\
The **ScopeMeas** scope displays the following signals (from top to bottom):

* **STATCOM voltages** in phases a, b, c, and neutral (4 signals)
* **Capacitor‑voltage metrics:** maximum, minimum, average, and the value of the first cell (4 signals)
* **Average capacitor voltages** for phases a, b, and c (3 signals)
* **Source‑bus voltages** in phases a, b, and c (3 signals)
* **PCC voltages** (3‑phase)
* **PCC currents** (3‑phase)
* **Active and reactive powers** at PCC (3‑phase)
  {% endtab %}
  {% endtabs %}

## Simulation and results <a href="#simulationandresults" id="simulationandresults"></a>

Among the control scenarios described above, a **voltage sag event** is used to demonstrate the dynamic response of the MMC‑STATCOM model. The previously introduced controls are used to apply the sag, and the monitored signals highlight how the STATCOM reacts. The example is simulated **offline** to illustrate the behavior of the **CPU SWF model**, although the same test can also be performed in **real‑time**.

At approximately **t = 1.55 s**, the STATCOM is activated by enabling the gating pulses through the **Enable Pulse** checkbox in the **MMCValvesParam** block. Figure 1 shows the system response immediately before and after pulse activation.

At approximately **t = 2.75 s**, the **voltage sag** is applied by toggling the corresponding switch from 0 to 1. Figure 2 illustrates the system behavior before and after the sag. As expected, the STATCOM increases its **reactive‑power output** from 0 to approximately **0.4 p.u.** to support the AC‑grid voltage during the disturbance.

Figure 3 provides an overview of the complete system response, showing how the MMC‑STATCOM stabilizes the terminal voltage during and after the voltage sag event.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-13a61634eaaf830924405b1d612bda14e3d27e59%2Fmmc-statcom-ex9.png?alt=media" alt=""><figcaption><p>Figure 1: Response before and after the pulse enabled.</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-d485cec9c3a4dcb489d6fde4a6e3094e51187bd2%2Fmmc-statcom-ex10.png?alt=media" alt=""><figcaption><p>Figure 2: Response before and after the voltage sag event.</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-0b0c1618e8bc818e29fb0e0b3dbe69277ea40c1e%2Fmmc-statcom-ex11.png?alt=media" alt=""><figcaption><p>Figure 3: Overall system response during voltage sag event.</p></figcaption></figure>

The model has been run on a dual-Xeon-based 3.466 GHz CPU with Red-hat operating system. The time-step is 20 µs, and 1 CPU core has been assigned. Note the time step is as short as 20 µs. The model can run in 2 modes, the CPU mode and the AVM mode. The real-time simulation performance will be different with the 2 modes.

With both converters running under the CPU mode, the performance is shown as follows:

<table><thead><tr><th width="88">CPU#</th><th width="420">Simulation contents</th><th width="122">Usage (%)</th><th width="115">Time step</th></tr></thead><tbody><tr><td>1</td><td><p>The power system (ideal source, LR line, MMC STATCOM, transformer, load, fault)</p><p>MMC high level control, PWM generator</p><p>Cell voltage balance control</p></td><td>27.65%</td><td>20</td></tr></tbody></table>

With both converters running under the AVM mode, the performance is shown as follows:

<table><thead><tr><th width="87">CPU#</th><th width="426">Simulation contents</th><th width="117">Usage (%)</th><th width="113">Time step</th></tr></thead><tbody><tr><td>1</td><td><p>The power system (ideal source, LR line, MMC STATCOM, transformer, load, fault)</p><p>MMC high level control, PWM generator</p><p>Cell voltage balance control</p></td><td>15.16%</td><td>20 us</td></tr></tbody></table>

## References <a href="#references" id="references"></a>

1. Wei Li, L.-A. Gregoire, and Jean Belanger, "Modeling and Control of a Full-Bridge Modular Multilevel STATCOM," IEEE Power and Energy Society General Meeting, 2012, 7 pages.
2. W. Li et J. Belanger, “An equivalent circuit method for modelling and simulation of modular multilevel converters in real-time HIL test bench,” IEEE Transactions on Power Delivery, vol. 31, no. 15, pp. 240—2409, 2016.
3. W. Li, L. -A. Grégoire and J. Bélanger, "A Modular Multilevel Converter Pulse Generation and Capacitor Voltage Balance Method Optimized for FPGA Implementation," in IEEE Transactions on Industrial Electronics, vol. 62, no. 5, pp. 2859-2867, May 2015, doi: 10.1109/TIE.2014.2362879.


---

# 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/mmc-example-models/mmc-statcom.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.
