> 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/hypersim/library-blocks-reference/control-sources/pwm-average-generator-for-3-level-converter-switching-function.md).

# PWM Average Generator for 3-Level Converter (Switching Function)

## Description

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-719a8286cddb2e58031ec7369384020e51ee3dd2%2Fimage%20(975).png?alt=media" alt="" width="222"><figcaption></figcaption></figure>

The **PWM Average Generator for 3-Level Converter (Switching Function)** block is a pulse generator averaged over the simulation time step. It uses interpolation to determine the exact high-to-low and low-to-high transition instants within each sample time, enabling accurate switching timing.

The generator produces a pulse value based on carrier-based natural sampling and the simulation time step. If a transition occurs within a sample, it outputs a value between 0 and 1 equal to the ON-state time ratio during that step. For example, with a carrier frequency of 2 kHz, a duty cycle of 0.8, and a time step of 50 μs, a value of 0.25 indicates a 0-to-1 transition at 0.25 · Ts, and a value of 0.75 indicates a 1-to-0 transition at 0.75 · Ts.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-1dfde32d44909bcecc3e138a0d13b0ff9e93b852%2Fimage%20(974).png?alt=media" alt="" width="563"><figcaption><p>Operating principle of this model for a carrier frequency (Fc) of 2 kHz and a duty cycle of 0.8. The time step is 50 μs.</p></figcaption></figure>

{% hint style="danger" %}
Use this block with the **3-Level NPC Converter (Switching Function)**.
{% endhint %}

## Mask parameters

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a22a1af17be1ff56df9c87e676819f4cec2e9587%2Fimage%20(976).png?alt=media" alt="" width="545"><figcaption></figcaption></figure>

<table><thead><tr><th width="239.60003662109375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Description</strong></td><td>Text field to document the block.</td></tr><tr><td><strong>PWM carrier frequency</strong></td><td>Frequency of the triangular carrier (Hz).<br>FrequencyCarrier = [0, 1e12].</td></tr><tr><td><strong>PWM carrier initial phase</strong></td><td>Initial phase of the carrier (°). InitialPhase = [0, 360].</td></tr></tbody></table>

{% hint style="info" %}
For accuracy, set the simulation time step to no more than one-tenth of the carrier period (1/Fc).
{% endhint %}

## Inputs

<table><thead><tr><th width="190">Input</th><th>Description</th></tr></thead><tbody><tr><td><strong>Vref</strong></td><td>Vectorized reference signal with phase-ground voltages Va, Vb, and Vc. Range: -1 to 1.</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="180.39996337890625" valign="top">Output</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><strong>P</strong></td><td><p>Vectorized signal containing six firing pulses to control the converter:</p><p><strong>Va</strong>: Reference voltage for phase A (V)</p><p><strong>Vb</strong>: Reference voltage for phase B (V)</p><p><strong>Vc</strong>: Reference voltage for phase C (V)</p><p><strong>P1</strong>: Firing pulse for Q1 (phase A upper arm)</p><p><strong>P2</strong>: Firing pulse for Q2 (phase A upper arm)</p><p><strong>P3</strong>: Firing pulse for Q3 (phase A lower arm)</p><p><strong>P4</strong>: Firing pulse for Q4 (phase A lower arm)</p><p><strong>P5</strong>: Firing pulse for Q5 (phase B upper arm)</p><p><strong>P6</strong>: Firing pulse for Q6 (phase B upper arm)</p><p><strong>P7</strong>: Firing pulse for Q7 (phase B lower arm)</p><p><strong>P8</strong>: Firing pulse for Q8 (phase B lower arm)</p><p><strong>P9</strong>: Firing pulse for Q9 (phase C upper arm)</p><p><strong>P10</strong>: Firing pulse for Q10 (phase C upper arm)</p><p><strong>P11</strong>: Firing pulse for Q11 (phase C lower arm)</p><p><strong>P12</strong>: Firing pulse for Q12 (phase C lower arm)</p></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/hypersim/library-blocks-reference/control-sources/pwm-average-generator-for-3-level-converter-switching-function.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.
