Blog · · 6 min read

Does your machine need an encoder? Incremental vs. absolute, and where to mount it

Open-loop stepper, incremental or absolute encoder? When a machine axis needs position feedback, why counts are not accuracy, and why the mounting point matters more than the resolution.

A motor turns, the carriage moves, and the controller believes it knows where the axis is. But when a stepper skips steps under load, or a belt jumps a tooth on its pulley, the controller keeps believing, and the next move starts from the wrong place. An encoder replaces that belief with a measurement.

Here is when a prototype machine needs one, which type to choose, and why the mounting point matters more than the resolution.

Do you need an encoder at all?

Plenty of machines run well without one. A stepper motor in open loop moves a fixed angle per step, and the controller simply counts the steps it sent. That works as long as the motor always has more torque than the load needs. Homing at power-up gives it a known zero, and from there the step count is the position.

If the motor stalls for a moment, because the acceleration was too high or the tool hit something, the steps are lost and nothing reports it. The machine carries on, a few millimetres off.

Plan an encoder when:

  • A wrong position is expensive. A crash, a scrapped part or a safety risk.
  • The load changes. Cutting forces, a payload that is sometimes there and sometimes not, or a vertical axis.
  • The motor needs it anyway. A DC motor or a brushless servo cannot hold a position without feedback.
  • The machine must know where it is at power-up without first moving to a switch.

A middle way is the closed-loop stepper: a stepper with an encoder on the back. The drive notices when the shaft lags and corrects or stops with an error instead of carrying on.

Incremental encoders: counting edges

An incremental encoder produces two square waves, A and B, shifted by a quarter period. Which one leads tells the direction. If the controller counts every rising and falling edge of both, it gets four counts per line: a disc with 500 lines gives 2000 counts per revolution. This is called quadrature, and it is the type you will meet most often.

Datasheets mix up PPR, CPR and LPR, so check whether a number is before or after the factor of four.

Many incremental encoders have a third channel, the index, which gives one pulse per revolution. Combined with a home switch, it makes homing repeatable to a single count. And if the count at the index pulse changes from one turn to the next, the controller has missed edges.

The limit: an incremental encoder only knows how far the shaft moved since power-up. After a power cut, the machine has to home again.

Absolute encoders: a code for every position

An absolute encoder reports a unique value for every angle. A 12-bit single-turn encoder divides one revolution into 4096 positions and knows the angle the moment it gets power, even if someone turned the shaft by hand while it was off.

A lead screw turns many times, so it needs a multi-turn encoder that also counts revolutions, in one of three ways:

  • A battery keeps the turn counter alive while the machine is off. Simple, but the battery has to be replaced every few years.
  • A gear train inside the encoder drives slower code discs. No battery, but the encoder gets larger, and gears wear.
  • Energy harvesting: a special wire produces a short, strong pulse when the magnetic field flips, and that pulse powers the turn counter. No battery and no maintenance.

Absolute encoders usually talk over a serial interface instead of A/B pulses, and they cost more. For a prototype joint that turns less than once, a single-turn magnetic sensor with a small magnet on the shaft end is often the cheapest way to an absolute angle.

Optical or magnetic?

Optical encoders shine light through a slotted disc. They reach the highest resolution, but dust, oil and condensation on the disc cause errors. Magnetic encoders read a magnet with a sensor chip. They shrug off dirt and are cheap, but they are less accurate and can be disturbed by strong stray fields, for example from the motor itself.

Motor side or load side: what the encoder really sees

This point matters most and is easiest to miss. An encoder on the back of the motor measures the motor shaft, not the tool. Everything after it is invisible to it: the play in the lead-screw nut, the stretch of the belt, a slipping coupling, the frame bending under load.

The numbers show why. With 2000 counts per revolution on a lead screw with 8 mm lead, one count is 4 µm. A plain lead-screw nut can easily have a tenth of a millimetre of play, 25 times more. The encoder happily reports 4 µm steps while the carriage sits a tenth of a millimetre away from where it should be. On a belt axis, the belt stretches under hard acceleration, and the motor encoder never notices.

A motor-side encoder catches lost steps and stalls. If you need the real position of the carriage, measure the carriage: a linear scale along the axis sees backlash and stretch, but costs more and needs protection from chips and dust. Precision machines often use both, the motor encoder for a smooth control loop and the scale for the final position.

Reading an encoder without losing counts

Work out the count rate before you choose the controller. 2000 counts per revolution at 3000 rpm is 100,000 counts per second. A small microcontroller that runs an interrupt for every edge will drop some of them. Use a hardware counter instead: many microcontrollers have timers with a built-in quadrature mode, and dedicated counter chips cover the rest.

The second cause of wrong counts is noise: encoder wires next to motor cables pick up spikes that look like extra edges. Prefer encoders with differential outputs when the cable is long or shares a path with motor wires, use twisted, shielded cable, and route it away from the motor phases.

A quick checklist

  1. What happens when the position is wrong? If a crash costs money or is unsafe, close the loop.
  2. Must the machine know its position at power-up without moving? Then absolute, and multi-turn if the axis turns more than once.
  3. Where do the errors come from? If backlash or stretch matter, measure on the load side.
  4. Choose counts a few times finer than the accuracy you need. More counts add data, not precision.
  5. Can the controller read the encoder at full speed? Calculate the count rate.
  6. Is the machine dirty or open? Prefer magnetic. Clean and precise? Optical.

How this fits into the rest of the machine

The encoder belongs to the same decision as the motor, the drive and the homing switch: see stepper, DC or servo motor, lead screw, belt or rack and pinion and linear guides.

When makemachine plans a machine, the sensors are part of the concept from the first version: it decides which axes need feedback, the electronics get the matching inputs, and the CAD model leaves room for the sensor and its cable. If you have a machine idea, start a project on makemachine.ai and see how the axes come together.

Watch hardware get built by AI. Follow public projects on makemachine.ai, read every result in full and get an email when there is something new.

Get started See the live projects

More from the blog

Open-hardware projects built with AI