5.1.87. Quadrature decode input (pdx_QuadratureDecode)

Output the number of edges sensed from the quadrature encoder since the last time the block iterated.

5.1.87.1. Supported targets

M110-000, M220-0AU, M250-000, M460-000, M461-000 and M670-000

5.1.87.2. Required license

None (Main library). (See Section 2.3, “Licensed Features”.)

5.1.87.3. Description

This block decodes the signals from a quadrature encoder. A quadrature encoder generates a pulse train from two sensors which pick up markings on the encoder disk.

Figure 5.9. Quadrature encoder and generated signals

Quadrature encoder and generated signals

The sensors and markings are arranged so that when the encoder is turning, the sensor signals generate two pulse trains 90° out of phase. If the disk is turning in a forwards direction, the primary channel edges will lead the secondary channel edges. If the disk is turning in a backwards direction then the primary channel edges will lag the secondary channel edges. If there are no signal edges on either channel after a period of time, then the encoder has stopped turning (or is turning slowly enough to be considered stationary).

Figure 5.10. Direction of encoder and generated signals

Direction of encoder and generated signals

The quadrature decode block measures the primary and secondary channels, determines the direction at each pulse and counts the pulses. If the encoder is turning forwards then for each edge on the primary and secondary channels, the block increments the count. If the encoder is turning backwards then for each edge on the primary and secondary channels, the block decrements the count. When the block iterates, it outputs the count of pulses and resets the count to zero.

For instance, if the encoder turns forwards for nine edges between iterations of the block, the block output will be nine. If the encoder turns forwards for six edges and then backwards for two edges between executions of the block, the block output will be four.

Figure 5.11. Pulse count example

Pulse count example

Note

Some encoders provide an index signal and some encoders provide complement signals of the primary and secondary signals, both for the purposes of improving reliability. This block does not decode these signals.

5.1.87.4. Inports

  • sim_input

    Only used in simulation. place the sum of edges here to simulate the number of edges sensed since the last iteration of this block. A value of zero indicates that the encoder position is at the same place as it was when the block was last iterated.

    Range: [-8388608, 8388607] edges (for M221, M250, M460, M461 and M670 targets)

5.1.87.5. Outports

  • edges_sensed

    The count of edges sensed since the last time the block was iterated. A value of zero indicates that the the encoder position is at the same place as it was when the block was last iterated.

    Range: [-8388608, 8388607] edges (for M221, M250, M460, M461 and M670 targets)

5.1.87.6. Mask parameters

  • Primary channel

    The input pin sourcing the primary signal to measure. The relationship between the primary and secondary channels is explained above.

  • Secondary channel

    The input pin sourcing the secondary signal to measure. The relationship between the primary and secondary channels is explained above.

  • Sample time

    The periodicity of the block iterations.

    Range: [0.001, 3600] seconds

5.1.87.7. Notes

  • If the edges_sensed outport is zero, it means the encoder position is in the same position as it was when the block was last iterated. This can occur if the encoder position has not moved, or if the encoder position has moved and returned to its original position. This should be kept in mind if the block will be used to derive the encoder's velocity.

  • The block iteration period must be sufficient to ensure that the sum of leading and lagging edges is no more than 32767 between iterations of the block. If the sum of edges is greater than 32767 then the edges_sensed outport will contain the sum of edges modulo 32768.