ClassA Motor

How do I connect a motor encoder? A/B/Z channels, differential vs open collector wiring

Wire an incremental encoder's A, B and Z channels correctly. Compare differential and open-collector outputs, and use the count and speed formulas with a worked example.

Updated 2026-11-28

The short answer

An incremental encoder gives two square-wave channels, A and B, offset by 90 degrees (quadrature), plus an index pulse Z once per revolution. The phase order of A and B gives direction, and counting edges gives position. Connect power (often 5 V, or 12 to 24 V), ground, A, B and Z. Differential outputs, with A+, A−, B+ and B−, are best for long cables and electrical noise. Open-collector outputs need pull-up resistors and are more easily corrupted at high speed.

Output types

  • Push-pull: the output swings between supply and ground. Simplest, suitable for short cables.
  • Differential (line driver, RS-422 style): each channel is a pair, and the receiver reads the difference. It rejects common-mode noise and suits long runs and high speeds.
  • Open collector (NPN or PNP): the output sinks or sources current only. It needs a pull-up to the controller's supply, usually 4.7 to 10 kΩ. It is cheaper but has less noise immunity and a lower usable frequency.

Wiring steps

  • Confirm the encoder supply voltage before wiring. Applying more than the rated voltage destroys the electronics.
  • Connect the encoder ground to the controller ground.
  • Differential: connect A+ to the controller's A+, A− to A−, and the same for B and Z. Terminate long lines at the receiver as the controller specifies, often with a resistor across the pair.
  • Open collector: connect each output to its input and add a pull-up from the output to the controller's supply.
  • Use shielded twisted pairs. Ground the shield at the drive end, and keep the cable away from motor power cables.
  • Do not connect only one leg of a differential output to a single-ended input. This is a common error and gives unreliable counts.

Worked example: counts and speed

A 1000 PPR (pulses per revolution) encoder read in x4 quadrature mode gives 1000 × 4 = 4000 counts per revolution, so the angle resolution is 360 / 4000 = 0.09 degrees per count. At 1500 rpm, one channel produces 1000 × 1500 / 60 = 25,000 pulses per second, and the counter sees 4 × 25,000 = 100,000 counts per second. The counter and the input must handle this rate. Speed is n = (counts per second) × 60 / (counts per revolution).

Channel checks

  • Turn the motor slowly by hand and watch A and B. Their edges should be 90 degrees apart, and the lead of A over B reverses with the direction.
  • If the direction reads backward, swap A and B in the wiring or in the controller's settings.
  • Z should give one pulse per revolution. Use it to home the axis.
  • If the count is off by a factor of four, check the decoding mode (x1, x2 or x4).

Common mistakes

  • Using open-collector outputs on a long cable with no pull-up, or with a pull-up that is too weak for the speed.
  • Counting only channel A. Without B you cannot know the direction.
  • Connecting a 5 V encoder to a 3.3 V input without a level shifter.
  • Confusing the encoder's PPR with the counts per revolution. The decoding mode multiplies it.
  • Forgetting the gearbox ratio. An encoder on the motor shaft reports motor revolutions, not output shaft revolutions.

How to choose PPR and wiring

  • Choose PPR for resolution, then check the maximum frequency: f_max = PPR × rpm_max / 60. Example: 2000 PPR at 3000 rpm gives 2000 × 3000 / 60 = 100 kHz per channel, so the input must be rated above 100 kHz.
  • Differential for cables longer than a few metres, or any run beside a VFD. Open collector for short, low-speed runs.

Sourcing a motor or production equipment from China? We can find and contact the right factories for you in Chinese. Ask on WhatsApp →