> 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/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/spwm-generators-section.md).

# SPWM Generators Section

## Overview

Use the SPWM Generators to generate sinusoidal pulse width modulated signals on the FPGA. These signals can be mapped directly to the circuit model Switches.

Sine Triangle PWM is a common modulation technique for converting DC power sources into AC power sources. In the Power Electronics Add-On, the specific implementation of the SPWM generators allows for multiple SPWM signal outputs, but only one carrier frequency and one modulation index. Frequency Engines are responsible for storing the current phase for signals based on their frequency and a free-running clock on the FPGA represented as 'time' in the following equation

$$
\\\[8pt]
\text{Frequency Engine X Phase}
\= 2 \* \pi \* \text{SPWM Frequency Engine X} \* \text{time}
\\\[8pt]
$$

Each SPWM Generator can select which Frequency Engine to use through the **Frequency Engine** channel.

$$
\\\[8pt]
\text{Modulation Signal}
\= \text{Modulation Index} \* \sin(\text{Frequency Engine X Phase} + \text{Phase})
\\\[8pt]
$$

Modulation & carrier signals are internal signals used for storing the current state of each individual SPWM generator. The carrier signal is a triangle wave whose frequency is set by the **Carrier Frequency** channel. The amplitude of the Modulation signal is set through the **Modulation Index** channel.

$$
SPWM\ Signal =
\begin{cases}
\text{True} & \text{if Modulation Signal } > \text{ Carrier Signal},\\\[8pt]
\text{False} & \text{if Modulation Signal } \leq \text{ Carrier Signal}.\\\[8pt]
\end{cases}
$$

When the Modulation signal is greater than the Carrier Signal, the SPWM generator outputs True, otherwise it outputs False. The animation below shows the internal Modulation and Carrier signals with the corresponding SPWM signal. In this example, the **Modulation Index** is 0.6.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FKmonCoWWnce2J3JcFVuE%2F4710eaae-b934-48a5-a6a0-a4c5cea8437f.gif?alt=media&amp;token=e53e4bb8-0a5c-4c9f-98c0-ed9e8f25483a" alt=""><figcaption></figcaption></figure>

## SPWM Generators Section Channels

In the System Explorer window configuration tree, expand the Power Electronics Add-On custom device, then **Circuit Model >> SPWM Generator**s to display the subsections and custom device channels. Assign values to the channels to configure the SPWM Generators.

{% hint style="info" %}
The value of an input channel can be modified dynamically at execution time.
{% endhint %}

### SPWM Carrier

<table><thead><tr><th width="240.22235107421875">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>Carrier Frequency (Input)</strong></td><td>Frequency of the Carrier signal (Hz) (Default Value: 5000 Hz).</td></tr><tr><td><strong>Modulation Index (Input)</strong></td><td><p>Amplitude of the Modulation signal.</p><p>(Default Value: 1).</p></td></tr></tbody></table>

### SPWM Frequency Generators

<table><thead><tr><th width="239.77777099609375">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>SPWM Frequency Engine X</strong></p><p><strong>(Input)</strong></p></td><td>Frequency of the Modulation signal (Hz) (Default Value: 60 Hz).</td></tr></tbody></table>

### SPWM Generator X

<table><thead><tr><th width="240.4888916015625">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>Dead Time (Input)</strong></td><td><p>Time during which both the SPWM signal and its complementary are held inactive immediately before the SPWM signal goes active (Seconds)</p><p>(Default Value: 0 s).</p></td></tr><tr><td><strong>Frequency Engine (Input)</strong></td><td>Index of the SPWM Frequency Engine used to generate the PWM signal. Setting a value of <strong>2</strong> will connect <strong>SPWM Frequency Engine 2</strong> to the SPWM generator. Use the same SPWM Frequency Engine with multiple different SPWM generators to ensure that they stay phase locked in time.<br>(Default Value: 0).</td></tr><tr><td><strong>Phase (Input)</strong></td><td>Phase offset of the generated SPWM signal relative to the other SPWM signals using the same frequency engine (Degrees) (Default Value: 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/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/spwm-generators-section.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.
