Skip to content
Programming, Controls & Sensors·Lesson 24 of 51

Quadrature Encoders and How They Work

The foundational incremental encoder type, how it senses direction and counts, and what CPR/PPR mean.

Sign in to track progress, earn XP, and save lessons.

A quadrature encoder is the workhorse incremental position sensor. It produces two square-wave pulse trains, called channels A and B, that are 90 degrees out of phase with each other — the 'quadrature' relationship.

Counting and direction

Because A and B are offset by a quarter cycle, the controller can tell direction by which channel leads. If A rises before B, the shaft turns one way; if B leads A, it turns the other. Counting the edges accumulates a position relative to wherever you started.

This is the key property and limitation: a quadrature encoder is incremental/relative. It tells you how far you have moved from power-on, not your absolute angle. If the robot boots with an arm halfway up, the encoder reads zero there until you zero it against a known reference (often a limit switch).

Resolution: CPR vs PPR

Resolution is described with two easily-confused acronyms — CPR (cycles or counts per revolution) and PPR (pulses per revolution). One full electrical cycle of a single channel contains only two edges (one rising, one falling). But across both channels A and B there are four edges per cycle (hence 'quad'). The roboRIO FPGA and WPILib's Encoder class default to 4x decoding (k4X), counting all four of those edges to yield four counts per cycle. Always read the datasheet to learn whether a spec means cycles, pulses, or edges. As a guideline, your effective resolution should be finer than the smallest position error you can tolerate.

Reading one in WPILib

Encoder enc = new Encoder(0, 1); // DIO 0 (A), DIO 1 (B)
enc.setDistancePerPulse(Math.PI * wheelDiameter / countsPerRev);
double meters = enc.getDistance();
double metersPerSec = enc.getRate();

setDistancePerPulse converts raw counts into real-world units (meters, degrees), which is essential before using the value in control code. Remember that with default 4x decoding the denominator is the counts per revolution (4 x cycles), not the raw cycle count.

Common quadrature encoders

WPILib lists several FRC-legal quadrature encoders, including the CUI/AMT103-V, the US Digital E4T, the Grayhill 63R, the CIMcoder, the legacy CTRE Mag Encoder, and the REV Through Bore Encoder (covered next, which also offers absolute output).

Key takeaways

  • Quadrature encoders use two 90-degree-out-of-phase channels to sense both distance and direction.
  • They are incremental/relative: they measure change from power-on, so they usually need zeroing.
  • Watch CPR/PPR carefully — one cycle = four edges, and WPILib defaults to 4x decoding — and always call setDistancePerPulse to get real units.

Lesson quiz

Required

Answer all 3 questions correctly to complete this lesson.

1.A quadrature encoder uses two output channels, A and B. What is the key relationship between them that lets the encoder determine direction of rotation?

2.A standard quadrature encoder is an incremental sensor. What does this mean for the position it reports when the robot is powered on?

3.Some quadrature encoders include a third 'index' (or Z) channel in addition to A and B. What does this index channel do?

Answer every question to submit.