> 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-lab-library/optrigger.md).

# OpTrigger

## Description

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

The **OpTrigger** block, located in the **RT-LAB/Data logging** library, controls when data acquisition starts during simulation based on a trigger condition.

Data is acquired only when the specified condition on the trigger signal is met. Once started, acquisition continues until it reaches the size defined in the number of samples per signal field on the **OpWriteFile** block mask. After this, acquisition may be re-triggered if the condition remains true.

When used with an **OpWriteFile** block (same Acquisition group), if the block is triggered after the file is full (file size limit is reached), the .mat file is not overwritten; data collected during the initial trigger(s) is kept.

## Mask parameters

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

<table><thead><tr><th width="250.59991455078125">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Condition</strong></td><td><p>Condition required to trigger acquisition. One of:</p><ul><li>Rising or falling edge</li><li>Rising edge (threshold crossed on a positive slope, from below)</li><li>Falling edge (threshold crossed on a negative slope, from above)</li><li>Trigger signal >= trigger level</li><li>Trigger signal &#x3C;= trigger level</li></ul></td></tr><tr><td><strong>Offset</strong></td><td><p>If positive, number of steps (cycles) to wait before starting acquisition after the trigger condition is met. Default is 0 (start immediately).</p><p>The offset can also be a negative value n; in this case, the n samples corresponding to the n steps before the trigger condition are acquired (up to the number of samples per signal). The valid range is [-FrameSize ; +FrameSize]. The frame size is defined in the number of samples per signal field on the <strong>OpWriteFile</strong> block mask.</p></td></tr><tr><td><strong>Acquisition group</strong></td><td>Specifies the acquisition group controlled by this block.</td></tr></tbody></table>

## Inputs

<table><thead><tr><th width="251.39996337890625">Input</th><th>Description</th></tr></thead><tbody><tr><td><strong>Trigger signal</strong></td><td>The signal compared to the trigger level.</td></tr><tr><td><strong>Trigger level</strong></td><td>Usually a constant. Specifies the value the trigger signal must reach to start acquisition.</td></tr></tbody></table>

## Outputs

<table><thead><tr><th width="250.60003662109375">Output</th><th>Description</th></tr></thead><tbody><tr><td><strong>Trigger output</strong></td><td>Status of the acquisition: 0 indicates no acquisition in progress; 1 indicates data is being acquired.</td></tr></tbody></table>

## Characteristics and limitations

| Characteristic       | Value |
| -------------------- | ----- |
| Direct Feedthrough   | No    |
| Discrete sample time | No    |
| XHP support          | Yes   |
| Work offline         | No    |


---

# 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-lab-library/optrigger.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.
