> 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/examples/pwm-generators.md).

# PWM Generators

## Description

This example allows users to explore the FPGA-based **PWM Generators** and understand the effects of each configuration parameter on the generated signals.

The example is available as two separate VeriStand projects, one providing support for the PXIe-7868R FPGA card and the other for the PXIe-7891 FPGA card. Both projects demonstrate the same concepts and behave almost identically.

## Detailed explanation

This example is a collection of eight simple **passthrough circuits**, each containing one voltage **Source**, one voltage **Measurement**, and one PWM-controlled **Switch**. By monitoring the measured voltage of each circuit, we can observe the behavior of the mapped **PWM Generator**.

Four PWM generators are mapped to the switches of a pass-through circuit model, and the measured signals are displayed in VeriStand through the waveform engine.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FtCrtqWc3WVfFul9S7JTG%2Fimage.png?alt=media&amp;token=822ed217-6988-49a5-8b90-fbe04c274881" alt=""><figcaption><p>Passthrough circuits</p></figcaption></figure>

## Configuration

<details>

<summary><strong>Hardware Configuration</strong></summary>

* In the Configuration Tree, expand **Controller >> Custom Devices** and click the **Power Electronics Add-On** custom device to open its configuration page.
* The **Hardware Configuration** selected in the **Configuration** dropdown depends on the FPGA card targeted by the project. Note that this example could be re-created using any Hardware Configuration that contains a set of PWM Generators.

<table><thead><tr><th width="343">NI FPGA Card</th><th>Hardware Configuration</th></tr></thead><tbody><tr><td><strong>NI PXIe-7868R</strong></td><td>eHSx64_Dual_PMSM_VDQ_IO_7868R</td></tr><tr><td><strong>NI PXIe-7891</strong></td><td>eHSx64_Quad_PMSM_VDQ_IO_7891</td></tr></tbody></table>

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FI7NG23HY9adHFLu5FP20%2Fimage.png?alt=media&amp;token=d7278b56-413e-46b9-8948-45c86de4ccbd" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Circuit Model</strong></summary>

* In the Configuration Tree, expand **Power Electronics Add-On** and click **Circuit Model.**
* The **Circuit Model File Path** points to the currently loaded circuit model. Open the file in Simulink to observe the circuit.
* (*optional*) Click **Reload** to trigger a model update in the system definition.
* *(optional)* Click the **Refresh** button to see additional model information.

**Circuit Model File Path:** *\<PWM Generators>\Circuit Model\PassthroughCircuit.slx*

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2F6hdes8HGaTzWV8fRykJS%2Fimage.png?alt=media&amp;token=9b4eac83-b091-4ecf-8ac9-2ab96d606709" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Sources</strong></summary>

The **Sources page** maps signals to each source of the circuit model. In this example, a constant value of 1V is mapped to each source using the VeriStand channels.

* In the Configuration Tree, expand **Circuit Model** and click **Sources**. This page is populated with a list of sources from the circuit model.
* The mappings are configured as shown below, with the **CPU (VeriStand)** option configured for each source.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FoTVfQXS1qSisyoDWjXNP%2Fimage.png?alt=media&amp;token=0b2ee4da-fae0-4bdf-8d8b-bfdc658b3afe" alt="" width="563"><figcaption></figcaption></figure>

* The **Default Value** of each source VeriStand channel is set to 1V.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FcpSd0EWkNj3yxqbTnpF2%2Fimage.png?alt=media&amp;token=a8b10d2c-16de-4fdf-a48c-dd698ecdef19" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Switches</strong></summary>

The **Switches page** maps signals to each switch of the circuit model. In this example, four PWM Generators and their complementary signals are mapped to the eight switches.

* In the configuration tree, expand **Circuit Model** and click **Switches**. This page is populated with a list of switches from the circuit model.
* The mappings are configured as shown below.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2Fi1ipB3XVuW0UpnB1FeCd%2Fimage.png?alt=media&amp;token=c8c887ac-d04d-4421-8e1d-a8205fa95c7c" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>PWM Generators</strong></summary>

In this example, four of the FPGA-based **PWM Generators** are configured with varying parameters so that their effects on the resulting PWM signals can be observed.

* In the configuration tree, expand **Circuit Model** and click **PWM Generators**.
* The **PWM Generators** parameters for **PWM 0**, **PWM 1**, **PWM 2**, and **PWM 3** are configured as shown below. If desired, modify these parameters while the simulation is undeployed to observe the effects on the generated PWM signals.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FAI4vQJsetISkXLlZITn8%2Fimage.png?alt=media&amp;token=2e1f6f24-03ea-47f6-b871-000a150bea8d" alt="" width="563"><figcaption></figcaption></figure>

</details>

<details>

<summary><strong>Waveform Channels</strong></summary>

**Waveform Channels** allow signals to be streamed from the FPGA at a rate faster than that of the CPU execution.

* In the Configuration Tree, expand **Circuit Model** and click **Waveforms**.
* The signals in the example are mapped to the Waveform channels as shown below. The data from these channels will be streamed at the **Sample Rate (S/s)** specified at the bottom of the page.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FW3d30FeRir6s8z36BNiB%2Fimage.png?alt=media&amp;token=ec7c2eb9-b630-4dca-a946-2f2b14120ffe" alt="" width="563"><figcaption></figcaption></figure>

</details>

## Simulation

Open the VeriStand Screen (Mai&#x6E;*.nivsscr*) files and manipulate the parameters in the blue boxes to observe the resulting output signals.

The configuration information displayed in grey is for informational purposes only; these parameters can only be modified from the System Definition file while the project is undeployed.

In this example, all four PWM Generators are operating at **Frequency** of 100Hz and a **Duty Cycle** of 50% by default.

* **Phase Shift Graph**: Displays the effects of a 30° **Phase Shift** applied to **PWM Generator 1** compared to **PWM Generator 0** (with no phase shift).
* **Wave Mode Graph**: Compares a **Symmetric** PWM waveform to an **Asymmetric** waveform.
* **Dead Time Graph**: Shows **PWM Generator 3** and its complement, configured with a **Dead Time** of 0.001 seconds.

Change the **PWM Duty Cycles** of any of the four generators and observe the effects on the respective waveforms. To modify any of the other PWM parameters displayed in grey, undeploy the simulation and edit the parameters in the system definition file on the **PWM Generators** page.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FDGJqHWBl7yadSqIH7TNC%2Fimage.png?alt=media&amp;token=db7adf90-873f-4057-a923-ecb57447f77f" alt=""><figcaption></figcaption></figure>


---

# 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/examples/pwm-generators.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.
