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 regardless of decoding type, WPILib always treats one "pulse" in setDistancePerPulse as a full cycle (four edges) — the denominator should be the encoder's raw cycles per revolution from its datasheet, not multiplied by 4.
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.
Keep going
Take the quiz · +10 XP with an accountMore in Encoders: Measuring Position and Velocity
Sources & corrections
This lesson is AI-assisted: drafted from primary sources, then reviewed and edited by hand. Errors still get through. When one is reported we fix it and write down what changed — publicly, in the corrections log.
Sources and further reading
Read next
Articles on this, for competition day
The lesson covers how it works. These cover what to do when it breaks.
Lesson quiz
RequiredAll 3 right completes the lesson. Miss one and only that question comes back — anything you already answered correctly stays banked.
0 of 3 answered
01.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?
02.A standard quadrature encoder is an incremental sensor. What does this mean for the position it reports when the robot is powered on?
03.WPILib's Encoder class and the roboRIO FPGA default to 4x decoding (k4X). What does this default decoding actually count for each electrical cycle?
Answer every question to submit.
All 51 lessons in Programming, Controls & Sensors
- Not started:Mini-Project: A Closed-Loop Elevator with Motion Magic
- Not started:Mini-Project: A Velocity-Controlled Shooter on REVLib
- Not started:Mini-Project: A Teleop Swerve Drive Subsystem
- Not started:Mini-Project: An Autonomous Routine with PathPlanner
- Not started:Mini-Project: Vision-Aligned Scoring with Limelight
- Not started:State-Space Control and Kalman Filtering
- Not started:Log Replay Architecture with AdvantageKit
- Not started:Advanced Pose Estimation: Multi-Tag Fusion and Standard Deviations
- Not started:Robot Coordination, Alerts, and Operator Feedback
- Not started:Case Study: Hardening Software Before an Event