> 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/additional-components/discrete-variable-time-delay.md).

# Discrete Variable Time Delay

## Description

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

The **Discrete Variable Time Delay** block, located in the **OPAL-RT SPS Software/Control** library, delays the input signal by the value specified in the D input. At each simulation time step, the Discrete Variable Time Delay block saves the time and the input value in an internal buffer and outputs the previous input value determined by the delay input.

When the delay input is not an integer of the time step, the Discrete Variable Time Delay block performs linear interpolation. When the **Direct feedthrough** parameter is selected, the delay can be less than the simulation time step.

## Parameters

<table data-header-hidden><thead><tr><th width="249.88897705078125"></th><th></th></tr></thead><tbody><tr><td><strong>Maximum delay (s)</strong></td><td><p>Specify the expected maximum delay of the D input delay, in seconds.</p><p>The <strong>Maximum delay</strong> parameter determines the input buffer size. When the maximum delay is exceeded, the delay is clipped to the maximum delay value. Default is 1.</p></td></tr><tr><td><strong>Initial conditions</strong></td><td><p>Specify the initial conditions of the signal.</p><p>The block outputs the specified values until the first delayed sample of signal is out. Default is 0. Set to 0 to implement null initial output, or specify the N previous input values of signal to start from steady-state.</p><p>The required number of input values is N = ceil(D1/Ts) where D1 is the value of the delay at t = 0, and Ts the sample time value.</p><p>The figure shows the details of the initial conditions.</p><p><img src="https://799605156-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdlNg8IbOdahCpFCyzxSN%2Fuploads%2Fgit-blob-c640be8e4b53baf3fa436a520ced3b12bc1ec672%2Fdiscrete_var_time_delay_curves.png?alt=media" alt="" data-size="original"></p><p>Suppose, for example, that the signal is a 60 Hz sine wave, the initial delay is set to D1 = 10<em>Ts by the D input of the block, and the sample time is equal to 50e-6 s.</em></p><p><em>The N previous input values of the signal are determined as follows:</em></p><p><em>N = ceil(10</em>Ts)/Ts; % N=10</p><p>t = [-N<em>Ts:Ts:-1</em>Ts]; % time vector of the N previous inputs</p><p>S_init = sin(2<em>pi</em>60*t); % The N previous input values of signal</p></td></tr><tr><td><strong>Sample time</strong></td><td>Specify the time interval between the samples. Default is 50e-6.</td></tr><tr><td><strong>Direct feedthrough</strong></td><td><p>When this check box is selected, the block can handle a delay less than the simulation time step.</p><p>Otherwise the block extrapolates the input values.</p><p>Default is selected.</p></td></tr></tbody></table>

## Inputs and Outputs

<table data-header-hidden><thead><tr><th width="250.22216796875"></th><th></th></tr></thead><tbody><tr><td><strong>In</strong></td><td><p>The signal.</p><p>The input can be a scalar signal or a vector of signals. The dimension of the In and D inputs must be the same.</p></td></tr><tr><td><strong>D</strong></td><td><p>The value of the delay to apply to the signal.</p><p>The input can be a scalar delay signal or a vector of delay signals. The dimensions of the In and D inputs must be the same.</p></td></tr><tr><td><strong>Out</strong></td><td>Returns the delayed signal.</td></tr></tbody></table>

## Characteristics

<table data-header-hidden><thead><tr><th width="250"></th><th></th></tr></thead><tbody><tr><td>Direct Feedthrough</td><td>Yes</td></tr><tr><td>Sample Time</td><td>Discrete</td></tr><tr><td>Scalar Expansion</td><td>Yes, of input D and of the <strong>Initial conditions</strong> parameter</td></tr><tr><td>Dimensionalized</td><td>Yes</td></tr><tr><td>Zero-Crossing Detection</td><td>No</td></tr></tbody></table>

## Example

The power\_DiscreteVariableTimeDelay example shows various uses of the Discrete Variable Time Delay block.


---

# 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/additional-components/discrete-variable-time-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.
