Measurement Computing PCI-QUAD04 Incremental Encoder

PCI-QUAD04 Incremental Encoder block (not recommended)


Simulink® Real-Time™ Library of Drivers No Longer Recommended for Use


This driver block has three block outputs: Angle, Turns, and Init.

You can use Init to determine when the block output values are valid. Init is first set to 0. When the encoder reached the first index, Init is set to 1. From then on, you can determine the exact position, direction, and velocity. Init remains 1 unless Counting reset by index is set to Only First, and the counter detects a rollover.

Turns is the number of complete revolutions made by the encoder. Angle is the amount the encoder turns since the last full revolution.

The distance is given by:

distance = 2 * pi * Turns + Angle

The velocity is given by:

velocity = (distance(ts) - distance(ts-1)) / ts

The direction is given by:

direction = distance(ts) - distance(ts-1) 

A negative value is reverse, while a positive value is forward.

Block Parameters

Function module

From the list choose 1, 2, 3, or 4. This parameter specifies which channel you use for this block. For the same board (same base address) two blocks cannot have the same channel number.

Counting reset by index

From the list choose Only First, Continuous, or Index input disabled.

If you choose Only First, the first time the encoder reaches the index, the counter is reset to zero, the Init output signal is set to 1, and the encoder begins to count. The encoder ignores the second and later times it reaches the index. Init remains 1 until a rollover is detected, and then set to -1. A rollover is when the counter reaches its maximum value and begins to start counting at zero again. A rollover can also occur when the counter reaches its minimum value and the counter resets itself to the maximum value and resumes counting down. The outputs are still valid after rollover. The -1 flag is used to alert that a rollover has occurred.

If you choose Continuous, The first time the encoder reaches the index, the counter is reset to zero, the Init output signal is set to 1, and the encoder begins to count. Each time the encoder reaches the index, it resets to zero. Init remains at l because a rollover cannot occur.

Positive Rotation

From the list, choose either Clockwise or Counter Clockwise. This parameter sets the direction for positive rotation. If you choose Clockwise, when the encoder is turned clockwise it counts up, and when turned counter clockwise it counts down. If you choose Counter Clockwise the counting direction is reversed.


From the list, choose Single, Double, or Quadruple. This parameter specifies the phase detection mode. That is, how many phase changes are detected. For more information, see the board manual.


This field specifies the divisions of the connected incremental encoder for one revolution.

Filter prescale factor

Enter a base prescale factor for digital filtering. This filter helps eliminate high frequency noise. Enter a value from 0 to ff in hexadecimal (0 to 256 in decimal). For example, for a prescale factor value of ff in hexadecimal, enter

Sample time

Enter a base sample time or a multiple of the base sample time. The sample time indicates the update rate of registration on the input (Duty Cycle). Enter -1 to inherit the model sample time from another block. The sample time is in seconds.

PCI slot (-1:autosearch)

If only one board of this type is in the target computer, enter -1 to locate the board.

If two or more boards of this type are in the target computer, enter the bus number and the PCI slot number of the board associated with this driver block. Use the format [BusNumber,SlotNumber].

To determine the bus number and the PCI slot number, type:

tg = slrt;
getPCIInfo(tg, 'installed')

Was this topic helpful?