> 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-i-o-library/encoder-in.md).

# Encoder In

## Description

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-7a863cc05ffbd390031a75e4bac02af2cc90119b%2Fc4ed5ad9-2b9b-4a5b-aae2-1eb6ca813f45.jpg?alt=media" alt="" width="365"><figcaption></figcaption></figure>

The **Encoder In** block, located in the **RT-LAB I/O/Opal-RT/Common** library, acquires and processes **quadrature encoder signals** to compute the **angular rate**, **position**, and **direction of rotation** of an encoder. The block processes the **A, B, and Z** signals acquired from Digital Input modules or a OP5969 module and extracts the corresponding motion information in real time. A single Encoder In block can process signals for **up to two encoders**. Availability of this functionality depends on the bitstream supplied with the system. Refer to the **System Description Document** provided with your order for connector pin assignments.

## Mask parameters

<figure><img src="https://96827845-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNRdpSk8kjn20gXAexnt6%2Fuploads%2Fgit-blob-84d2d569131e4e583eb1f051def0c784eca56122%2Fbd2256ac-219a-47f5-9d12-e757a22abb5b.png?alt=media" alt="" width="329"><figcaption></figcaption></figure>

<table><thead><tr><th width="211">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Controller Name</strong></td><td>Specifies the <strong>OpCtrl</strong> block this block is bound to. Enter the same <strong>Controller Name</strong> as defined in the corresponding <strong>OpCtrl</strong> block.</td></tr><tr><td><strong>DataOut port number</strong></td><td>Specifies the Digital Input or OP5969 module and subsection from which this block acquires signals. Subsection 1 corresponds to channels 0–7, subsection 2 corresponds to channels 8–15, and so on.<br>Configure the <strong>DataIn port number</strong> according to your <strong>System Description Document</strong> or <code>.conf</code> file.</td></tr><tr><td><strong>Slot infos</strong></td><td>Read‑only field displaying the expected physical location (Slot, Section, Subsection) of the Digital Input or OP5969 module derived from the selected <strong>DataIn port number</strong>. If the port number is invalid, <em>Slot 0 Module X Subsection 0</em> is displayed.</td></tr><tr><td><strong>Available channels</strong></td><td>Read‑only field displaying the maximum number of encoders available in the selected subsection.</td></tr><tr><td><strong>Number of Encoder Signals</strong></td><td>Specifies how many encoders in the subsection are monitored (maximum of <strong>two</strong> per subsection).</td></tr><tr><td><strong>Auxiliary Output type</strong></td><td>Specifies the data type produced at the block <strong>Data</strong> output.<br><strong>Raw:</strong> Reports the wheel position as encoder count values.<br><strong>Angle:</strong> Reports the wheel position converted to an angular quantity in the selected <strong>Angle Unit</strong>.</td></tr><tr><td><strong>Rate Unit</strong></td><td>Selects the speed unit used for the output: <strong>Hz</strong> or <strong>RPM</strong> (revolutions per minute).</td></tr><tr><td><strong>Angle Unit</strong></td><td><em>Editable only when <strong>Auxiliary Output type</strong> is set to <strong>Angle</strong>.</em><br>Selects the angle unit used for the output: <strong>degree</strong>, <strong>radian</strong>, or <strong>revolution</strong>.</td></tr><tr><td><strong>Sample Time (s)</strong></td><td><p>Specifies the block sample time, in seconds. A value of <code>0</code> sets a continuous sample time, inherited from the parent subsystem. A value of <code>−1</code> specifies an inherited sample time from the model.</p><p>The functionality block and its associated <strong>OpCtrl</strong> block must execute at the same <strong>sample time</strong>.</p></td></tr><tr><td><strong>Resolution</strong></td><td>Also known as <strong>PPR</strong> (pulses per revolution) or <strong>CPR</strong> (counts per revolution). Defines the number of A/B cycles per mechanical revolution. The maximum supported resolution is <strong>65 535 PPR</strong>. This parameter must be set correctly to ensure an accurate rate measurement.</td></tr><tr><td><strong>Clockwise Rotation</strong></td><td>Specifies whether clockwise rotation corresponds to signal <strong>A leading B</strong> or <strong>B leading A</strong>.</td></tr><tr><td><strong>Minimal rate</strong></td><td>Specifies the lowest detectable angular rate. Rates below this threshold are treated as zero. The minimum supported value is <strong>±0.1 RPM</strong> (approximately <strong>±0.0017 Hz</strong>), using the unit specified by <strong>Rate Unit</strong>.</td></tr></tbody></table>

## Inputs

This block has no inputs.

## Outputs

<table><thead><tr><th width="102">Output</th><th>Description</th></tr></thead><tbody><tr><td><strong>Rate</strong></td><td>Outputs the rate of the decoded quadrature input signals, using the unit specified by the <strong>Rate Unit</strong> parameter.</td></tr><tr><td><strong>Data</strong></td><td>Outputs either raw 16‑bit quadrature data or computed angle values derived from this data, as determined from the <strong>Auxiliary Output type</strong> parameter. The angle unit is determined by the <strong>Angle Unit</strong> parameter.</td></tr><tr><td><strong>Status</strong></td><td><p>Outputs the block status:</p><ul><li><code>0</code>: No error.</li><li><code>-1</code>: Block not associated with an <strong>OpCtrl</strong> block (check the <strong>Controller Name</strong> parameter), or FPGA initialization failure.</li><li><code>-2</code>: Data reception timeout, typically caused by model synchronization issues.</li><li><code>-3</code>: Data reception error: fewer data received than expected. Missing values are replaced with <code>0</code>.</li><li><code>-4</code>: Data reception error: more data received than expected. Extra values are discarded.</li></ul></td></tr><tr><td><strong>Direction</strong></td><td><p>Returns the direction of rotation:</p><ul><li><code>0</code>: no rotation (null rate).</li><li><code>+1</code>: Positive rotation rate.</li><li><code>-1</code>: Negative rotation rate.</li></ul></td></tr></tbody></table>

## Characteristics and limitations

<table><thead><tr><th width="247.75">Characteristic</th><th>Value</th></tr></thead><tbody><tr><td><strong>Connector pin assignments</strong></td><td>Refer to the <strong>System Description Document</strong> provided with your order, or refer to the pin assignment of the <a href="https://opal-rt-technologies.gitbook.io/opal-rt-technologies-docs/op53xx/"><strong>OP53xx series I/O module</strong></a> or <a href="https://www.opal-rt.com/docs/pcie-cards-and-connector-kits/connector-kits/op5969-1-rs-422-i-o-module.md"><strong>OP5969</strong></a> module associated with each subsection.</td></tr><tr><td><strong>Rate precision (RT-XSG &#x3C; 2.2.0)</strong></td><td>Limited by the model sampling rate. The RT-XSG bitstream returns one angle value per calculation step, and the block computes rate from the angle variation between consecutive steps. The RT-XSG version used to generate the bitstream is included in the bitstream name.</td></tr><tr><td><strong>Rate precision (RT-XSG ≥ 2.2.0)</strong></td><td>Speed is calculated as the number of events on signals A and B between two consecutive timestamps. Rate precision is 10 nanoseconds. The RT-XSG version used to generate the bitstream is included in the bitstream name.</td></tr><tr><td><strong>Direct feedthrough</strong></td><td>No</td></tr><tr><td><strong>Discrete sample time</strong></td><td>Yes</td></tr><tr><td><strong>XHP support</strong></td><td>Yes</td></tr><tr><td><strong>Work offline</strong></td><td>No</td></tr></tbody></table>


---

# 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-i-o-library/encoder-in.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.
