> 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/simulink-blocks-reference/mmc-library/mmcvalveslowlvlctrl.md).

# MMCValvesLowLvlCtrl

## Description

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

The **MMCValvesLowLvlCtrl** block, located in the **MMC/MMC blocks** library, implements the low‑level control for the [**MMCValves**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalves.md) block. It controls up to 12 valves and supports three model types: CPU-based Average Model (AVM), CPU-based Switched Function Model (SFM), and FPGA-based SFM.

The block receives high‑level control signals (modulation index) for each valve and generates the corresponding control orders based on the selected model:

* Average model (CPU): Reformats the input vector into the structure expected by [**MMCValves**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalves.md) block.
* Switched function model (CPU): Implements voltage balancing algorithms (Sorting or Vmin/Vmax) and modulation schemes (PWM or NLC) to generate gating signals for each sub‑module. The algorithm is selected in the [**MMCValvesParam**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalvesparam.md) block.
* Switched function model (FPGA): Forwards modulation indices from the high‑level control to the FPGA, where the low‑level control is implemented. FPGA algorithms are optimized for FPGA execution and differ from the CPU-based options.

Use this block together with the [**MMCValvesParam**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalvesparam.md) and the [**MMCValves**](https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalves.md) blocks. The **MMCValvesParam** block configures it, and the **MMCValves** block implements the valve model.

{% hint style="danger" %}
When its parameter **Model Type** is set to **CPU**, this block requires a valid RT-LAB license on the simulator with the following features:

* **ARTEMIS** = enabled

When its parameter **Model Type** is set to **FPGA**, this block requires a valid RT-LAB license on the simulator with the following features:

* **XSG\_MMC\_CELLS\_PER\_VALVE** ≥ max(**Number of SMs per valve** across all **MMCValvesLowLvlCtrl** blocks)

**Examples**

If the model contains **one block** with **Number of SMs per valve** = 16, the license must include:\
→ **XSG\_MMC\_CELLS\_PER\_VALVE** ≥ **16**

If the model contains **two blocks**, one block with **Number of SMs per valve** = 16, and one block with **Number of SMs per valve** = 32:\
→ **XSG\_MMC\_CELLS\_PER\_VALVE** ≥ **32**
{% endhint %}

## Mask parameters

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

{% tabs %}
{% tab title="Model Type = CPU AVM" %}

<table><thead><tr><th width="194">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Model Type</strong></td><td>Selects the implementation location (CPU or FPGA). Must match the <strong>Model Type</strong> set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Number of Valves</strong></td><td>Number of valves to control. Must match the value set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Time step</strong></td><td>Simulation time step inside the CPU (seconds).</td></tr><tr><td><strong>CPU Model Type</strong></td><td>Selects the CPU model: Average Model (AVM) or Switched Function Model (SFM). Must match the value set in the corresponding <strong>MMCValves</strong> block.</td></tr></tbody></table>
{% endtab %}

{% tab title="Model Type = CPU SFM" %}

<table><thead><tr><th width="194">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Model Type</strong></td><td>Selects the implementation location (CPU or FPGA). This value must match the <strong>Model Type</strong> set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Number of Valves</strong></td><td>Number of valves to control. This value must match the value set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Time step</strong></td><td>Simulation time step inside the CPU (seconds).</td></tr><tr><td><strong>CPU Model Type</strong></td><td>Selects the CPU model: Average Model (AVM) or Switched Function Model (SFM). This value must match the value set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Number of SMs per valve</strong></td><td>Sets the number of sub‑modules in each valve. Must match the value in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Number of capacitors per valve</strong></td><td>Sets the number of capacitors per valve. For Half‑Bridge and Full‑Bridge SMs, this equals the number of SMs per valve. For SMs with two capacitors (e.g., CD‑SM), set this to twice the number of SMs. Must match the value in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Carrier Frequency [Hz]</strong></td><td>Sets the carrier frequency for PWM modulation. Must be greater than zero and smaller 1/(4Ts).</td></tr></tbody></table>
{% endtab %}

{% tab title="Model Type = FPGA" %}

<table><thead><tr><th width="187">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Model Type</strong></td><td>Selects the implementation location (CPU or FPGA). This value must match the <strong>Model Type</strong> set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Number of Valves</strong></td><td>Number of valves to control. This value must match the value set in the corresponding <strong>MMCValves</strong> block.</td></tr><tr><td><strong>Time step</strong></td><td>Simulation time step inside the CPU (seconds).</td></tr><tr><td><strong>OpCntrl / OpLnk block</strong></td><td>Selects the OpCntrl or OpLnk block used to connect the FPGA with the CPU model. The <strong>MMC Valves Low Level Control</strong> block exchanges data with the FPGA specified by this selection. The list shows OpCntrl/OpLnk blocks available in the same computation subsystem; if none are found, an error/warning is issued. The model can still compile, but the block will not be connected to the FPGA and the model will not behave as expected.</td></tr><tr><td><strong>FPGA Controller / Link Name</strong></td><td>Displays the name used in the selected OpCntrl or OpLnk block. This field is read‑only and updates automatically when an OpCntrl/OpLnk block is selected under <em>OpCntrl / OpLnk block</em>.</td></tr><tr><td><strong>Maximum number of SMs per valve in FPGA license</strong></td><td>Must match the maximum number of SMs per valve supported by the FPGA license.</td></tr><tr><td><strong>Number of SMs to scope</strong></td><td>Sets how many SMs per valve (status and capacitor voltage) are sent from FPGA to CPU for scoping at the <em>Scope</em> output. If the value is N, data for 2N SMs per valve are sent. This must match the <strong>Number of SMs to display</strong> parameter in the <strong>MMCValvesParam</strong> block (Scope tab).</td></tr><tr><td><strong>Gating signal dimension</strong></td><td>Number of gating signals sent from CPU to FPGA. Use when gating signals for FPGA SMs are generated on the CPU (e.g., for debugging) instead of using low‑level FPGA control or an external controller. To reduce CPU overhead, set the minimum value required.</td></tr><tr><td><strong>CR discrepancy pattern number</strong></td><td>Defines the number of patterns used to create discrepancies in capacitor and shunt resistance parameters across SMs. Must equal the number of <strong>rows</strong> in <strong>Parameter discrepancy data</strong> in the <strong>MMCValvesParam</strong> block (CR discrepancy tab).</td></tr><tr><td><strong>CR discrepancy data in one pattern</strong></td><td>Defines how many SMs are affected by each discrepancy pattern. Must equal the number of <strong>columns</strong> in <strong>Parameter discrepancy data</strong> in the <strong>MMCValvesParam</strong> block (CR discrepancy tab).</td></tr><tr><td><strong>Valve group ID</strong></td><td>Specifies the logical group inside the FPGA in which the valves are simulated.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

## Inputs

<table><thead><tr><th width="156">Input</th><th>Description</th></tr></thead><tbody><tr><td><strong>MMCParam</strong></td><td>Bus carrying parameter values from the <a href="https://www.opal-rt.com/docs/rt-lab/simulink-blocks-reference/mmc-library/mmcvalvesparam.md"><strong>MMCValvesParam</strong></a> block.</td></tr><tr><td><strong>Vref</strong></td><td>Vector of high‑level control signals (modulation index) for the valves (p.u.). Its length must equal <strong>Number of Valves</strong>. Index i in the vector controls valve i. Valid range depends on SM polarity: [0, 1] for unipolar SMs (e.g., Half‑Bridge) and [‑1, 1] for bipolar SMs (e.g., Full‑Bridge). Exceeding these ranges may cause unexpected behavior.</td></tr><tr><td><strong>Vlvmeas</strong></td><td>Bus of valve measurements (currents(A) and voltages(V)). Connect directly to the <strong>meas</strong> output of the corresponding <strong>MMCValves</strong> block. See that block’s documentation for bus contents.</td></tr><tr><td><strong>Vcap</strong></td><td>Bus of valve capacitor voltages (p.u.) when using the CPU‑based SFM. For average model or FPGA‑based SFM, this signal is empty. Connect to the <strong>Vcap</strong> output of the corresponding <strong>MMCValves</strong> block.</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="149">Output</th><th>Description</th></tr></thead><tbody><tr><td><strong>VlvCtrl</strong></td><td><p>Control signals for the <strong>MMCValves</strong> block.</p><p>Format depends on the selected model:</p><ul><li>CPU implementation – Average Model (AVM): Bus with signals v1, v2, …, each carrying the modulation index for the corresponding valve. Content mirrors <strong>Vref</strong>, reorganized as a bus.</li><li>CPU implementation – Switched Function Model: Bus with signals v1, v2, …, each a bus containing g1, g2, g3, g4, g5. Each gk is a vector of gating signals for the k‑th switch of every SM in the valve; vector length equals <strong>Number of SMs per valve</strong>. Elements map to SM order from the positive to the negative terminal. A value of 1 closes the switch; 0 opens it. For SM types with fewer than 5 switches (e.g., Half‑Bridge), unused gating signals are set to zero. The number of valve buses (v1…vN) equals <strong>Number of Valves</strong>.</li><li>FPGA implementation: Empty, as control signals are sent directly to the FPGA model.</li></ul></td></tr><tr><td><strong>Vcap_ave</strong></td><td>Vector of average SM capacitor voltage per valve (ΣVcap / Nsm). For CPU implementations, computed from <strong>Vlvmeas</strong> and <strong>Vcap</strong>. For FPGA implementations, extracted from FPGA data. The i‑th element corresponds to valve i. Units: p.u. Range: [0, ∞) for CPU; [0, 4] for FPGA (FPGA values are saturated at 4 p.u.).</td></tr><tr><td><strong>Scope</strong></td><td>Available only with FPGA implementations. Contains individual data of selected SMs for scoping. Structure: two buses, <em>vlv1to6</em> (valves 1–6) and, if applicable, <em>vlv7to12</em> (valves 7–12). Output groups are always by six valves regardless of <strong>Number of Valves</strong>; when fewer than six are used, only the relevant subset carries meaningful data.</td></tr></tbody></table>

## Characteristics and limitations

<table><thead><tr><th width="263">Characteristic</th><th>Value</th></tr></thead><tbody><tr><td>Maximum number of valves per block</td><td>The number of valves per <strong>MMC Valves Low Level Control</strong> block is limited to 12. Multiple <strong>MMC Valves Low Level Control</strong> blocks can be used for larger systems. The number of valves per FPGA is limited to 12 in current firmware versions.</td></tr><tr><td>Uniform control approach per block</td><td>All valves within a block use the same modulation and voltage balancing control (VBC). Mixing algorithms across valves within a single block is not supported; use multiple blocks if different algorithms are required.</td></tr><tr><td>VBC execution frequency</td><td>Not user‑configurable. For example, sorting VBC cannot be scheduled at a frequency different from that dictated by the simulation time step.</td></tr></tbody></table>


---

# 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/simulink-blocks-reference/mmc-library/mmcvalveslowlvlctrl.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.
