42.3. PLB QEI Encoder Example

42.3.1. Overview

This example demonstrates how to use the PLB peripheral to implement a Quadrature Encoder Interface (QEI). PLB can be configured as AB phase or ABZ phase encoder interface to measure motor position and revolution count.

Key features:
  • Supports both AB phase and ABZ phase encoder modes

  • Configurable pulses per revolution

  • Digital filtering for input signals

  • Position count and revolution count monitoring

  • Z phase triggered revolution counting

42.3.2. Board Setting

  • Connect the motor board and motor to the development board

  • Connect encoder signals based on encoder type:
    • AB mode: Connect encoder A and B signals to corresponding board pins

    • ABZ mode: Connect encoder A, B and Z signals to corresponding board pins

42.3.3. Running the example

When the project runs correctly, the serial port terminal will output encoder position and revolution information every 100ms:

hase:3133. z:1
phase:597. z:2
phase:1792. z:2
phase:2596. z:2
phase:2593. z:2
/* ... */

42.3.4. Notes

  • When phase counting is enabled, pulses per revolution must be greater than 4

  • Z phase function is only valid in ABZ mode