Peripheral features and how this peripheral works
The Quadrature Decoder module interfaces to position/speed sensors that are used in industrial motor control applications. It uses 5 input signals (PHASEA, PHASEB, INDEX, TRIGGER, and HOME) from those position/speed sensors, the quadrature decoder module decodes shaft position, revolution count, and speed.
Features
- Support 32-bit position counter
- Capable of modulo counting
- Could be initialized to a predetermined value by one of 3 different methods:
- Software-triggered event
- INDEX signal transition
- HOME signal transition
- When the position counter registers are read, the snapshot of position counter, revolution count, and position difference counter could be saved to their respective hold registers.
- Support quadrature decode mode and signal phase count mode.
- With quadrature decode mode, the PHASEA and PHASEB represent a two-phase quadrature signal.
- With signal phase count mode, a positive transition of the PHASEA input generates a count signal. The PHASEB input controls the counter direction.
- Support revolution counter with or without INDEX signal
- When INDEX signal used, INDEX signal pulse increases/decreases the revolution counter.
- When INDEX signal not used, the configurable modulus counting roll-over/roll-under is used to increase/decrease revolution counter.
- Support flexible speed measurement. QDC uses the Position Difference Counter (POSD), Last Edge Time Counter (LASTEDGE), Position Difference Period Counter (POSDPER), and Position Difference Period Buffer (POSDPERBFR) to support both high rotation speed measurement and low rotation speed measurement.
- Support position match output pulse The position match output pulse could be used to trigger other modules. It can be configured to occur when:
- The position counter matches the application defined compare value.
- Or, the position counter registers (POS, REV or POSD) are read. Optionally, the position match event triggers interrupt.
- Configurable digital filter for input signals: PHASEA, PHASEB, INDEX, HOME.
- Support watchdog timer QDC uses a watchdog timer for non rotating shaft detection.
- The watchdog timeout value is configurable.
- The watchdog could be disabled.
- Watchdog timeout could trigger interrupt.
- Supports Interrupts.
- Input signal interrupts: HOME transition interrupt, INDEX pulse interrupt, PHASEA and PHASEB simultaneous change interrupt.
- Watchdog timeout interrupt
- Position compare event interrupt.
- Position counter interrupts: Roll over interrupt, roll under interrupt.
How this peripheral works
- Initialize the module clock, configure the input pins (PHASEA, PHASEB, INDEX, HOME) based on use case, configure the TRIGGER and POSMATCH signal if necessary.
- After configured, QDC's Revolution Counter, Position Counter, Position Difference Counter, Last Edge Time Counter, and Position Difference Period Counter start to work based on configurations. Input signal PHASEA, PHASEB, INDEX, HOME are filtered by digital glitch filter before feeding QDC counters. The QDC counters values are saved to each hold registers at the proper time, taking a snapshot of the counters' values allows a consistent view of a system's position and the velocity to be attained.
How this driver is designed to make this peripheral works
QDC driver's initialize function QDC_Init initializes the QDC based on configuration structure qdc_config_t. This function convers all the QDC configurations. Generally QDC is ready to work after calling this function. The function QDC_GetDefaultConfig helps to fill the qdc_config_t with default values.
Besides QDC_Init for the whole module configuration, there are smaller flexible functions used for runtime setting, including:
When QDC is working, QDC driver provides functions to get the counter registers value, revolution count value, position difference value, last edge time, position difference period.
How to use this driver
- Prepare the module clock, configure the input pins according to real use case, configure output pin if it is used.
- Prepare the configuration qdc_config_t, initialize the QDC using QDC_Init.
- When QDC started running, call the value get APIs to get the required register value to calculate position and speed.