> 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-interpolation.md).

# PWM Generator (Interpolation)

## Description

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

The **PWM Generator (Interpolation)** block, located in the **OPAL-RT SPS Software/Power Electronics/Power Electronics Control** library, generates pulses for PWM-controlled power electronics converters by using a carrier-based, unipolar PWM method with interpolation.

The block can control switching devices with two-quadrant converters, single-phase full-bridges, two-level three-phase bridges, or three-level three-phase bridges. The reference signal at the **Vref** port, also called the modulating signal, is compared with a symmetrical triangle carrier. When the reference signal is greater than the carrier, the pulse for the upper switching device is high (1), and the pulse for the lower device is low (0). The generator uses this unipolar modulation technique to control each arm independently. A second reference signal is internally generated by phase-shifting the original reference signal by 180 degrees.

The interpolation method takes into account switching events that occur between the two sample times of the generator and computes the time delays to capture the evolution of the states at different switching times. The block computes the pulse delays sent to the power electronic gate inputs when the **Use time stamped gate signals** option of the powergui block is enabled.

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

This figure shows Pulse 1 of the output port **P**, delay 1 of the output port **DelayOn** and delay 1 of the output port **DelayOff**.

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

Every time the pulse signal enters the on state, **DelayOn** outputs a value that corresponds to the exact time delay between the computation step and when the pulse entered the on state. In the figure, the Pulse 1 signal enters the on state at 0.09128 seconds (indicated by the blue arrow). At the same moment, the **DelayOn** output for Pulse 1 is 1e-5 seconds. Therefore, the exact time Pulse 1 entered the on state was 0.09128 – 1e-5 = 0.09127 seconds.

Similarly, every time the pulse signal enters the off state, **DelayOff** outputs a value that corresponds to the exact time delay between the computation step and when the pulse entered the offstate. In the figure, Pulse 1 enters the off state at 0.09204 seconds (indicated by the red arrow). At this moment, the **DelayOff** output is equal to 1.09e-5 seconds. Therefore, the exact time Pulse 1 entered the off state was 0.09204 – 1.05e-5 = 0.0920295 seconds.

This time-stamped interpolation technique works only with the following converter blocks:

* Converters built with individual switch blocks
* Universal Bridge blocks (for modelling half bridge, full bridge, and two-level three-phase converters)
* Three-Level Bridge blocks For more information on the sampling techniques, see the PWM Generator (2-Level) block reference page.

## Ports

### Input

<table data-header-hidden><thead><tr><th width="249.88885498046875"></th><th></th></tr></thead><tbody><tr><td><strong>Vref</strong> — Reference voltage<br>Three-phase vector | single-phase scalar</td><td><p>Reference voltage signal used to generate the output pulses, specified as a three-phase vector or a single-phase scalar.</p><p>Connect this input to a single-phase sinusoidal signal to control a single-phase full-bridge converter, or to a three-phase sinusoidal signal to control a three-phase bridge converter.</p><p>For linear operation of this block, the magnitude at <strong>Vref</strong> must be between −1 and +1 Dependencies This port is visible only if <strong>Generator type</strong> is set to one of these values:</p><ul><li>Full-bridge, single-phase</li><li>Two-level, three-phase</li><li>Three-level, three-phase</li></ul><p>.<strong>Data Types:</strong>double</p></td></tr><tr><td><strong>D</strong> — Duty cycle<br>Single-phase scalar</td><td><p>Duty cycle of the PWM generator.</p><p>A value between 0 and 1 determines the percentage of the pulse period that the output is on.</p><p>Dependencies This port is visible only if <strong>Generator type</strong> is set to Two-quadrant.</p><p><strong>Data Types:</strong> double</p></td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="250.11114501953125"></th><th></th></tr></thead><tbody><tr><td><strong>P</strong> — Pulses<br>Vector</td><td>Output pulses, returned as a vector.<strong>Data Types:</strong>double</td></tr><tr><td><strong>DelayOn</strong> — On delay<br>Scalar</td><td>Output representing the delay between when the pulses entered the on state, returned as a scalar.<strong>Data Types:</strong>double</td></tr><tr><td><strong>DelayOff</strong> — Off delay<br>Scalar</td><td><p>Output representing the delay between when the pulses entered the off state, returned as a scalar.</p><p><strong>Data Types:</strong> double</p></td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="250.22216796875"></th><th></th></tr></thead><tbody><tr><td><strong>Generator type</strong> — PWM model<br>Two-level, three-phase (default) | Two-quadrant | Full-bridge, single phase | Three-level, three-phase</td><td><p>Type of generator to control. The number of pulses generated by the block is proportional to the number of bridge arms to fire.</p><ul><li>Select Two-quadrant to fire the self-commutated devices of a two-quadrant converter.</li><li>The duty cycle of the generator is specified by the input <strong>D</strong>, which determines the percentage of the pulse period that the pulse is on. Two pulses are generated.</li><li>Select Full-bridge, single-phase to fire the self-commutated devices of a single-phase full-bridge converter.</li><li>Four pulses are generated. Pulses 1 and 3 fire the upper devices of the first and second arm. Pulses 2 and 4 fire the lower devices.</li><li>Select Two-level, three-phase (default) to fire the self-commutated devices of a three-phase bridge converter. Six pulses are generated.</li><li>Pulses 1, 3, and 5 fire the upper devices of the first, second, and third arms. Pulses 2, 4, and 6 fire the lower devices.</li><li>Select Three-level, three-phase to fire the self-commutated devices of a three-level three phase bridge.</li><li>Twelves pulses are generated. Pulses (1, 2), (5, 6), and (9, 10) fire the upper devices of the first, second, and third arms.</li><li>Pulses (3, 4), (7, 8), and (11, 12) fire the lower devices of the three arms.</li></ul></td></tr><tr><td><strong>Carrier frequency (Hz)</strong> — Carrier signal frequency<br>2000 (default)</td><td>Frequency, in Hz, of the triangular carrier signal. The value must be greater than 0</td></tr><tr><td><strong>Carrier initial phase (deg)</strong> — Carrier signal initial phase<br>0 (default)</td><td><p>Carrier signal initial phase, in deg.</p><p>A value of 90 degrees means that the triangle carrier initial position is set to the midpoint between its minimum and maximum value and the slope is positive.</p></td></tr><tr><td><strong>Sample time (s)</strong> — Block sample time<br>50e-6 (default)</td><td>Sample time of the block, in s. The value must be positive and greater than 0.</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/smart-power-simulation-software-sps/blocks-functions-tools/control-and-measurements/pulse-and-signal-generators/pwm-generator-interpolation.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.
