Troubleshooting KMotion Z-Axis Encoder Scale Drift

Tom Garrett6 min read
Motion ControlOther ManufacturerTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The Z-axis discrepancy is a scale mismatch between commanded step motion and encoder feedback, not a position-dependent encoder fault. In closed-loop step/direction mode, the mismatch accumulates with travel until the correction reaches the configured MaxOutput=10000 limit; beyond that point, the controller cannot apply enough correction. Correct the microstep-to-encoder count ratio and the trajectory-planner scale, then verify the axis in open loop before restoring closed-loop operation.

How the scale error creates the symptom

Axis 2 uses encoder feedback with step/direction output:

ch2->InputMode=ENCODER_MODE;
ch2->OutputMode=CL_STEP_DIR_MODE;
ch2->InputChan0=0;       // or 10
ch2->InputGain0=3.2;
ch2->OutputChan0=146;
ch2->OutputGain=-1;
ch2->MaxOutput=10000;

The trajectory planner generates a destination based on its Z-axis scale. The encoder supplies actual position through InputChan0, with InputGain0 contributing to the conversion used by the axis loop. If the commanded microsteps per unit and feedback counts per unit are not equivalent, each millimeter of travel adds a small following-position discrepancy.

The closed-loop step/direction controller initially hides that mismatch by issuing corrective steps. Correction demand grows with distance from the point where the commanded and measured positions were aligned. When that demand reaches MaxOutput=10000, the output correction saturates and the displayed encoder position begins separating visibly from the Z DRO.

Zeroing the encoder at -20 mm removes the accumulated error at that one location. It does not repair the scale ratio. The readings then agree locally and diverge again as the axis travels farther from the new zero.

What the measurements reveal

Z DRO Encoder position divided by Z scale Error
-18.000 mm -18.000 mm 0.000 mm
-19.000 mm -19.000 mm 0.000 mm
-20.000 mm -20.001 mm -0.001 mm
-25.000 mm -25.069 mm -0.069 mm
-30.000 mm -30.142 mm -0.142 mm

From -20 mm to -30 mm, the nominal travel is 10 mm while the encoder indicates approximately 10.141 mm. Using the endpoints, the incremental scale error is:

Scale error = (encoder travel - commanded travel) / commanded travel
            = (10.141 mm - 10.000 mm) / 10.000 mm
            = 0.0141, or about 1.41%

The observed error is therefore about 1.4%, matching a conversion mismatch rather than random missed counts. A possible source is confusing a 5 mm screw pitch with 0.2 in. Because 0.2 in equals 5.08 mm, those values differ by 1.6%. Treat that as a specific item to check against the installed screw marking or measured travel, not as proof that this machine has either pitch.

The identical result through Encoder #10 on Kogna JP8 and Encoder #0 on Kanalog JP1 further moves the diagnosis away from one input connector. The encoder's stated minimum edge separation is 0.25 microseconds, equivalent to a 4 MHz edge rate, but the position-proportional and repeatable drift pattern does not indicate an input-rate failure.

Diagnostic sequence

  1. Record the alignment point. Disable the axis only under conditions that prevent unintended Z motion, align the commanded and feedback positions, and record both values. Avoid repeatedly zeroing during the test because that erases the accumulated scale error needed for diagnosis.
  2. Measure over the longest safe travel. Command a known Z displacement and record the starting and ending DRO, encoder count, axis Position, and Destination. Longer travel makes a ratio error easier to distinguish from backlash or measurement resolution.
  3. Calculate both scale factors. Determine commanded microsteps per millimeter from the configured motor steps, microstep setting, transmission ratio, and screw pitch. Determine encoder counts per millimeter from the encoder resolution, decoding method, transmission ratio, and the sign and magnitude of InputGain0.
  4. Test open-loop step/direction operation. Temporarily use open-loop control, make a large but safe move, and compare Position with Destination and with independently measured carriage travel. This removes servo correction from the measurement and exposes whether the commanded step scale matches actual mechanics.
  5. Check correction saturation. During the closed-loop test, monitor following error and output demand. If the separation starts when output reaches the configured limit, MaxOutput=10000 is containing the consequence of the scale mismatch rather than causing the underlying ratio error.
  6. Repeat on both encoder inputs only if needed. Matching results on channels 0 and 10 indicate that changing connectors will not correct the scale. Continue with scaling and mechanics unless signal diagnostics show count discontinuities or direction errors.

Correcting the configuration

Choose one authoritative mechanical unit—normally counts or steps per millimeter—and make every conversion agree with it. Read the actual encoder resolution, drive microstep configuration, transmission ratio, and screw pitch from the installed components. Do not tune the PID gains to compensate for a conversion error.

  1. Calculate the true commanded microsteps per millimeter from the drive and mechanics.
  2. Calculate the true encoder counts per millimeter at the selected encoder input.
  3. Set the trajectory-planner Z parameter so a requested millimeter produces the calculated number of commanded steps.
  4. Set InputGain0 so encoder feedback uses the same internal distance basis and correct direction. Retain OutputGain=-1 only if it produces the required command direction with stable negative feedback.
  5. Reinitialize the axis with EnableAxisDest(2, ch2->Position), then perform a short, low-speed move before increasing travel.

If the current ratio is otherwise valid and the measured 1.41% error is confirmed over several moves, apply the correction to the incorrect scale only. For a scale that makes feedback read 1.0141 times too much travel, the corrected multiplier is the current multiplier divided by 1.0141. Recalculate from component data whenever possible instead of relying solely on this observed ratio.

Verification after adjustment

Verify the correction in both directions and from more than one starting position. A successful result has four characteristics: encoder displacement agrees with commanded displacement, Position remains close to Destination, error does not grow in proportion to travel, and output correction remains below MaxOutput.

Run at least one move spanning the original -19 mm transition and one move beginning below -20 mm without re-zeroing. Compare displacement rather than absolute coordinates. If forward and reverse displacement have the same proportional error, scaling remains wrong; if the error changes with direction or appears mainly at reversals, inspect backlash, coupling slip, screw thrust movement, and encoder mounting.

Finally, increase velocity toward the operating value while watching for sudden count discontinuities. The configured values Vel=272000, Accel=2720000, and Jerk=15000000 are controller units and cannot be converted to encoder edge rate until the command scale is known. Calculate the maximum expected edge frequency from the corrected counts-per-distance value and actual axis speed, then compare it with the encoder and input specifications.

Recurring pitfalls

  • Increasing MaxOutput: This may postpone visible divergence but leaves the loop continuously correcting a bad ratio.
  • Retuning P, I, or D: Servo tuning changes response dynamics; it does not reconcile counts per millimeter.
  • Zeroing at the failure point: This masks accumulated error and makes a scale problem appear position-dependent.
  • Comparing absolute positions only: Use start-to-end displacement so offsets do not contaminate the ratio calculation.
  • Changing multiple scale terms together: Modify only the term shown to be wrong, then rerun the same measured move.
  • Assuming a connector fault: A repeatable proportional error on Encoder #0 and Encoder #10 points to shared configuration or mechanics; electrical count loss more often produces discontinuities or speed-dependent errors.

FAQ

Why does my KMotion encoder drift only after -19 mm?

A small command-to-feedback scale mismatch accumulates with distance. Near -19 mm, the closed-loop correction reaches the configured MaxOutput=10000 limit, making the remaining error visible.

Why does zeroing the encoder at -20 mm fix the Z DRO?

Zeroing removes the accumulated offset at -20 mm, so the readings agree at that point. The incorrect counts-per-millimeter ratio remains and produces new divergence with further travel.

How do I test a closed-loop step/dir scaling mismatch?

Temporarily operate in open loop, make a large safe move, and compare Position, Destination, encoder displacement, and measured mechanical travel. A proportional displacement error identifies the scale term that requires correction.

Can a 5 mm versus 0.2 inch screw setting cause this error?

Yes. Since 0.2 in equals 5.08 mm, confusing those pitches creates a 1.6% difference, close to the observed approximately 1.4%; verify the installed screw before changing the scale.

Back to blog