> 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/rt-lab/simulink-blocks-reference/rt-events-library/rte-pwm.md).

# RTE PWM

## Description

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-05257b9ba11ce944e9266eebbba9bc25fb9b49c4%2FRTE_PWM_block.png?alt=media" alt="" width="101"><figcaption></figcaption></figure>

The **RTE PWM** block, located in the **RT-EVENTS/Source** library, generates square-wave pulses at regular time intervals. The frequency and duty cycle inputs define the output waveform.

The block supports scalar, vector, or matrix signals. Use scalar inputs to produce a scalar output; use vector or matrix inputs to produce vector or matrix outputs, respectively. Each element of the inputs controls the corresponding element of the output. All inputs must have the same dimensions after scalar expansion.

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-18a83fdf675a2f23a8eafc3727c49c1caadb74bd%2FRTE_PWM_charac.png?alt=media" alt=""><figcaption><p>Main characteristics of the generates square wave pulses</p></figcaption></figure>

The Maximum number of events parameter sets the limit on transitions that can occur during one calculation step, which also bounds the maximum output frequency: Fmax = Num / ( 2 \*Ts), where Num and Ts are the maximum numbers of events and the block sample time.

**Shifted transitions**

In normal operation, frequency updates take effect when the current period completes, avoiding frequency spikes. At low frequencies, this can delay updates because the block waits for the ongoing period to finish before applying the new frequency.

When shifted transitions are enabled, the block updates as soon as possible to reach the new frequency. This behavior is closer to real sensors and provides faster updates at low frequency, but some hardware devices may interpret the intermediate half-period shift differently.

For example, in a model with a 250 Hz pulse generator and a 1 ms sample time, if shifted transition is disabled and the frequency is increased to 1000 Hz, the block waits until the next 250 Hz transition to update, using that next transition as the reference. If shifted transition is enabled, the block uses the previous transition as the reference.

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

## Mask parameters

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-91392c4c5035fa01c4a18abf0a8065bc10f05202%2FRTE_PWM_mask.png?alt=media" alt="" width="313"><figcaption></figcaption></figure>

<table><thead><tr><th width="259.60003662109375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Shifted transition</strong></td><td>Enable or disable shifted transition: disabled, enabled.</td></tr><tr><td><strong>Maximum number of events</strong></td><td>Maximum number of events (transitions) that can occur during a single step.</td></tr><tr><td><strong>Sample time</strong></td><td>Time interval between samples, in seconds.</td></tr></tbody></table>

## Inputs

<table><thead><tr><th width="260.39996337890625">Input</th><th>Description</th></tr></thead><tbody><tr><td><strong>Frequency (Double)</strong></td><td>Pulse frequency in Hz.</td></tr><tr><td><strong>Duty Cycle (Double)</strong></td><td>Percentage of the period during which the signal is on.</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="259.60003662109375">Output</th><th>Description</th></tr></thead><tbody><tr><td><strong>Output (RTE Boolean)</strong></td><td>RTE Boolean signal generated by the PWM block.</td></tr></tbody></table>

## Characteristics and limitations

| Characteristic     | Value          |
| ------------------ | -------------- |
| Direct Feedthrough | No             |
| Sample Time        | Fixed discrete |
| Work Offline       | Yes            |
| Dimensionalized    | Yes            |


---

# 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/rt-lab/simulink-blocks-reference/rt-events-library/rte-pwm.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.
