TPU3 Fast Quadrature Decode - Configure pair of TPU3 channels for Fast Quadrature Decode (FQD)

Library

Target Support Package FM5/ MPC555 Driver Library/ Time Processor Unit (TPU3)

Description

The TPU3 Fast Quadrature Decode block decodes position information from quadrature encoder hardware. The relative phase of a pair of input signals is used to determine direction of movement. The signals are decoded to increment or decrement the position counter (block output). You can derive a speed from the position information. It is particularly useful for decoding position and direction information from a slotted encoder in motion control systems.

In normal mode (the default), the position counter is incremented or decremented for each valid transition on either channel. The counter increments when the primary channel is ahead and decrements when the primary channel lags. A switch in the phase relationship indicates a change of direction.

At certain speeds you may want to switch to fast mode. You can supply an input to tell the block to switch to fast mode under specified conditions. In fast mode only one of the two input signals is read. The position counter increments or decrements by 4 for each rising transition on the primary channel only (instead of once for each transition in each signal). This reduces the TPU processing load; you can also decode at more than four times the maximum count rate of normal mode.

The counter is 16 bit and free flowing (that is, it overflows to 0, and underflows to 0xFFFF). You must take care when calculating speed derived from the counter, as it may be necessary to use two's complement arithmetic. A useful document is the TPU Fast Quadrature Decode Programming Note — search for "TPUPN02/D."

It is possible to overload the TPU processor; if you observe unexpected behavior you should consult the TPU documentation. Refer to Section 17, "Time Processor Unit 3," in the MPC555 User's Manual for further information.

Dialog Box

TPU module

Select TPU module A, B or C; each has 16 channels. Note that the MPC555 only has modules A and B. MPC565 and MPC566 also have module C. An error will be thrown if you select C and your target processor does not support this.

TPU channel numbers (primary and secondary)

Select a pair of consecutive channels from (0 and 1) to (14 and 15). The primary channel is always the lower channel number.

Channel priority:

Choose Low, Medium, or High

The order in which channels are serviced is determined by assigned priority first, followed by channel number (lowest number first).

Show Fast Mode port

This option is unselected by default. Left unselected, the block always operates in Normal mode. If you select this option, an inport appears where you can input a Boolean signal to control the mode of operation (for example, from a Stateflow subsystem): 0 or false = Normal Mode; 1 or true = Fast Mode.

Fast mode conserves TPU activity by only reading one of the two signals. This also allows you to decode at more than four times the maximum count rate of Normal mode. This may be appropriate at some speeds where you can assume the behavior of the second sign — instantaneous direction change is assumed to be impossible. The counter is updated in the same direction as when the last transition was serviced in Normal Mode. The position counter is incremented or decremented by 4 for every rising transition read on the primary channel, instead of having to read all four transitions in the two signals.

Initial value for POSITION_COUNT

Set an initial value. Range checking is applied (must be 16 bit).

POSITION_COUNT parameter alias (optional)

Provide a name that blocks such as the TPU3 New Input Capture/Input Transition Counter can use to refer to the POSITION_COUNT Fast Quadrature Decode parameter (see TPU3 New Input Capture/Input Transition Counter). Using a name is clearer than using absolute channel and parameter indices to refer to the position count from another TPU block.

Sample time

The default is always 0.1 for input driver blocks, but you will need to change this to suit the frequency of your input signals.

This block uses TCR1 as a timebase, but the functionality of the TPU Fast Quadrature Decode (FQD) function used by the block is not changed by changing the speed of the TCR1 clock. The Position Count output is incremented at a rate entirely controlled by the rising and falling edges of the pair of input waveforms (and the Fast mode input). See Time Processor Unit (TPU3) Configuration Parameters for more information on the TCR1 timebase settings.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS