Comparison · Intermediate · 3 min read
Optical, Magnetic and Absolute Rotary Encoders
PPR, Output Types and Wiring
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
An incremental encoder gives pulses and counts movement from a start point. An absolute encoder reports the exact angle at power-up. Optical types are accurate and common in machines; magnetic types such as the AS5600 are compact and tolerate dust. Match the supply voltage, output type (NPN open collector, push-pull or SSI/I2C) and PPR to your controller before buying.
Key specs at a glance
- Types
- Incremental (A/B/Z), absolute (binary, SSI, I2C, SPI), magnetic and optical
- Resolution
- 20 to 10,000+ PPR; absolute parts 10 to 12+ bits
- Output
- NPN open collector, push-pull/line driver, SSI, I2C, PWM
- Supply
- 5 V, or 5 to 24 V on industrial housings
- Shaft
- Solid 6 to 8 mm, or hollow bore
- Protection
- Often IP50 to IP54; check the datasheet
Incremental, absolute, optical, magnetic
Pick the sensing method first, then the resolution.
| Type | Best for | Watch out for |
|---|---|---|
| Incremental optical (A/B/Z) | Motors, conveyors, lathes, handwheels | Loses position when power is lost; homing needed |
| Absolute optical (parallel or SSI) | Robot joints, positioning that must survive power-off | More wires or a serial protocol to read |
| Magnetic (AS5600, MT6816) | Hobby servos, gimbals, knobs, compact builds | Needs a magnet centred and at the right gap; stray fields hurt |
| Hand-wheel pulse generator | CNC and DIY jog wheels | Low PPR; not for precise control |
| Slot disc plus photo-interrupter | Cheap speed sensing | Counts speed well, direction needs two sensors |
- Incremental optical (A/B/Z)
- Best for:
- Motors, conveyors, lathes, handwheels
- Watch out for:
- Loses position when power is lost; homing needed
- Absolute optical (parallel or SSI)
- Best for:
- Robot joints, positioning that must survive power-off
- Watch out for:
- More wires or a serial protocol to read
- Magnetic (AS5600, MT6816)
- Best for:
- Hobby servos, gimbals, knobs, compact builds
- Watch out for:
- Needs a magnet centred and at the right gap; stray fields hurt
- Hand-wheel pulse generator
- Best for:
- CNC and DIY jog wheels
- Watch out for:
- Low PPR; not for precise control
- Slot disc plus photo-interrupter
- Best for:
- Cheap speed sensing
- Watch out for:
- Counts speed well, direction needs two sensors
PPR, CPR and what you really get
A 600 PPR encoder read in quadrature gives 2,400 counts per turn. For a motor driving a lead screw or belt, divide the counts by the travel per turn to get the step size; the encoder resolution calculator does this. Higher PPR means finer resolution but also a higher pulse rate, so check the controller can count fast enough. See rotary encoders for the basic knob-style parts.
Output types and wiring
- NPN open collector (for example the HS-S32 family): the output pulls to ground. Add a pull-up resistor to your logic voltage, or use the controller's internal pull-up if the current is low.
- Push-pull / line driver: drives high and low; connect it directly if the voltage levels match.
- 5 V parts on a 3.3 V board: use a level shifter or a divider; see logic-level shifting.
- Connect shield to ground at one end and keep the cable away from motor wires.
- A, B and Z (index) go to three input pins. Use hardware interrupts or a timer in encoder mode on STM32 and ESP32 rather than polling.
Magnetic encoders such as the AS5600
A magnetic encoder reads the angle of a diametric magnet fixed to the shaft. The AS5600 gives 12-bit angle over I2C, PWM or analog output, so it needs no counting at all. Keep the magnet centred within about a millimetre of the chip and at the gap in the datasheet. Check the reading for the whole turn before trusting it in a control loop. See Hall effect sensors for how the sensing works.
Using one with a microcontroller
- 1Read the datasheet for supply, output type and pin colours.
- 2Connect A and B to interrupt-capable pins, and Z to any input.
- 3Count edges with a library or hardware peripheral; the ESP32 has a pulse counter and STM32 timers have an encoder mode.
- 4Check direction by turning the shaft clockwise and watching the sign of the count.
- 5Reset the count on the index pulse for a repeatable zero.
- 6For a motor loop, see motor encoders.
Try it: Encoder resolution calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Feeding a 24 V encoder output into a 3.3 V pin.
- Forgetting the pull-up resistor on an NPN open-collector output.
- Reading A/B by polling and missing pulses at speed.
- Mounting a magnet off-centre on a magnetic encoder.
- Running encoder cables beside motor power wires without a shield.
Frequently asked questions
What is the difference between PPR and CPR?
PPR counts the cycles on one channel per turn. CPR is the count after decoding both channels and all edges, which is 4 times PPR.
Do I need an absolute encoder?
Only if the position must be known after power loss without homing, for example a robot joint.
Can I use a 5 V encoder with an ESP32?
Only with level shifting or a divider on the signal lines, since ESP32 inputs are 3.3 V.
What does the Z or index pulse do?
It gives one pulse per turn at a fixed angle, used to reset the count or find home.
Optical or magnetic?
Optical gives high resolution in clean machines; magnetic is more compact and tolerates dust but needs correct magnet placement.
Parts for this guide
Calculators
Terms in this guide
Projects that use it
Put this into practice: 9 step-by-step builds in our project library use parts from this guide.
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.





