> 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/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/pulse-and-signal-generators/pwm-generator-3-level.md).

# PWM Generator (3-Level)

## Description

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

The **PWM Generator (3-Level)** block, located in the **OPAL-RT SPS Software/Power Electronics/Power Electronics Control** library, generates pulses for carrier-based pulse-width modulation (PWM) converters using three-level topology.

The block can control switching devices (FETs, GTOs, or IGBTs) of three different converter types: single-phase half-bridge (one arm), single-phase full-bridge (two arms), or three-phase bridge (three arms).

The reference signal (Uref input), also called the modulating signal, is naturally sampled and compared with two symmetrical level-shifted triangle carriers.

The following figure shows how the pulses are generated for a single-phase, half-bridge three-level converter.

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

The converter arm can have three states: +1, 0, or −1. When the reference signal is greater than the positive carrier, the state of the arm is +1; when the reference signal is smaller than the negative carrier, the state of the arm is −1.

Otherwise, the state is 0. Based on the current state of the arm, the appropriate pulses are generated.

| **State** | **Q1** | **Q2** | **Q3** | **Q4** |
| --------- | ------ | ------ | ------ | ------ |
| 1         | 1      | 1      | 0      | 0      |
| 0         | 0      | 1      | 1      | 0      |
| −1        | 0      | 0      | 1      | 1      |

One reference signal is required to generate the four pulses of an arm. For a single-phase full-bridge converter, a second reference signal is required to generate the four pulses of the second arm. This signal is internally generated by phase-shifting the original reference signal by 180 degrees.

For a three-phase bridge, three reference signals are required to generate the 12 pulses.

The reference signal also can be internally generated by the PWM generator.

In this case, specify a modulation index, voltage output frequency, and phase.

## Characteristics

<table data-header-hidden><thead><tr><th width="250.33331298828125"></th><th></th></tr></thead><tbody><tr><td>Sample Time</td><td>Specified in the <strong>Sample Time</strong> parameter Continuous if <strong>Sample Time</strong> = 0</td></tr><tr><td>Scalar Expansion</td><td>No</td></tr><tr><td>Dimensionalized</td><td>No</td></tr></tbody></table>

## Ports

### Input

<table data-header-hidden><thead><tr><th width="249.66656494140625"></th><th></th></tr></thead><tbody><tr><td><strong>Uref</strong> — Reference signal used to generate Output pulses<br></td><td><p>Vectorized reference signal used to generate the output pulses.</p><p>Connect this input to a single-phase sinusoidal signal when the block is used to control a single-phase half- or full-bridge converter, or to a three-phase sinusoidal signal when the PWM Generator block is controlling a three-phase bridge converter.</p><p>For linear operation of this block, the magnitude of <strong>Uref</strong> must be between −1 and +1.</p><p><strong>Dependencies</strong> To enable this port when <strong>Mode of operation</strong> is Synchronized, clear the <strong>Internal generation of modulating signal (s)</strong> parameter.</p></td></tr><tr><td><strong>wt</strong> — External reference signal used to Synchronize carrier<br></td><td><p>External reference signal used to synchronize the carrier.</p><p><strong>Dependencies</strong> To enable this port, set <strong>Mode of operation</strong> to Synchronized.</p></td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="249.88885498046875"></th><th></th></tr></thead><tbody><tr><td><strong>m</strong> — Measurement output<br></td><td>The output contains the 4, 8, or 12 pulses used to fire the self-commutated devices (MOSFETs, GTOs, or IGBTs) of a one-, two- or three-arm three-level converter.</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.888916015625"></th><th></th></tr></thead><tbody><tr><td><strong>Generator type</strong> — Number of pulses to generate<br>Single-phase half-bridge (4 pulses) (default) | Single-phase full-bridge (8 pulses) | Three-phase bridge (12 pulses)</td><td><p>Specify the number of pulses to generate. The number of pulses generated by the block is proportional to the number of bridge arms to fire.</p><p>Select Single-phase half-bridge (4 pulses) to fire the self-commutated devices of a single-phase half-bridge converter. Pulses (1, 2) fire the upper devices and pulses (3, 4) fire the lower devices.</p><p>Select Single-phase full-bridge (8 pulses) to fire the self-commutated devices of a single-phase full-bridge converter.</p><p>Eight pulses are then generated. Pulses (1, 2) and (5, 6) fire the upper devices of the first and second arms.</p><p>Pulses (3, 4) and (7, 8) fire the lower devices of the first and second arms.</p><p>Select Three-phase bridge (12 pulses) (default) to fire the self-commutated devices of a three-phase bridge converter.</p><p>Pulses (1, 2), (5, 6), and (9, 10) fire the upper devices of the first, second, and third arms. Pulses (3, 4), (7, 8), and (11, 12) fire the lower devices of the three arms.</p></td></tr><tr><td><strong>Mode of operation</strong> — Mode of operation of carrier signal<br>Unsynchronized (default) | Synchronized</td><td><p>When set to Unsynchronized, the frequency of the unsynchronized carrier signal is determined by the <strong>Carrier frequency (Hz)</strong> parameter.</p><p>When set to Synchronized, the carrier signal is synchronized to an external reference signal (input wt) and the carrier frequency is determined by the <strong>Switching ratio (carrier frequency/output frequency)</strong> parameter.</p></td></tr><tr><td><strong>Carrier frequency (Hz)</strong> — Frequency of triangular carrier signal<br>27*60 (default)</td><td><p>Frequency, in hertz, of the triangular carrier signal.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Unsynchronized.</p></td></tr><tr><td><strong>Switching ratio (carrier frequency/output frequency)</strong> — Frequency of triangular carrier signal<br>27 (default)</td><td>Frequency (<em>F</em><sub><em>c</em></sub>) of the triangular carrier signal. > <em>F</em><sub><em>c</em></sub>=<em>SwitchingRatio</em>×<em>OutputVoltageFrequency</em><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Synchronized.</td></tr><tr><td><strong>Internal generation of reference signal(s)</strong> — Internal generation of reference signal<br>off (default) | on</td><td><p>When selected, the reference signal is generated by the block.</p><p>When not selected, external reference signals are used for pulse generation. This parameter is available only if the <strong>Mode of operation</strong> parameter is set to Unsynchronized.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Unsynchronized.</p></td></tr><tr><td><strong>Modulation index</strong> — Modulation index<br>0.8 (default)</td><td><p>Modulation index to control the amplitude of the fundamental component of the output voltage of the converter.</p><p>The modulation index must be greater than 0 and lower than or equal to 1.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Unsynchronized and select <strong>Internal generation of reference signal</strong>.</p></td></tr><tr><td><strong>Output voltage frequency (Hz)</strong> — Frequency of reference signal<br>60 (default)</td><td><p>Output voltage frequency used to control the frequency of the fundamental component of the output voltage of the converter.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Unsynchronized and select <strong>Internal generation of reference signal</strong>.</p></td></tr><tr><td><strong>Output voltage phase (degrees)</strong> — Phase of reference signal<br>0 (default)</td><td><p>Phase of the fundamental component of the output voltage of the converter.</p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Mode of operation</strong> to Unsynchronized and select <strong>Internal generation of reference signal</strong>.</p></td></tr><tr><td><strong>Sample time</strong> — Sample time<br>0 (default)</td><td>Sample time of the block, in seconds. Set to <code>0</code> to implement a continuous block.</td></tr></tbody></table>

## Examples

The power\_PWMGenerator3Level model uses a simple circuit to show how the PWM Generator (3-Level) operates. Run the simulation and use the FFT Analysis tool of the Powergui block to see the harmonics and the THD value of the voltages produced by the three-phase three-level converter.

The model sample time is parameterized by the Ts variable set to a default value of 2e-6. Set Ts to 0 in the command window and change the **Simulation type** parameter of the Powergui block to Continuous to simulate the model in continuous mode.


---

# 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/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/pulse-and-signal-generators/pwm-generator-3-level.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.
