> 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/logic/on-off-delay.md).

# On/Off Delay

## Description

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

The **On/Off Delay** block, located in the **OPAL-RT SPS Software/Control** library, implements switch-on or switch-off delay with the following logic when the **Select type** parameter is set to **On delay**:

* When the input becomes true, the output becomes true after a preset time delay. The output remains true as long as the input is true.
* When the input is false or becomes false, the output becomes false with no delay.
* When the **Initial condition of previous input** parameter is set to 1, and the input is true at t = 0, the output is true with no delay.

The On/Off Delay block implements the following logic when the **Select type** parameter is set to **Off delay**:

* When the input becomes false, the output becomes false after a preset time delay. The output remains false as long as the input is false.
* When the input is true or becomes true, the output is true with no delay.
* When the **Initial condition of previous input** parameter is set to 0, and the input is false at t = 0, the output is false with no delay.

## Characteristics

<table data-header-hidden><thead><tr><th width="250.4444580078125"></th><th></th></tr></thead><tbody><tr><td>Direct Feedthrough</td><td>Yes</td></tr><tr><td>Sample Time</td><td>Specified in the <strong>Sample Time</strong> parameter</td></tr><tr><td>Scalar Expansion</td><td>Yes, of parameters</td></tr><tr><td>Dimensionalized</td><td>Yes</td></tr><tr><td>Zero-Crossing Detection</td><td>No</td></tr></tbody></table>

## Ports

### Input

<table data-header-hidden><thead><tr><th width="250.22222900390625"></th><th></th></tr></thead><tbody><tr><td><strong>In</strong> — Delay input<br>boolean</td><td>Input of Delay block.</td></tr></tbody></table>

### Output

<table data-header-hidden><thead><tr><th width="250.00006103515625"></th><th></th></tr></thead><tbody><tr><td><strong>Out</strong> — Delay output<br>boolean</td><td><p>Output of Delay block.</p><p>The value of the output depends on the value of the <strong>Select type</strong> and <strong>Initial condition of previous input</strong> parameters.</p></td></tr></tbody></table>

## Parameters

<table data-header-hidden><thead><tr><th width="250"></th><th></th></tr></thead><tbody><tr><td><strong>Select type</strong> — Type of delay<br>On delay (default) | Off delay</td><td>Select between On delay (default for On Delay blocks) or Off delay (default for Off Delay blocks).</td></tr><tr><td><strong>Time delay (s)</strong> — Duration of delay<br>0.01 (default) | nonnegative scalar</td><td>Duration of the delay, in seconds. When the <strong>Sample time</strong> parameter is greater than 0, the time delay value must be a multiple of the sample time.</td></tr><tr><td><strong>Initial condition of previous input</strong> — Proportional, integral, and derivative gains of internal PID controller<br>0 (default) | 1 | nonnegative scalar</td><td>Initial value of the previous input. Default is 0 for On Delay blocks and 1 for Off Delay blocks.</td></tr><tr><td><strong>Sample time</strong> — Block sample time<br>0 (default) | nonnegative scalar</td><td>Sample time of the block, in seconds. Set to 0 to implement a continuous block.</td></tr></tbody></table>

## Examples

The power\_Logic example shows the operation of the On/Off Delay block.

The model sample time is parameterized with the variable Ts (default value Ts = 5e-3). To simulate a continuous On/Off Delay block, specify Ts = 0 in the MATLAB® Command Window.


---

# 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/logic/on-off-delay.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.
