Q4 Incremental Encoder block (not recommended)

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

To open this library, type `xpcobsoletelib`

in the Command
Window.

**Channel vector**Enter a vector of numbers between 1 and 4. This driver allows you to enter channel numbers in arbitrary order. For example, to use the first two odd encoder input channels, enter

[1,3]

Number the channels beginning with 1 even if this board manufacturer starts numbering the channels with 0.

### Note

If you specify four channels or fewer, it is more efficient to use channels that are all odd or all even.

**Initial count vector**The initial value vector contains valid count values to be loaded into the preload register (PR) for the corresponding channel. After a counter decrements to zero, it reloads from the value in the preload register. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that value is replicated as initial count value over the channel vector.

**Prescale vector**The prescale vector is a base prescale factor for digital filtering. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. This filter clock frequency helps eliminate high frequency noise. Enter a value from 0 to 255. An entry of 0 corresponds to the highest possible available frequency of 16.7 MHz.

**Quadrature vector**Enter the quadrature vector. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. The allowable entries are

`0`

— Non-quadrature or normal. The driver treats the A input as count and the B input as direction.`1`

— 1X quadrature. Counts up or down once per complete cycle of the quadrature signal`2`

— 2X quadrature. Counts up or down twice per complete cycle of the quadrature signal`4`

— 4X quadrature. Counts up or down four times per complete cycle of the quadrature signal

**Mode vector**Enter the counting mode. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. The allowable entries are

`0`

— Normal. The counter wraps from 0 to 0xFFFFFF when decremented and from 0xFFFFFF to 0 when incremented.`1`

— Range Limit. The counter freezes upon reaching 0 from above and upon reaching the preload register (PR) value from below. In both cases, once counting has stopped, the counter resumes only when the count direction reverses.`2`

— Non-recycle. Counting stops upon overflow or underflow and does not resume.`3`

— Modulo-N. This mode is similar to normal mode except that the maximum count is specified by the preload register (PR).

**Synchronous index vector**Enter the synchronous index vector. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. The allowable entries are

`0`

— Disables index mode. This mode treats the index/load (I/LD) input as a level-sensitive asynchronous input.`1`

— Enables index mode. This mode treats the index/load (I/LD) input as a level-sensitive synchronous input with the quadrature clocks.

**Index polarity vector**Enter the index polarity mode vector. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. The allowable entries are

`0`

— Active Low, for a negative slope`1`

— Active High, for a positive slope

**Preserve counts vector**Enter the preserve counts vector. Enter a scalar or a vector that is the same length as the channel vector. If you specify a scalar value, that setting is replicated over the channel vector. The allowable entries are

`0`

— Do not preserve the current count for the corresponding channel. The driver loads its counter from its preload register (PR) when the model is restarted.`1`

— Preserve the current count for the corresponding channel when the model is restarted. (Note that the count will be meaningless after power is recycled.)

**Sample time**Enter the base sample time or a multiple of the base sample time (

`-1`

means sample time is inherited).**PCI slot**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?