GreatLight CNC Machining Factory logo
CNC Machining
Rapid Prototyping
Materials
Industries
News
About GL

Get Instant Quote

CNC Fundamentals

What Is an Encoder and Decoder in CNC Machine Control?

The encoder measures where the axis actually is; the decoder turns that signal into numbers the controller can act on. This page explains the mechanism, the boundary conditions, and what it means for the tolerances you can hold on a real part.

±0.005 mm tolerance127 CNC machines16 five-axis centersISO 9001 / IATF 16949
what is encoder and decoder in cnc machine
The mechanism

What an encoder and decoder in CNC machine feedback actually do

Say the controller commands an axis to move to 152.734 mm. The servo drives the ball screw, and the axis moves. Something has to confirm it landed there and not at 152.731 mm. That is the encoder's job. It is a transducer bolted to the motor shaft or to the slide itself, and it outputs a pulse train whose count is proportional to travel.

The decoder is the second half of the pair. Encoder output is not a number yet. It is a pair of square waves, usually called A and B, plus a once-per-revolution index mark called Z. The decoder counts edges, reads which channel leads to establish direction, multiplies the count by an interpolation factor, and hands the controller a clean position value and a velocity value.

That loop closes thousands of times per second. If the commanded position and the decoded position disagree by more than a set window, the drive faults out before the tool ever touches metal. This is why the feedback chain, not the ball screw alone, sets the practical floor on accuracy.

One consequence engineers should keep in mind: the decoder only knows what the encoder tells it. Backlash, thermal growth of the screw, and tilt of the column sit outside that loop unless a second scale is fitted on the axis itself.

  • 1
    EncoderMeasures actual position and speed; outputs A, B and Z signals.
  • 2
    DecoderCounts edges, resolves direction, produces position and velocity values.
  • 3
    ControllerCompares command against feedback and corrects the drive.
Types

Incremental, absolute, and where each one belongs

Incremental encoders count from a reference point. They have no memory of absolute position. After a power loss the machine must return to a home or reference mark, using the Z pulse, to re-establish where it is. Any motion during the outage is simply lost information. On a three-axis mill this homing routine costs a few seconds and is rarely a problem.

Absolute encoders report a unique position value at every point in travel, so the machine knows where it is the moment power returns. No homing cycle, no lost position after an e-stop. The trade is cost and wiring complexity. On a five-axis machine with a tilting head, that trade usually pays for itself because re-homing a rotary axis mid-setup is slow and easy to get wrong.

Linear encoders sit on the slide rather than the motor. They see the table itself, so they capture screw pitch error, thermal growth, and backlash directly. Rotary encoders on the motor shaft see only motor rotation and trust the mechanical train in between. For work at ±0.005 mm, a linear scale on the critical axis is often the difference between holding tolerance all shift and chasing drift.

Magnetic and optical versions cover the same ground with different constraints. Optical scales give finer resolution but dislike oil mist and chips on the read head. Magnetic scales tolerate contamination better and are common on lathes and on machines cutting graphite or cast iron.

  • 1
    IncrementalLow cost, needs homing after power loss.
  • 2
    AbsolutePosition known at power-up, better for rotary and 5-axis.
  • 3
    Linear scaleReads the slide, captures screw and thermal error.
Resolution

Resolution, accuracy, and repeatability are not the same thing

A spec sheet that says 0.1 μm resolution does not mean the machine holds 0.1 μm. Resolution is the smallest step the decoder can report. Accuracy is how close the reported position is to the true position. Repeatability is how consistently the axis returns to the same point. Buyers mix these up constantly, and the mix-up leads to unrealistic purchase specs.

Consider a common setup: a rotary encoder with 2,500 lines per revolution, decoded with four-fold quadrature, on a 10 mm pitch ball screw. That gives roughly 1 μm of reported resolution per step. The machine may still only hold ±0.01 mm because of screw lead error, thermal drift, and servo tuning. Resolution sets the floor, not the result.

Interpolation inside the decoder multiplies the raw count. A 1 Vpp sine encoder with 1,024 periods, interpolated 4,096-fold, reports very fine numbers indeed. But interpolation amplifies signal noise along with signal. If the scale is dirty or the head alignment is off, a high interpolation factor makes the position reading jittery rather than more precise.

The practical question is not which encoder has the biggest number. It is whether the feedback chain is finer than the tolerance you need to hold, with margin left for everything downstream.

  • 1
    ResolutionSmallest reported step from the decoder.
  • 2
    AccuracyCloseness of reported position to true position.
  • 3
    RepeatabilitySpread of returns to the same commanded point.
Failure modes

How the feedback chain fails, and what it looks like on the part

Contamination is the most common cause. Oil mist, fine chips, or coolant film on an optical read head scatters the light and drops pulses. The decoder sees fewer counts than the axis actually travelled, so the controller thinks it is short of target and keeps driving. The visible result is a part that measures oversize on one feature and on size on the next, with no consistent pattern.

Cable and connector problems show up as intermittent faults that appear only at certain axis positions. A partially broken signal wire inside a drag chain can pass continuity checks on a stationary machine and fail the moment the axis moves. If a drive alarms only in one region of travel, check the cable before replacing the encoder.

Electrical noise from a spindle drive or a welding cell nearby can corrupt the A and B channels. Shielding, separate routing, and proper grounding fix most of it. A differential line driver output instead of a single-ended one is the other standard fix.

Mechanical issues look different again. A loose coupling or a slipping belt between motor and screw means the encoder reports motor rotation that never reached the slide. The controller is satisfied, the part is not. This is exactly the case a linear scale would catch and a motor-mounted encoder cannot.

  • 1
    Symptom: oversize featuresDirty optical scale dropping pulses.
  • 2
    Symptom: alarm at one positionBroken wire inside the drag chain.
  • 3
    Symptom: erratic size, no patternNoise on the signal channels.
Shop floor

What this means for the parts you send out for machining

When a shop quotes ±0.005 mm, it is quoting what its machines and its inspection can actually hold. That number comes from the whole chain: encoder, decoder, screw, structure, thermal control, and metrology. The feedback system is one link, and it is usually a well-understood one on modern machines.

For most machined parts, the tolerance driver is not the encoder. It is fixturing, tool wear, and heat. A block of 6061 aluminium that warms 5 °C during a long roughing pass moves more than the feedback resolution ever will. That is why in-process measurement and a cool-down before finishing matter more than the encoder spec on the datasheet.

Where feedback does become the limit is on long axes, on rotary axes, and on parts with tight true-position callouts across several features. On a 4,000 mm travel machine, screw thermal growth over a shift can exceed the tolerance band. A linear scale on that axis is not a luxury.

So the useful question when you review a supplier is not which encoder brand they run. It is whether they can explain how they hold the tolerance on your specific feature, and whether they inspect it before the part ships.

  • 1
    Short axesFeedback rarely the limiting factor.
  • 2
    Long axesThermal and lead error dominate; linear scales help.
  • 3
    Rotary axesAbsolute feedback avoids re-homing errors.
Selection guide

Which feedback setup fits which axis

Match the feedback device to the axis, the tolerance, and the environment.

Axis typeTypical feedbackHolds roughlyWhen it is the wrong choice
3-axis mill, short travelIncremental rotary on motor±0.01 mmLong unattended runs with thermal drift
4-axis with rotary tableAbsolute rotary on table±0.01 mm angularBudget jobs with loose angular tolerance
5-axis simultaneousAbsolute on all rotary axes±0.005 mmTwo-axis positioning work only
Long-travel gantryLinear scale on X±0.005 mm over 4,000 mmShort parts where screw error is negligible
Turning centerMagnetic rotary on spindle±0.005 mmOptical-only shops with heavy oil mist
Grinding or finishingLinear scale, high interpolationRa 0.2–0.8 μm finishesDirty environments without air purge

The short version

If your part is short and your tolerance is ±0.01 mm or looser, a standard motor-mounted incremental encoder is enough and you should not pay for more. If you are holding ±0.005 mm across a long axis or on a rotary axis, insist on linear or absolute feedback, because that is where the loop stops being your friend.

FAQs

Questions engineers ask next

Is the decoder a separate box on the machine?

Usually not. On modern drives the decoding happens inside the servo amplifier or the controller, on a dedicated input card. Older systems sometimes used a separate interface board between the encoder and the control.

Functionally it does not matter where the decoding sits. What matters is that the count, the direction, and the interpolation factor are all correct before the position loop uses them.

Can I add a linear scale to an existing machine?

Sometimes. It depends on whether the control accepts a second feedback input and whether the mechanical mounting surface exists. Retrofits are common on surface grinders and on older mills used for finishing work.

The cost is not just the scale. It includes mounting, alignment, cable routing, and re-tuning the servo loop to the new feedback source.

Why does the machine need to home every morning?

That is the signature of an incremental feedback system. It has no absolute reference, so it must find a known mark before it trusts any position value.

If the machine homes after every power-up but not between shifts while powered, that is normal. If it loses position mid-shift, look at the encoder coupling and the cable, not the homing routine.

Does a higher count encoder always give a better part?

No. Past a certain point the mechanical structure, the thermal state, and the tool condition dominate the result. A very fine count on a machine with a loose axis just reports the looseness more precisely.

Match the feedback resolution to the tolerance you need, with some margin, and spend the rest of the budget on fixturing and inspection.

How do I know if my supplier's feedback chain is adequate?

Ask which axes carry linear or absolute feedback and what the incoming inspection covers. A supplier that can answer both is usually measuring what it ships.

At GreatLight, 127 CNC machines run with 100% inspection before shipment, and reports are available on request.

Send a drawing and get a real tolerance answer

We review your features against the machine that will cut them and reply with a quote and free DFM analysis within 12 hours.

12-hour quote100% inspectionNo minimum order quantityNDA on request

Follow

More from the shop floor

We publish setup notes, tooling trials and inspection data from the factory floor.

FacebookTikTokYouTubeLinkedInInstagramThreadsPinterest

Trusted by engineers and manufacturers worldwide

Tesla Ford Motor Company BYD Auto Denso Magna International Boeing Airbus Medtronic KUKA FANUC