MPL PATI Incremental Encoder

MPL PATI Incremental Encoder block


Simulink® Real-Time™ Library for MPL

General Description

This block has one input port and one output port.

  • Input port

    Selects the counting mode. The block M input port determines the counting mode. The incremental encoder function has two counting modes, normal and fast. In fast mode, the count direction is not controlled by the polarity of the two signals but continues the same direction that was determined when the counter was last in normal mode. The maximum counting rate is much higher in fast mode than in normal mode.

    • Normal mode

      If the block input M is less than 0.5, the counter works in normal mode and counts on each edge. The edge sense and polarity of each signal determines the count direction of each signal. Each rising and falling edge of both inputs is counted. You must set the counting mode to normal when the model is first started. You can change it to fast mode afterward.

    • Fast mode

      If the block input M is greater than or equal to 0.5, the counter works in fast mode. The counter increments by 4 each time the primary channel has a rising edge.

  • Output port

    Returns the current position count as a double.

To keep the counting mode set to normal mode, just connect a constant block with the value 0 to the M input.

    Note:   To execute a model using this block, you must first write MPL boot code on the EEPROM using the MPL PATI EEPROM Write block.

    To flash the EEPROM with the boot code, add the EEPROM Write block to an empty model, then build and execute that model before executing the actual model. See MPL PATI EEPROM Write block for further information.

Block Parameters

Channel pair

From the list, choose a pair of sequential channels for the incremental encoder. Both channels must be in the same group of 16. For example, 1+2, 2+3, or 18+19. If you want to use channels 16 or 32, their sequential partners are 1 and 17, for example, 16+1 and 32+17.

Channel priority

From the list, select Low, Medium, or High priority. This changes the order that individual timers are serviced. See the MPC555 TPU documentation for more information.

Initial count

The initial count specifies the initial value for the encoder count register when the model starts executing.

Output range

From the list, choose one of the following. This block converts the output to doubles.

  • signed [-32768 +32767]

    Interprets the 16-bit count as a signed quantity. This places the discontinuity far from the 0 origin. Counting up from 32767 goes to -32768 on the next count.

  • unsigned [0 65535]

    Interprets the 16-bit count as an unsigned quantity. This places the discontinuity at the origin, where counting up from 65535 goes to 0 on the next count.

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')

External Websites

Was this topic helpful?