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

# PWM Generator (DC-DC)

## Description

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

The **PWM Generator (DC-DC)** block, located in the **OPAL-RT SPS Software/Power Electronics/Power Electronics Control** library, outputs a pulse to fire the MOSFET, GTO, or IGBT switch of a one-quadrant converter (buck or boost).

The duty cycle of the generator is specified by the input D. A value between 0 and 1 determines the percentage of the pulse period that the output is on.

## Characteristics

<table data-header-hidden><thead><tr><th width="249.66668701171875"></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="250.11114501953125"></th><th></th></tr></thead><tbody><tr><td><strong>D</strong> — Generator duty cycle<br>Scalar in the range [0,1]</td><td>Duty cycle of the generator. Specify a signal with a value between 0 and 1.</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> — Signal to convert into equivalent current source<br></td><td>Pulse that the generator outputs.</td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="249.77777099609375"></th><th></th></tr></thead><tbody><tr><td><strong>Switching frequency (Hz)</strong> — Generator switching frequency<br>5000 (default) | scalar</td><td><p>Switching frequency Fsw of the generator, in hertz.</p><p>The switching frequency is the frequency of the internal sawtooth signal used to generate the pulse.</p></td></tr><tr><td><strong>Sample time</strong> — Block sample time<br>0 (default) | scalar</td><td><p>Sample time of the block, in seconds.</p><p>Set to 0 to implement a continuous block.</p></td></tr></tbody></table>

## Examples

The power\_PWMGeneratorDCDC example shows the operation of the PWM Generator (DC-DC) block. Run the simulation for various duty cycles values and observe the resulting voltage and current on the Scope block.

The model sample time is parameterized with variable Ts (default value Ts = 500e-9). To run a continuous simulation, at the MATLAB® command prompt, enter

{% code lineNumbers="true" %}

```matlab
Ts = 0
```

{% endcode %}

and set the **Simulation type** parameter of the Powergui block to Continuous before starting the simulation.


---

# 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-dc-dc.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.
