> 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/modular-multilevel-matrix-converter-m3c.md).

# Modular Multilevel Matrix Converter (M3C)

## 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-086dc4259546c0a9951bfae54ac4a615b0500c8d%2Fmmc-m3c-ex.png?alt=media" alt=""><figcaption></figcaption></figure>

The **Modular Multilevel Matrix Converter** 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\_Matrix\_Converter**, then click **Finish**.

This demo simulates a Modular Multilevel Matrix Converter (M3C) station.

### Model overview <a href="#testsystemandparameters" id="testsystemandparameters"></a>

The demo is organized into three main subsystems, representing the console interface, the high‑level control, and the plant model of the M3C station.

#### Computation subsystems

**SM\_M3CControl:**\
This subsystem contains the **high‑level control** algorithms for the M3C model. It computes the reference signals required for stable operation and manages the overall power exchange between the interconnected AC grids.

**SS\_M3CPlant:**\
This subsystem contains the complete **M3C plant model**, including:

* Electrical components such as three‑phase RLC branches and AC grid representations
* The **MMC Valves** block, which implements the detailed M3C behavior
* The **MMC Valves Low‑Level Control** block, responsible for valve‑level modulation and balancing

Together, these components emulate the full dynamic behavior of the M3C converter in AC‑to‑AC power conversion applications.

#### Console subsystem

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

* Displays and scopes for visualizing simulation waveforms
* Constant blocks and parameter blocks for setting power references and operating points
* The **MMC Valves parameter blocks**, which provide configuration settings for the M3C during simulation

Through this console, the user can set reference values and monitor system behavior in real time.

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

This M3C demo illustrates the operation of a **10 MVA Modular Multilevel Matrix Converter (M3C)** used to interconnect two AC grids operating at different frequencies **F₁ and F₂** (with **F₁ ≠ F₂**, and **neither frequency equal to zero**). In this example, the M3C enables **bidirectional AC‑to‑AC power exchange** between the two grids while accommodating their frequency differences.

The associated **higher‑level control strategy**, **system parameters**, and **control‑parameter derivations** are discussed in detail on the corresponding subpage of the M3C model.

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

\*The demo is set to **5** submodules (SMs) per valve (can be adjusted in the initialization file **`Parameters_M3C.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 **`Parameters_M3C.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>9 (or more)</td><td>Activated MMC valves on FPGA</td></tr><tr><td>XSG_MMC_VALVES_CONTROLLERS</td><td>9 (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 **`Parameters_M3C.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 **`Parameters_M3C.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-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 **SS\_M3CPlant** 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-db7e076058eab9a9999133aa1ba8c3457bbb7b64%2Fmmc-m3c-ex4.png?alt=media" alt=""><figcaption></figcaption></figure>

**Controls**

The power flow between the two AC grids can be adjusted during the simulation by modifying the power‑reference inputs **Pref**, **Q1ref**, and **Q2ref** in the console.\
**Important:** The resulting apparent power must remain **within the M3C rated capacity (10 MVA)**.

* **Pref:**\
  Active‑power reference (p.u.). Adjustable from **−1 to 1 p.u.**
* **Q1ref:**\
  Reactive‑power reference at the **M3C input** (p.u.). Adjustable from **−1 to 1 p.u.**
* **Q2ref:**\
  Reactive‑power reference at the **M3C output** (p.u.). Adjustable from **−1 to 1 p.u.**
* **MMC parameters:**\
  Sets the M3C/M3C‑MMC parameters based on the selected model type.\
  Values are initialized from the variables in the initialization file.
* **Enable Pulses (inside MMC Valves parameter mask):**\
  Enables or disables the gating signals for the converter.\
  This option must be enabled for the M3C to operate.

{% hint style="info" %}
Adjusting Pref, Q1ref, and Q2ref allows full control of active and reactive power exchange. Ensure the **apparent power √(P² + Q²)** does **not exceed 10 MVA**.
{% endhint %}

**Monitoring**

All values are in **per unit (p.u.)**, except **MMC valve voltages**, which are shown in their corresponding per‑unit base.

* 3‑phase input voltages
* 3‑phase input currents
* 3‑phase output voltages
* 3‑phase output currents
* Active‑power setpoints and measured active power
* Reactive‑power setpoints
* Measured reactive power
* Average SM‑capacitor voltages
* Per‑unit valve voltages (Inputs 1 and 3)
* Per‑unit valve currents (Inputs 2 and 4)
  {% 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 **`Parameters_M3C.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-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 **SS\_M3CPlant** 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-db7e076058eab9a9999133aa1ba8c3457bbb7b64%2Fmmc-m3c-ex4.png?alt=media" alt=""><figcaption></figcaption></figure>

**Controls**

The power flow between the two AC grids can be adjusted during the simulation by modifying the power‑reference inputs **Pref**, **Q1ref**, and **Q2ref** in the console.\
**Important:** The resulting apparent power must remain **within the M3C rated capacity (10 MVA)**.

* **Pref:**\
  Active‑power reference (p.u.). Adjustable from **−1 to 1 p.u.**
* **Q1ref:**\
  Reactive‑power reference at the **M3C input** (p.u.). Adjustable from **−1 to 1 p.u.**
* **Q2ref:**\
  Reactive‑power reference at the **M3C output** (p.u.). Adjustable from **−1 to 1 p.u.**
* **MMC parameters:**\
  Sets the M3C/M3C‑MMC parameters based on the selected model type.\
  Values are initialized from the variables in the initialization file.
* **Enable Pulses (inside MMC Valves parameter mask):**\
  Enables or disables the gating signals for the converter.\
  This option must be enabled for the M3C to operate.

{% hint style="info" %}
Adjusting Pref, Q1ref, and Q2ref allows full control of active and reactive power exchange. Ensure the **apparent power √(P² + Q²)** does **not exceed 10 MVA**.
{% endhint %}

**Monitoring**

All values are in **per unit (p.u.)**, except **MMC valve voltages**, which are shown in their corresponding per‑unit base.

* 3‑phase input voltages
* 3‑phase input currents
* 3‑phase output voltages
* 3‑phase output currents
* Active‑power setpoints and measured active power
* Reactive‑power setpoints
* Measured reactive power
* Average SM‑capacitor voltages
* Per‑unit valve voltages (Inputs 1 and 3)
* Per‑unit valve currents (Inputs 2 and 4)
  {% endtab %}
  {% endtabs %}

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

{% tabs %}
{% tab title="Offline" %}
**Test Scenario – 01:** Transfer of active power from input to output. The control of M3C is enabled at 0.25 seconds & the DC-link voltage is regulated to its reference. A step change in active power reference from 0 to nominal (1 P.U) is applied at 5s.

Simulation result illustrating the input & output voltages, currents, active-reactive powers & DC-link voltage of test scenario-01:

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

Steady-state response of the M3C for zero active power reference of test scenario-01:

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

Steady-state response of the M3C for nominal active power reference of test scenario-01:

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

Dynamic response of M3C for step-change change in active power reference with test scenario-01:

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

Per-unit valve voltages and currents corresponding to steady-state nominal active power:

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

Per-unit valve currents in double-αβ reference frame corresponding to steady-state nominal active power:

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

Per-unit valve capacitor voltages in double-αβ reference frame:

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

**Test Scenario – 02:** Transfer of active & reactive power at 0.6 P.F. Similar to the scenario-01, the control of M3C is enabled at 0.25 seconds & the DC-link voltage is regulated to its reference. A step change in active power reference 0.8 P.U is applied from starting and a step change in reactive power from 0 to 0.6 P.U is applied at 5 seconds.

Simulation result illustrating the input & output voltages, currents, active-reactive powers & DC-link voltage:

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

Steady-state response of the M3C for 0.8 PU active and 0.6 P.U reactive power reference:

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

{% tab title="CPU implementation" %}
The real‑time CPU implementation is distributed across **two cores**, separating the model into a **master subsystem** (containing the top‑level control) and a **slave subsystem** (containing the M3C plant that interconnects the two AC grids). The real‑time simulation runs with a fixed step size of **Tₛ = 30 µs**. The online CPU computational load, approximately **6%** for the master and **67%** for the slave, is shown below, confirming that the model executes without overruns:

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

**Test Scenario – 01:** Transfer of active power from input to output. The control of M3C is enabled at 0.25 seconds & the DC-link voltage is regulated to its reference. A step change in active power reference from 0 to nominal (1 P.U) is applied at 5s. In this test, the active‑power reference is set to **0.8 p.u.** and the reactive‑power reference to **0.6 p.u.**, demonstrating that the converter control operates correctly under real‑time conditions.

Real-time simulation result illustrating the input & output voltages, currents, active-reactive powers & DC-link voltage:

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

Per-unit valve voltages and currents corresponding to steady-state nominal active power:

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

In this demo, the M3C converter interfaces the two-ac grids with frequencies F1 & F2 **(F1≠ F2, & F1 and/or F2 ≠ 0).** The control for M3C is developed based on the double-αβ reference frame. The objectives of the control are active & reactive power exchange/transfer, input & output current regulation, DC-link capacitor voltage regulation, circulating current control for balancing of valve capacitor voltages and independent sub-module capacitor voltage balancing. All the control objectives are well achieved.
{% endtab %}
{% endtabs %}

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

1. 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.
2. 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/modular-multilevel-matrix-converter-m3c.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.
