National Instruments PCI-6251 Incremental Encoder

Incremental Encoder block for PCI-6251, PCIe-6251, PXI-6251, and PXIe-6251 boards (not recommended)


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

To open this library, type xpcobsoletelib in the Command Window.

Scaling Input to Output

I/O Module Input

Block Output Data Type


TTL level quadrature encoder signals



Block Parameters


From the list, choose 0 or 1 for the channel counter you want to use. For information on input for these counters, see the National Instruments® M Series user manual. The pin associations are:

CounterChannel 0Channel 1
APFI 8 (Pin 37)PFI 3 (Pin 42)
BPFI 10 (Pin 45)PFI 11 (Pin 46)
ZPFI 9 (Pin 3)PFI 4 (Pin 41)
Counting mode

From the list, select a counting mode:

Quadrature Mode x1Count on rising edges of the A signal
Quadrature Mode x2Count on both rising and falling edges of the A signal
Quadrature Mode x4 Count on both rising and falling edges of both A and B signals

The level of the opposite signal when an edge occurs determines the count direction. For example, a rising edge of A when B is high counts one way, while an edge of A when B is low counts the other. For more information, see the National Instruments M Series user manual.

Initial count

The initial count specifies the initial value for the counter. The block resets the count to this value under the following conditions:

  • When the model starts

  • When the following is true, which typically occurs once per revolution for a rotary encoder.

    • Reload at index pulse check box is selected

    • Index pulse (Z input) is true

    • The phases of A and B match the setting of Index phase

Reload at index pulse

Select this check box to reset the counter to the value of Initial count at each index pulse. The reset occurs when:

  • The encoder outputs a high level on its index output

  • The phases of A and B match the setting of Index phase

Index phase

If you have selected the Reload at index pulse check box, the Index phase parameter specifies the phase of the quadrature signals during which the count reloads with Initial count. Your choice of value primarily depends on the particular incremental encoder you use. From the list, select one:

  • A low B low

  • A low B high

  • A high B low

  • A high B high

To choose an Index phase for reset, use an oscilloscope, triggered on the index pulse, to observe the states of counters A and B. If your choice does not meet the encoder requirements, resets may be inconsistent.


You can apply a digital debouncing filter to the input pins before processing.

From the list, select a filter value to ignore pulses that are shorter than the filter time. The value of None indicates that the input is not filtered.

  • None

  • Minimum pulse width 125 nanoseconds

  • Minimum pulse width 6.25 microseconds

  • Minimum pulse width 1.25 milliseconds

Sample time

Enter the base sample time or a multiple of the base sample time (-1 means sample time is inherited).

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?