# Rotary or motor encoder counts jump or drift: bounce, noise and missed pulses

> Fix an encoder that counts wrongly: both channels needed, interrupt pins, noise from motors, debounce and pulse rate limits.

Canonical: https://roboticsengineering.in/fix/rotary-encoder-wrong-counts-bounce/ | Published: 2026-11-03 | Updated: 2026-11-03

**Wrong counts usually come from noise on the signal or from reading too slowly.** Use both channels and interrupt-capable pins.

## What the message means

A quadrature encoder gives two pulse trains, A and B, a quarter cycle apart. The order of the changes tells the direction. Missed or false edges add up as drift.

## Fix it in this order

1. Connect both channels A and B, plus power and ground at the right voltage.
2. On an Uno use pins 2 and 3 for interrupts. On an ESP32 most pins can take interrupts.
3. Keep ISR code short: update a counter and return.
4. Mark the shared counter volatile, and copy it with interrupts off if it is more than 8 bits.
5. Add pull-ups if the encoder has open-collector outputs, and a small capacitor on noisy lines.
6. Run the encoder wires away from motor wires, and twist or shield them.
7. Check the pulse rate against what the board can handle at full motor speed.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Counts go up at a standstill | Noise on the signal. |
| Counts too low at speed | Missed pulses. Use interrupts or a hardware counter. |

## Related

[encoder counts calculator](https://roboticsengineering.in/encoder-counts-per-wheel-distance-calculator/), [wheel speed calculator](https://roboticsengineering.in/wheel-speed-rpm-calculator/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
