Introduction

Author: Kristian Saxrud Bekken, Microchip Technology Inc.

Incremental quadrature encoders are used in a great number of applications across many disciplines as they provide a low-cost way of measuring motion in systems with moving parts. Some typical examples include measuring the position of a physical control wheel or measuring the rotor angle and velocity in an electrical motor.

Some AVR® microcontrollers, like the AVR XMEGA® E5, include dedicated quadrature decoding functionality, but the decoding can also be accomplished by utilizing some of the core independent peripherals available on smaller, less feature rich controllers. This application note describes how to decode and keep track of quadrature encoded signals from an incremental position sensor using an AVR by combining Core Independent Peripherals (CIPs) such as Configurable Custom Logic (CCL), Event System (EVSYS), 16-bit Timer/Counter Type A (TCA), and 16-bit Timer/Counter Type B (TCB).

The described setup uses eight I/O pins. If implemented on an ATtiny1617 using the code provided with this application note, the device can decode quadrature pulses with a frequency of up to 2.5 MHz.