How-to
Stepper encoder feedback: commanded position vs measured
Short answer
A pulse-output stepper system is open loop: the controller's commanded position is its own count of emitted step pulses, and the quadrature encoder gives a separate measured position. Program the two as independent values, compare them in ladder logic after each move, and never reset the position counter or reload the motion profile between absolute moves — every target is an absolute position, so a reset turns each move into a fresh move from zero.

On this page
- Two positions, not one
- Configure the output and the counter as two separate channels
- The move sequence, step by step
- Worked example: two absolute moves with the arithmetic
- Reading the commanded position back
- Compare the two values and act on the difference
- Reference both values at every power-up
- The decisions
- Questions asked
A stepper axis driven by pulse outputs runs open loop no matter what is bolted to the motor shaft. The controller's commanded position is its own count of the step pulses it emits; the quadrature encoder on the shaft gives a second, independent measured position. Program the two as separate values: configure the pulse output and the encoder counter as independent channels, drive every move from an absolute-target positioning profile, and compare the two numbers in ladder logic after the move-complete bit sets. The habit that breaks this scheme is resetting the position counter or reloading the motion profile between moves — every target is an absolute position, so wiping the accumulated count turns each move into a fresh move from zero. The sections below walk through the configuration, the ladder sequence, a worked scaling example and the comparison decisions.
Two positions, not one #
Commanded position lives inside the pulse-output profile. The counter module adds one count for each step pulse it emits and subtracts one for each reverse pulse, so its value is bookkeeping on its own output, never a measurement of the shaft. Measured position lives in the quadrature counter channel, which counts up and down with the actual rotation it sees through the coupling.
| Position value | Where it lives | What it is for |
|---|---|---|
| Commanded position | The profile's internal count of emitted pulses | The reference each absolute target moves toward, remembered between moves |
| Measured position | The quadrature encoder counter channel | The independent value ladder logic compares against after each move |
Because the profile's target is absolute, the value you write is a position, not a travel length: a target below the remembered position produces a reverse move of exactly the difference. Unplug the encoder and the drive still finishes every commanded move — that is the fastest proof the axis is open loop, and it is why adding an encoder does not by itself close the loop; whether an encoder makes a stepper motor closed loop covers what closed loop actually requires. Keep the two values in separate registers; the only time one is written into the other is at startup, when both receive the homing reference.
Configure the output and the counter as two separate channels #
In the counter module's configuration tool, treat the output and the input as unrelated channels. Set the wired output to the input style the stepper drive expects: pulse-and-direction, where one output emits pulses and a second output switches level for reverse, or two pulse trains with one output per direction. If the axis later moves the same way for increasing and decreasing targets, confirm this output mode first and check both signals at the drive terminals.
Configure the encoder channel as a quadrature counter, scaled with the counts-per-revolution figure from the encoder datasheet and the mechanical ratio between motor and shaft. Do not land the encoder on ordinary scanned inputs: at stepping speeds the CPU scan misses short pulses, which is the failure mode why a PLC misses short input pulses and how to catch them describes. A quadrature counter channel counts in hardware, independent of the scan.
The move sequence, step by step #
- In the counter module's configuration tool, set the wired output channel to the drive's input style and create the positioning profile, with its starting frequency, top frequency and acceleration set for the machine. Note the profile number the tool assigns.
- Configure the encoder channel as a quadrature counter and scale it with the counts-per-revolution value from the encoder datasheet and the mechanical ratio.
- Load the profile once at startup, through its own gated contact, with no move command active at the same moment.
- Write the absolute target, in pulses, to the profile's target register.
- Start the move with a rising edge on the go-to-position bit.
- Wait for the move-complete bit, then read the measured position from the encoder channel.
- Convert both values to one unit, compare them, and alarm when the difference leaves the tolerance band.
- For the next absolute target, switch the go-to-position bit off, write the new target, and switch it on again, with no reset and no profile reload in between.
Two habits are what actually break absolute positioning in the field. Energizing the profile-load command and the go-to-position command together re-initializes the profile while a move is being requested, and every target then behaves like a move from zero — put a normally open contact on the load instruction's input leg so it fires only when you intend it. Toggling the module's reset between moves establishes zero again and discards the accumulated position reference. Load the profile once at startup; after that, only write targets and pulse the move bit.
Worked example: two absolute moves with the arithmetic #
The inputs below are example values chosen to make the arithmetic easy; the results are a calculated example, not a measured test.
- 1.8 degree stepper motor: 360 / 1.8 = 200 full steps per revolution.
- Drive microstep switch set to 8: 200 × 8 = 1600 step pulses per motor revolution.
- 5 mm pitch screw with a 1:1 coupling: 1600 / 5 = 320 pulses per mm of axis travel.
- Quadrature encoder rated at 100 pulses per revolution, from its datasheet: quadrature decoding gives four counts per line, so 4 × 100 = 400 counts per revolution, and 400 / 5 = 80 counts per mm of travel.
Move one, to 20.0 mm absolute: the target register receives 20.0 × 320 = 6400 pulses, and after the move-complete bit sets the encoder should read 20.0 × 80 = 1600 counts.
Move two, to 12.5 mm absolute, written with no reset and no profile reload in between: the target register receives 12.5 × 320 = 4000 pulses, and the profile must travel reverse by 6400 - 4000 = 2400 pulses, which is 2400 / 320 = 7.5 mm. The encoder should end at 1600 - (7.5 × 80) = 1600 - 600 = 1000 counts.
If the axis instead repeats a 12.5 mm move in the same direction, a reset or a reload wiped the remembered position between the commands. The arithmetic did not fail; the sequence did.
Reading the commanded position back #
Some counter modules keep the output pulse count internal to the profile instruction and do not expose it as an ordinary register. When ladder logic needs the commanded value, read the output count with the module's read or system function, then make it signed: with pulse-and-direction the raw count is unsigned, so combine it with the state of the direction output; with two per-direction pulse trains, keep a running signed total of forward pulses minus reverse pulses. Read it once per move, at the move-complete bit, not every scan.
Compare the two values and act on the difference #
After each move, convert both values to one unit and compute the difference. Set the tolerance band from your own mechanics, not from an article: at the example scale, a band of 10 counts is 10 / 80 = 0.125 mm, wide enough for quadrant edge jitter and modest overshoot on a healthy axis. Then sort what you see:
- A small offset of the same sign on every move is backlash plus deceleration overshoot. Fold it into the band's center or always approach each position from one direction.
- A gap that grows with distance or load means the motor lost steps the controller never noticed; the mechanical causes line up with why a pulse-command axis loses position between moves, and lowering acceleration or load is the fix.
- The same wrong fraction of travel on every move is scaling, not lost motion; recheck both conversions the way an axis that travels 1.25 times the commanded distance works through the arithmetic.
- Commanded advancing while measured stays frozen points at the encoder channel: coupling slipped, wiring fault, or the channel never configured.
- Measured counting while commanded stays at zero points at the output side: check the output mode and the drive terminals.
To prove the encoder channel before trusting it, disable the drive and apply your site's lockout practice, then turn the coupling by hand: the count must rise and fall with rotation and hold still at rest.
Reference both values at every power-up #
Both numbers are counts in volatile memory, and both drop to zero when power goes away. An absolute target written into a profile that believes it sits at zero will run a full travel from a false zero. Home the axis against a limit switch or a fixed stop at startup, then write that reference into both the profile's position and the encoder counter so commanded and measured agree from the first move. Neither channel is absolute across a power cycle on its own; Absolute vs quadrature encoder: what survives a power cycle covers what each encoder type remembers.
The decisions #
A pulse-output stepper with an encoder is a verification system, not a closed loop, so run it as one:
- Sequence right and the band holds: write absolute targets, switch the move bit off and on between moves, alarm outside the band, and leave the structure alone.
- Every target makes a fresh full move from zero: a reset or the profile-load command fires between or during moves. Gate the load contact and remove the reset toggle; the fix is two rungs of ladder.
- Commanded advances while measured is frozen: fix the encoder channel, in the order configuration, coupling, wiring, and prove it by hand with the drive disabled and locked out.
- Measured lags commanded by a growing amount: lost steps. Reduce acceleration or load, because the encoder can report lost steps but never recover them.
- Travel is always the same wrong fraction: scaling on one channel is wrong; recompute counts per revolution and the mechanical ratio for both channels.
- The process needs position corrected during the move: this architecture cannot do it. Move to a stepper drive that takes the encoder as its own feedback, or to a servo axis, where the comparison becomes the drive's own job.
Questions asked
Does the encoder stop the axis if the motor stalls?
No. A standard pulse-following stepper drive executes the whole pulse train even when the shaft is stalled, and the measured position just stops changing while commanded position keeps advancing. The protection is your own logic: after the move-complete bit sets, compare the two values and trip an alarm or stop the process when they differ by more than your tolerance band. Correcting the position automatically needs a drive that takes the encoder as its own feedback input.
How much axis travel is one encoder count?
It depends on your hardware, and you compute it. For the example axis in this article, a 1.8 degree motor with the drive set to 8 microsteps, a 5 mm pitch screw and a direct coupling, one revolution is 1600 step pulses or 400 encoder counts, so one encoder count is 5 divided by 400, which is 0.0125 mm, and one step pulse is 5 divided by 1600, which is 0.003125 mm. Take the microstep setting from your drive's switch and the line count from your encoder datasheet, not from an article.
Why must the go-to-position bit switch off and back on between moves?
Because the profile starts a move on the rising edge of that command. If the bit is still on from the previous move, a newly written target may not trigger anything, and holding it on at the same time as the profile-load command re-initializes the profile mid-command, which is what makes every target behave like a move from zero. Load the profile once through its own gated contact, then trigger each move with a clean off-to-on transition after the target register is written.
Should I scale the encoder to engineering units or compare raw counts?
Either works if both sides land in one common unit. Scaling the encoder channel in the configuration tool gives millimeters directly, but then your alarm band is in millimeters while the commanded side still needs its own conversion from pulses. Comparing raw counts avoids that second conversion as long as your logic applies the same counts-per-millimeter and pulses-per-millimeter factors everywhere and documents them. A wrong factor on either side looks exactly like position error, so verify the scale with a known travel before trusting the comparison.
