How-to
Why a pseudo closed loop stepper counts endlessly
Short answer
Endless counting on a pseudo closed loop stepper means the channel's feedback sign is inverted or the loop still carries derivative and integral gains tuned for a servo. Set I7mn0=8 and I7mn6=2 for the channel, save and reset, prove that a positive open-loop output raises M101, then zero the derivative and integral gains and raise the proportional gain stepwise until a short move settles.

On this page
- Why does the position count endlessly as soon as the motor moves?
- Which two settings put the channel into pseudo closed loop?
- How do I point the position register at the channel I configured?
- How do I prove the feedback sign before closing the loop?
- Which gains does a pure integrator tolerate?
- How do I verify the loop is settled before the demonstration?
- What can a pseudo closed loop never tell me?
- Questions asked
A PMAC-family motion controller can close a stepper axis on its own pulse-and-direction output when no encoder is fitted: the channel decodes the very pulses it generates and reports them as position. When that pseudo closed loop counts endlessly up or down from the first commanded move, the fault is one of two things: the feedback sign is inverted, or derivative and integral gains tuned for a real servo are still active. The fix is concrete. Set I7mn0=8 and I7mn6=2 for the channel, save and reset, and read both back. Kill the motor and prove that a small positive open-loop output raises M101; if it lowers it, invert the decode direction. Then zero the derivative and integral gains and raise the proportional gain stepwise. What you end up with is right for a demonstration of position capture and for nothing more, because the register holds commanded pulses, not shaft position.
Why does the position count endlessly as soon as the motor moves? #
The position runs away because the channel feeds the servo its own pulse output as feedback: the plant is a pure integrator, so an inverted decode sign makes the output and the readback push each other, and derivative or integral gains left from the servo tune accelerate the runaway.
In this mode the servo algorithm's output sets the frequency of the pulse train, the channel's decoder counts that same train, and the feedback register holds the integral of the commanded velocity. No motor dynamics, no load disturbance and no true shaft position enter the loop.
Counting in one direction, starting the instant a move is commanded and never settling, is the signature of positive feedback: the output raises the pulse frequency, the readback increments the same way, the following error grows, and the output drives to its limit. The second cause is gain structure: derivative and integral gains tuned for a servo driving a real motor turn a plant that is already an integrator into an oscillator or a runaway. Both causes are fixed with the settings and numbers below.
Which two settings put the channel into pseudo closed loop? #
Two settings do it: I7mn0=8 selects the decode mode that reads the channel's own pulse output back as position, and I7mn6=2 selects PFM as that channel's output mode; save, reset, and read both back before you tune anything.
Use the same channel index pair in every variable you touch for the axis. Write both settings, issue the controller's save command, reset or power-cycle, then query both again from the terminal:
| Setting | What it selects | Read-back check |
|---|---|---|
| I7mn0=8 | Decode mode that reads the channel's own pulse output as position | Query after reset; it must return 8 |
| I7mn6=2 | PFM as the channel's output mode | Query after reset; it must return 2 |
If either variable returns the old encoder-mode value, the write did not survive: save and reset once more and read it back before you touch anything else. Decode and output-mode assignments differ between controller generations, so confirm the two tables for your hardware in its software reference manual.
How do I point the position register at the channel I configured? #
The motor's feedback address must point at the decoded counter of the same m and n channel you just configured, and M101 must be defined on the register that holds that motor's actual position, because a conversion from an encoder setup often leaves both pointers on the old channel.
Check three things before the sign test. The feedback address must reference the decoded counter of the very channel carrying the pseudo loop, not the previous encoder input and not a neighbouring channel. The definition behind M101 must sit on the register that holds the motor's actual position, not on a raw counter that wraps and not on another motor's register. The stepper driver must be enabled and set to accept pulse-and-direction input: if it expects a different step format, the motor stays still while the internal loopback counts, which proves only that the output path works.
Then jog a short distance and watch M101 and the motor's reported position together. If M101 changes but the reported position does not, the address is wrong: correct the pointers and repeat the jog until both move together.
How do I prove the feedback sign before closing the loop? #
Kill the motor, write a small positive open-loop output, and read M101: it must increase; if it decreases, the decode direction is opposite to the output direction, and you invert it by selecting the opposite-direction decode mode from the I7mn0 table.
With the sign inverted, the servo sees position moving the wrong way, adds output, and the added output pushes the readback further the wrong way, so the register counts without end. No gain value can fix that, which is why changing the loop gains alone left the runaway in place.
After correcting a wrong sign, close the loop and command a short move. If the position now settles, go straight to the verification list; if it still runs away, the gains in the next section are the remaining cause. Keep a hand on the drive-enable or kill command through this test: a loop closed on the wrong sign can run the axis to the end of its travel, and the loopback register reports nothing wrong while it happens.
Which gains does a pure integrator tolerate? #
Set the derivative and integral gains to zero and start the proportional gain low: the pulse channel already integrates the servo output, so leftover derivative acts on a ramp and leftover integral winds up, while proportional gain alone shapes a well-behaved first-order response.
Zeroing two of the terms does not remove the need for tuning: the proportional gain is what gives the loop its bandwidth, the point the page on why a phantom closed loop stepper still needs PID gains makes for commanded-pulse feedback as well. Derivative earns its place on plants with real inertia, where it damps overshoot, as set out in why raising derivative gain reduces overshoot; a pulse-channel integrator is not that plant.
| Gain | Starting value | Reason on this plant |
|---|---|---|
| Proportional | Low, raised in small steps | Sets the response speed against the plant's integrator |
| Derivative | 0 | No real inertia inside the loop for it to damp |
| Integral | 0 | The plant already removes steady error by integrating |
| Velocity feedforward | Raise only if following error during motion is too large | Carries most of the velocity command in a pulse system |
Command a small step, watch the following error, and raise the proportional gain until the move completes without overshoot; the same stepwise discipline applies when tuning a pulse-and-direction stepper in closed loop on real feedback. Then check the servo output limit and the channel's maximum pulse rate against the stepper driver's rated input rate: a driver asked for steps faster than it accepts loses them at speed, and the physics stops while the loopback keeps counting. Take that rate from the driver's own datasheet, because it is a rating of that driver, not of the controller.
How do I verify the loop is settled before the demonstration? #
A settled pseudo loop holds the position register constant with the motor idle and lands it exactly on the commanded target of every move, with the shaft physically covering the distance you calculated for the pulse count.
Work down this list in order and stop at the first check that fails:
- Idle drift: with the motor enabled and holding, read M101 five times over several seconds; the value must not move.
- Commanded distance: command a move of known length; the register must land on the arithmetic target and stop changing inside the in-position band.
- Physical travel: mark the output shaft or measure the travel; the machine must really cover the distance the count describes.
- Return move: command the axis back to the start; the register must return to its starting value and the following error must settle near zero.
- Capture check: run the position-capture routine; the captured value must equal the commanded position at the trigger.
The arithmetic for check 2, as a calculated example for these inputs and not a measured result: a motor with 200 full steps per revolution, microstepped at 10 microsteps per full step, gives 200 × 10 = 2,000 pulses per motor revolution. Through a 5:1 gearbox, one output-shaft revolution costs 2,000 × 5 = 10,000 pulses, so a commanded output move of 90 degrees — 90/360 = 0.25 revolution — must move the register by 0.25 × 10,000 = 2,500 counts and end exactly there. Take the steps per revolution and the microstep factor from the drive's own configuration; both are settings of that drive, not constants of stepper motors. If check 3 disagrees with check 2, the loop is healthy and the machine is not: look for missed steps from speed or load, or a pulse scaling that does not match the mechanics.
What can a pseudo closed loop never tell me? #
A pseudo closed loop reports commanded pulses and nothing else: a stalled motor, a sheared coupling or a batch of lost steps leaves M101 looking perfect, so every captured position is a commanded position, never a measured one.
A hardware trigger captures the instantaneous pulse count, which leads or lags the physical shaft by whatever following lag the stepper carries at that speed, so present every captured value as a commanded count and say so. That gap is the whole argument in does an encoder make a stepper motor closed loop: counting your own command tells the controller what it asked for, never where the load is. When the final encoders arrive, restore the encoder decode mode in I7mn0, move the feedback address to the encoder's counter register, and retune the gains, because derivative becomes useful again on a plant with real inertia.
The decision: run the pseudo loop only while the encoders are off the machine and only to demonstrate the position-capture routine; the moment anything depends on a measured position, fit the encoders and switch the decode back. A pseudo loop that passes all five checks is a working demonstration, not a measurement system.
Questions asked
What do m and n in I7mn0 and I7mn6 stand for?
m is the index of the servo IC that carries the channel and n is the channel number on that IC, so the same variable name on a different card addresses a different register. Every setting and address for an axis must use one consistent m and n pair, and a two-axis demonstration bench gives each motor its own pair along with its own position definition.
Why did changing the loop gains not stop the runaway?
A gain change only amplifies whatever signal the loop already sees. With the decode counting opposite to the output direction, a stronger proportional or integral term pushes harder the wrong way and the register runs away faster, not slower. Run the open-loop sign test first; only once a positive output raises the position register do new gain values have a stable loop to work on.
How accurate is position capture on a pseudo closed loop?
It is exact in commanded pulses and unverified against the shaft. The capture stores the pulse count at the trigger instant, which leads or lags the physical position by whatever following lag the stepper carries at that speed. That is enough to prove a capture routine triggers and records on time; it is not enough to quote a measured position, and an encoder sized for the accuracy the application claims is what turns the demonstration into data.
Does the pseudo loop protect the motor or the mechanics?
No. The register only counts commanded pulses, so a jam, a stall or a broken coupling leaves it clean while the motor overheats or the mechanics take the damage. Stall and overload protection has to come from the drive's own current and stall-detection settings, plus mechanical limits and hard stops chosen from the machine's risk assessment.


