> 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/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/machine-section/im-sm-section/encoder-im-sm.md).

# Encoder (IM SM)

## Overview

In the **System Explorer** window configuration tree, expand the **Power Electronics Add-On** custom device and select **Circuit Model >> IM SM >> Encoder** to display this page. Use this page to configure the Encoder sensor model.

### Hall Effect Sensor Description <a href="#hall-effect-sensor-description" id="hall-effect-sensor-description"></a>

A Hall effect sensor is a device that is used to measure the magnitude of a magnetic field. Manufacturers of electrical machines will place magnetic materials on the machine at particular rotor angles to allow Hall Effect sensors to be able to detect when they are near the specific position on the machine. Through simple signal processing the voltage induced by the magnetic materials can be transformed into digital signals that turn active (true) when the Hall Effect sensor reaches the angle of the machine. The digital signals can then be used by a controller to calculate absolute position and/or speed. This Hall Effect Sensor model supports three independent sensor positions.

{% hint style="danger" %}
The Hall Effect mode is not currently supported as part of the IM SM model. As a result, **Encoder Mode** is set to Quadrature Encoder and disabled.
{% endhint %}

### Quadrature Encoder Description

A quadrature encoder is an angular position or motion sensor sometimes referred to as a rotary encoder. The quadrature encoder model generates three square-wave pulses (A, B, Z), which can then be interpreted into the angular position of the machine θm. For an encoder with Active High polarity, a pulse is defined as a transition from low to high back to low.

<figure><img src="https://2999842053-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe9Kk9pJCHht2LLBSxPap%2Fuploads%2FJd08a6uf1otvDomOTVcZ%2F13c453a2-38a5-49cc-9f38-04711c29a9f2.png?alt=media&amp;token=694127bf-21e0-472f-ad0f-7f87b0b3fad8" alt=""><figcaption><p>Figure 1. Quadrature encoder signals A, B, and Z, with A leading B at a standard 90 degree offset. The polarity of these signals is Active High.</p></figcaption></figure>

## Parameters

This page includes the following components:

### Encoder

<table><thead><tr><th width="209.5555419921875">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Specifies the name of the encoder.</td></tr><tr><td><strong>Description</strong></td><td>Specifies a description for the encoder.</td></tr></tbody></table>

### Configuration

<table><thead><tr><th width="210.26666259765625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Encoder Mode</strong></td><td><p>Choose from one of the following modes. The configuration parameters and section channels automatically populate depending on the selected <strong>Encoder Mode</strong>.</p><ul><li>Quadrature Encoder</li><li>Hall Effect</li></ul></td></tr></tbody></table>

When set to **Quadrature Encoder** mode, the sensor generates the A, B, and Z signals of a quadrature encoder module with a specific number of pulses per turn, according to an input angle or speed. Outputs A and B have a 90 degree phase difference that enables a decoder to retrieve the modulated signal angle and speed at any time.

<table><thead><tr><th width="210.26666259765625">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Number of Pole Pairs</strong></td><td>A gain applied to the mechanical angle of the machine, θm, before it is translated to an encoder signal. Modify this parameter if the encoder is attached to a gear box rather than connected directly to the rotor. In most applications, this is set to 1, pp (Default Value: 1)</td></tr><tr><td><strong>Angle Offset</strong></td><td>Angle offset applied to the machine angle, θm, θOffset (deg) (Default Value: 0)</td></tr><tr><td><strong>Number of Pulses/Revolution</strong></td><td>Number of pulses generated by the outputs A and B in a single revolution, ppr (Default Value: 1000)</td></tr><tr><td><strong>Rotation Type</strong></td><td>Select one of the following options: - <strong>A leads B</strong> — A is the first output pulse as the machine begins to rotate. - <strong>B leads A</strong> — B is the first output pulse as the machine begins to rotate. If the machine appears to be turning backwards, consider switching this setting, (Default Value: A leads B)</td></tr><tr><td><strong>Polarity</strong></td><td>Select one of the following options: - <strong>Active High</strong> — Output signals are pulled High to signify an encoder pulse. - <strong>Active Low</strong> — Output signals are pulled Low to signify an encoder pulse, (Default Value: Active High)</td></tr></tbody></table>

When set to **Hall Effect** mode, the sensor generates the A, B, and C signals which correspond to the absolute angle position. Typically A, B, and C are separated by 120° but other configurations are common.

The following parameters are available. They are modifiable at edit-time only:

<table><thead><tr><th width="209.82220458984375">Parameter</th><th>Description</th></tr></thead><tbody><tr><td><strong>Number of Pole Pairs</strong></td><td><p>A gain applied to the mechanical angle of the machine, θm, before it is translated to a Hall Effect signal. Modify this parameter if the sensor is attached to a gear box rather than connected directly to the rotor. In most applications, this is set to 1, pp</p><p>Default Value: 1</p></td></tr><tr><td><strong>Speed Sign</strong></td><td><p>Select one of the following options: - <strong>Clockwise</strong> — The sensor outputs a positive speed when the machine rotates clockwise. - <strong>Counter Clockwise</strong> — The sensor outputs a positive speed when the machine rotates counter clockwise,</p><p>Default Value: Clockwise</p></td></tr><tr><td><strong>Position A</strong></td><td><p>Sensor angle at which <strong>Channel A</strong> outputs a high signal pulse, θA (deg)</p><p>Default Value: 0</p></td></tr><tr><td><strong>Position B</strong></td><td><p>Sensor angle at which <strong>Channel B</strong> outputs a high signal pulse, θB (deg)</p><p>Default Value: 120</p></td></tr><tr><td><strong>Position C</strong></td><td><p>Sensor angle at which <strong>Channel C</strong> outputs a high signal pulse, θC (deg)</p><p>Default Value: -120</p></td></tr></tbody></table>

## Section Channels

When set to **Quadrature Encoder** mode, this section includes the following custom device channels:

<table><thead><tr><th width="210.3555908203125">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td>A <strong>(Output)</strong></td><td><p>Digital signal A generated by the encoder. When paired with <strong>B</strong> and <strong>Z</strong>, it can be used to determine the machine's position, A</p><p>Default Value: 0</p></td></tr><tr><td>B <strong>(Output)</strong></td><td><p>Digital signal B generated by the encoder. When paired with <strong>A</strong> and <strong>Z</strong>, it can be used to determine the machine's position, B</p><p>Default Value: 0</p></td></tr><tr><td>Z <strong>(Output)</strong></td><td><p>Digital signal Z generated by the encoder. One Z pulse occurs per full rotation at the 0° machine angle, Z</p><p>Default Value: 0</p></td></tr></tbody></table>

When set to **Hall Effect** mode, this section includes the following custom device channels:

<table><thead><tr><th width="209.64434814453125">Channel Name</th><th>Description</th></tr></thead><tbody><tr><td><strong>A (Output)</strong></td><td>Digital signal A generated by the Hall Effect sensor. When paired with <strong>B</strong> and <strong>C</strong>, it can be used to determine the machine's position, A Default Value: 0</td></tr><tr><td><strong>B (Output)</strong></td><td>Digital signal B generated by the Hall Effect sensor. When paired with <strong>A</strong> and <strong>C</strong>, it can be used to determine the machine's position, B Default Value: 0</td></tr><tr><td><strong>C (Output)</strong></td><td>Digital signal C generated by the Hall Effect sensor. When paired with <strong>A</strong> and <strong>B</strong>, it can be used to determine the machine's position, C Default Value: 0</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/pe-add-on-simulink/model-and-simulation/add-and-configure-a-circuit-model-to-the-system-definition/machine-section/im-sm-section/encoder-im-sm.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.
