> 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-generator-for-2-level-converter-switching-devices.md).

# PWM Generator for 2-Level Converter (Switching Devices)

## Description

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

The **PWM generator for 2-level converter** block generates pulses for carrier-based pulse width modulation (PWM) converters using a two-level topology.

The reference signal (Vref), also known as the modulation signal, is compared with a symmetrical triangular carrier. When the reference signal is higher than the carrier, the pulse for the upper switching component is high (1) and that of the lower device is low (0).

The carrier frequency (fc) is defined by the frequency of the converter output voltage and by the converter switching ratio:

$$
f\_c = Switching ratio \times Output Voltage Frequency.
$$

To control the 2-Level Converter (Switching Devices), the pulse generator produces pulses 1, 3, and 5 for the upper switching components of the first, second, and third arms, and pulses 2, 4, and 6 for the lower switching components of the first, second, and third arms.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-0de8ca2a880de786458aef3937b817fc6b619a50%2Fimage%20(980).png?alt=media" alt="" width="563"><figcaption><p>Technique used to sample the reference signal Vref.</p></figcaption></figure>

Natural sampling models an analog PWM generator. Using this technique, Vref can be sampled twice at both the valley and the peak of the carrier, or only once at the valley of the carrier.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-ea75c32817e72b389a5983ffd83d31aa0dcdcf3b%2Fimage%20(981).png?alt=media" alt="" width="563"><figcaption><p>Internal circuit of the block</p></figcaption></figure>

{% hint style="danger" %}
Use this block with the **2-Level Converter (Switching Devices)**.
{% 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-ded9773e56fb32f5cb31f408b5e7142c33c2a538%2Fimage%20(982).png?alt=media" alt="" width="545"><figcaption></figcaption></figure>

<table><thead><tr><th width="270">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Description</strong></td><td>Use this field to add information about the block.</td></tr><tr><td><strong>PWM carrier frequency</strong></td><td>Frequency of the triangular carrier signal (Hz), FrequencyCarrier = [0, 1e12]</td></tr><tr><td><strong>PWM carrier initial phase</strong></td><td>Initial phase of the carrier (°). A value of 90° sets the triangle carrier to the midpoint between its minimum and maximum values with a positive slope. InitialPhase = [0, 360]</td></tr></tbody></table>

## Inputs

<table><thead><tr><th width="179.5999755859375">Input</th><th>Description</th></tr></thead><tbody><tr><td><strong>Vref</strong></td><td>Vectorized reference voltage signal containing the phase-to-ground voltages of the AC side (Va, Vb, Vc).</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="180.4000244140625" 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.<br><strong>Va, Vb, Vc</strong>: Reference voltage signals from phases A, B, and C on the AC side (V).</p><p><strong>P1</strong>: Firing pulse to control Q1 (phase A upper arm).</p><p><strong>P2</strong>: Firing pulse to control Q2 (phase A lower arm).</p><p><strong>P3</strong>: Firing pulse to control Q3 (phase B upper arm).</p><p><strong>P4</strong>: Firing pulse to control Q4 (phase B lower arm).</p><p><strong>P5</strong>: Firing pulse to control Q5 (phase C upper arm).</p><p><strong>P6</strong>: Firing pulse to control Q6 (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-generator-for-2-level-converter-switching-devices.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.
