> 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/svpwm-generator-2-level.md).

# SVPWM Generator (2-Level)

## Description

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

The **SVPWM Generator (2-Level)** block, located in the **OPAL-RT SPS Software/Sources / Signal Generator Sources** library, generates pulses for three-phase two-level DC/AC converters using the space-vector pulse width modulation (SVPWM) technique. The converter switches are represented by the following equivalent circuit:

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

As shown in the following figure, the objective of the SVPWM technique is to approximate the reference voltage vector (Uref) instantaneously by combining the switching states corresponding to the basic space vectors.

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

More precisely, for every PWM period, the reference vector Uref is averaged by using its two adjacent space vectors (U3 and U4 in the figure) for a certain duration of time and a null vector (U7 or U8) for the rest of the period.

| **Vector** | **Q1** | **Q3** | **Q5** |
| ---------- | ------ | ------ | ------ |
| U1         | 1      | 0      | 0      |
| U2         | 1      | 1      | 0      |
| U3         | 0      | 1      | 0      |
| U4         | 0      | 1      | 1      |
| U5         | 0      | 0      | 1      |
| U6         | 1      | 0      | 1      |
| U7         | 0      | 0      | 0      |
| U8         | 1      | 1      | 1      |

The block implements two symmetrical switching patterns \[1]:

* Pattern #1: With this pattern, known as Software-Determined, each PWM channel switches twice per every PWM period.
* Pattern #2: With this pattern, known as Hardware-Determined, one PWM channel remains constant for the entire PWM period. Consequently, the number of switching times for this pattern is less than pattern #1. As a result, switching losses are reduced with Pattern #2.

## Characteristics

<table data-header-hidden><thead><tr><th width="250.3333740234375"></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.88885498046875"></th><th></th></tr></thead><tbody><tr><td><strong>|U|</strong> — Magnitude of rotating reference vector<br></td><td><p>Magnitude of the rotating reference vector U<sub>ref</sub>.</p><p>Dependencies To enable this port, set <strong>Data type of input reference vector (Uref)</strong> to Magnitude-Angle (rad).</p></td></tr><tr><td><strong>⦟U</strong> — Phase of rotating reference vector<br></td><td><p>Phase, in radians, of the rotating reference vector U<sub>ref</sub>.</p><p>Dependencies To enable this port, set <strong>Data type of input reference vector (Uref)</strong> to Magnitude-Angle (rad).</p></td></tr><tr><td><strong>Uα</strong> — Alpha components of rotating reference vector<br></td><td><p>Alpha components of the rotating reference vector U<sub>ref</sub>.</p><p>Dependencies To enable this port, set <strong>Data type of input reference vector (Uref)</strong> to alpha-beta components.</p></td></tr><tr><td><strong>Uβ</strong> — Beta components of rotating reference vector<br></td><td><p>Beta components of the rotating reference vector U<sub>ref</sub>.</p><p>Dependencies To enable this port, set <strong>Data type of input reference vector (Uref)</strong> to alpha-beta components.</p></td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="250.22222900390625"></th><th></th></tr></thead><tbody><tr><td><strong>P</strong> — Pulse signals used to fire self-commutated devices<br></td><td>Six pulse signals to fire the self-commutated devices (Q1 to Q6) of a converter device.</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.77777099609375"></th><th></th></tr></thead><tbody><tr><td><strong>Data type of input reference vector (Uref)</strong> — Type of reference vector<br>Magnitude-Angle (rad) (default) | alpha-beta components | Internally generated</td><td><p>Specify the type of reference vector. When set to Magnitude-Angle (rad) (default), the U<sub>ref</sub> vector is specified by the following inputs: |<em>U</em>| Magnitude of Uref (value between 0 and 1) When set to alpha-beta components, the U<sub>ref</sub> vector is specified by the Uα and Uβ inputs.</p><p>When set to Internally generated, the U<sub>ref</sub> is no longer an input to the block.</p><p>It is internally generated in order to control the converter output voltage as specified in the output voltage parameter.</p></td></tr><tr><td><strong>Switching pattern</strong> — Switching pattern<br>Pattern #1 (default) | Pattern #2</td><td><p>When set to Pattern #1 (default), every device of the converter switches twice per every PWM period.</p><p>When set to Pattern #2, the status of one of the three arms stays constant (no switching) for the entire PWM period.</p></td></tr><tr><td><strong>PWM frequency (Hz)</strong> — PWM frequency<br>2000 (default)</td><td>PWM frequency that determines the PWM period. > <em>PWMperiod</em>=1/<em>PWMFrequency</em></td></tr><tr><td><strong>Output voltage: [ Mag (0&#x3C;m&#x3C;1), Phase (degrees), Freq (Hz)]</strong> — Magnitude, phase, and frequency of output voltage<br>[0.8 -30 50] (default)</td><td><p>Magnitude, phase, and frequency of the output voltage of the two level converter controlled by the block.</p><p>The magnitude of the fundamental component of the converter line-to-line output voltage is defined as<br><span class="math">\\[8pt] V_{LLrms}=m\times \frac{V_{dc}}{\sqrt{2}}\\[8pt]</span><span class="math">\\[8pt]</span></p><p><strong>Dependencies</strong> To enable this parameter, set <strong>Data type of input reference vector Uref</strong> to Internally generated.</p></td></tr><tr><td><strong>Sample time</strong> — Sample time<br>0 (default)</td><td>Specify the sample time of the block, in seconds. Set to 0 to implement a continuous block.</td></tr></tbody></table>

## Examples

The power\_SVPWMGenerator2Level model uses two simple circuits to show how the SVPWM Generator (2-Level) works and to compare the two switching pattern options. Run the simulation and open the FFT Analysis tool of the Powergui block to see the harmonics and the THD value of the voltages produced by the two converters.

The model sample time is parameterized by the Ts variable set to a default value of 2e-6 s. 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/svpwm-generator-2-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.
