> 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-latch-delay.md).

# RTE Latch Delay

## Description

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

The **RTE Latch Delay** block, located in the **RT-EVENTS/Discrete** library, stores the value of the input signal each time a trigger event occurs and outputs the value stored at the event that precedes the last event. The output is held until the next trigger event. The block compensates for events that occur between samples.

**Capabilities:**

* Define initial conditions in the block dialog or provide them as inputs.
* Latch on rising, falling, or either edge of the trigger.

{% hint style="info" %}
Set Initial condition source to external, two additional inputs appear.
{% endhint %}

The block stores its input only when a specific edge is detected on the trigger signal.

* Choose **Rising** to store the input on rising edges.
* Choose **Falling** to store the input on falling edges.
* Choose **Either** to store the input on both rising and falling edges.

## Mask parameters

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

| Parameter                    | Description                                                                           |
| ---------------------------- | ------------------------------------------------------------------------------------- |
| **Trigger Type**             | Select whether the latch occurs on rising, falling, or either edge.                   |
| **Initial condition source** | Specify the source of the initial condition as internal or external.                  |
| **Initial Condition 1**      | Value output before the first edge is detected.                                       |
| **Initial Condition 2**      | Value output after the first edge is detected and before the second edge is detected. |
| **Sample Time**              | Time interval between samples.                                                        |

## Inputs

| Input                            | Description                                                                                                                                     |
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **Input (Double)**               | Signal to be latched.                                                                                                                           |
| **Trigger (RTE Boolean)**        | RTE Boolean trigger used to store the input value.                                                                                              |
| **Initial Condition 1 (Double)** | Value output before the first edge is detected. Visible when Initial condition source is set to external.                                       |
| **Initial Condition 2 (Double)** | Value output after the first edge is detected and before the second edge is detected. Visible when Initial condition source is set to external. |

## Outputs

| Output              | Description     |
| ------------------- | --------------- |
| **Output (Double)** | Latched signal. |

## Characteristics and limitations

| Characteristic     | Value          |
| ------------------ | -------------- |
| Direct Feedthrough | Yes            |
| 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-latch-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.
