1.32.18 Quadrature Decoder (PDEC)

The quadrature decoder (QDEC) mode is used to measure the position and speed of the motor. This provides below features:

  • Angular and revolution counts

  • Synchronous and asynchronous velocity measurements

  • Direction change detection

  • Interrupts/output events on:

    • Counter overflow/underflow

    • Velocity

    • Direction change

Using The Library

Quadrature encoder signals Phase A, Phase B and an optional index signal are connected to the PDEC peripheral. The PDEC peripheral processes these signals with an internal counter to get the angular position and revolution count.

For velocity measurement, velocity event output is connected to the TC module using the Event System.

Library Interface

Quadrature Decoder peripheral library provides the following interfaces:

Functions

Name Description
PDECx_QDECInitialize Initializes given instance of PDEC peripheral in quadrature mode
PDECx_QDECStart Starts the given PDEC counter in quadrature mode
PDECx_QDECStop Stops the given PDEC counter in quadrature mode
PDECx_QDECPositionGet Reads the angular position from the quadrature encoder
PDECx_QDECRevolutionsGet Reads the number of revolutions
PDECx_QDECAngleGet Reads the angle
PDECx_QDECCallbackRegister Registers the function to be called from interrupt
PDECx_QDECStatusGet Identifies status of the quadrature interrupts
PDECx_HALLInitialize Initializes given instance of PDEC peripheral in hall mode
PDECx_HALLStart Starts the given PDEC counter in hall mode
PDECx_HALLStop Stops the given PDEC counter in hall mode
PDECx_HALLPatternGet Reads the hall pattern
PDECx_HALLPatternSet Writes the hall pattern
PDECx_HALLTimeWindowSet Writes the low and high window threshold for hall mode
PDECx_HALLCallbackRegister Registers the function to be called from interrupt
PDECx_HALLStatusGet Identifies status of the hall interrupts
PDECx_COUNTERInitialize Initializes given instance of PDEC peripheral in counter mode
PDECx_COUNTERStart Starts the given PDEC counter in counter mode
PDECx_COUNTERStop Stops the given PDEC counter in counter mode
PDECx_COUNTERCompare0Set Configures Compare 0 register value
PDECx_COUNTERCompare1Set Configures Compare 0 register value
PDECx_COUNTERCompare0Get Reads Compare 0 register value
PDECx_COUNTERCompare1Get Reads Compare 1 register value
PDECx_COUNTERCallbackRegister Registers the function to be called from interrupt
PDECx_COUNTERStatusGet Identifies status of the counter mode interrupts

Data types and constants

Name Type Description
PDEC_QDEC_STATUS Enum Identifies Quadrature mode interrupt source mask
PDEC_HALL_STATUS Enum Identifies Hall mode interrupt source mask
PDEC_COUNTER_STATUS Enum Identifies counter mode interrupt source mask
PDEC_QDEC_CALLBACK Typedef Defines the function pointer data type and function signature for the pdec QDEC callback function
PDEC_HALL_CALLBACK Typedef Defines the function pointer data type and function signature for the pdec hall callback function
PDEC_COUNTER_CALLBACK Typedef Defines the function pointer data type and function signature for the pdec counter callback function
PDEC_QDEC_CALLBACK_OBJ Struct Callback structure
PDEC_HALL_CALLBACK_OBJ Struct Callback structure
PDEC_COUNTER_CALLBACK_OBJ Struct Callback structure