AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

Troubleshooting

Why a Stepper Axis Runs at Drive Power-Up Before Software Loads

Servo and stepper motion Published 9 min read By AutomateDirectUSA engineering team

Short answer

Motion that starts when drive power arrives and stops when the drive trips its own position error is an enable-sequencing fault, not replayed motion: until the controller configures its outputs, pulse inputs float and noise can be counted as steps. Route every servo-on circuit through one controller-controlled relay, keep it off until initialization finishes, then energize the enable relay, and run a StatusRequestCounter watchdog so closing the PC software also disables the drives. The reported machine went from roughly one runaway in ten starts to none.

On this page
  1. Why does a stepper motor start moving before any software loads?
  2. Is the motion coming from something stored in the controller or the PC?
  3. Could a closed-loop drive enable with a stored position error?
  4. How do I catch and identify the axis that runs away?
  5. How do I sequence drive enable so no input can step the motor early?
  6. How do I drop the drives out when the PC software closes?
  7. Why can the drives come back enabled after drive power is cycled?
  8. Example: how far do stray pulse counts move a 5 mm-lead screw?
  9. How do I verify the sequencing fix start after start?
  10. Questions asked

A stepper axis that starts moving the instant drive power arrives — before the motion software loads, before any command exists — is not replaying something stored. It is a drive that was enabled while the controller's pulse outputs were still unconfigured, leaving its inputs floating where noise can toggle them into steps; on a closed-loop drive, an internal destination that differs from the encoder position can produce the same motion. The fix is enable sequencing, and the field result backs it: let the controller close the drives' enable circuit itself, through one relay, only after every axis is configured and zeroed. This article works a reported case — five closed-loop stepper drives under a KFLOP motion controller with a Kanalog board on a knee-mill retrofit — from first symptom to the checks that prove the fix.

Why does a stepper motor start moving before any software loads? #

Motion that begins within seconds of drive energization and stops only when the drive trips its own position error is an enable-sequencing fault: the drives were live while the controller's pulse outputs were still unconfigured, and something in that window stepped them.

The exposed time is the gap between drive energization and the first axis configuration. Until the initialization program runs, the controller's CW/CCW outputs are not driven to a defined level. The reported machine wired each drive's pulse inputs directly to its controller output, so a floating line sat straight on the drive's step input, and every edge it picked up — switching noise, a ground offset, a marginal connection — was a step the drive counted. The power-up wiring widened the window: a Watchdog FET switch (SWE output) on connector JP8 closed the contactor feeding the drives and the VFD as soon as the controller was alive, which can be seconds before any configuration exists.

Commit to the decision rule now: motion at drive energization, before software loads, gets the sequencing fix in this article. An axis that runs away while a move is executing, or during tuning, is a different fault — open troubleshooting a servo axis that faults mid move or why a servo axis runs away during tuning instead.

Is the motion coming from something stored in the controller or the PC? #

No — a controller of this family powers up unconfigured, with every axis disabled and no buffered motion, so nothing stored in it can replay; if yours ever comes up configured or enabled, a flashed user program is the suspect.

Verify it from the console after any runaway: an axis that shows configured or enabled at boot means configuration is being loaded from flash, and re-running the console's New Version flash puts the controller back in that default state.

The PC is cleared the same way. Before the motion software runs, the PC sends nothing to the controller, and an unconfigured controller drives no outputs, so there is no path by which stored PC data becomes pulses. The reported pattern — failures clustering when the PC had been left running between sessions — reflects startup order and timing, not held data. Chase the enable window, not the PC.

Could a closed-loop drive enable with a stored position error? #

Possibly, and the sequencing fix below covers it either way: a closed-loop stepper drive that enables while its stored destination differs from the encoder position may drive until the mismatch is gone, which looks exactly like a runaway.

That mechanism fits the observed behavior — the reported motors ran until each drive's own position-error detector stopped them — but two facts keep it a hypothesis: the drive maker reportedly rejected stored motion as the cause, and no drive state was ever captured during a failure. What closed-loop feedback does and does not promise is its own subject; see whether an encoder makes a stepper motor closed loop.

The repair does not wait for a verdict. Both surviving explanations — floating pulse inputs and a drive-side position mismatch — are closed by the same change: no drive gets enabled until the controller has finished configuring every axis.

How do I catch and identify the axis that runs away? #

Catch it with the controller console, not with a guess: after a runaway, open the console and record whether any axis is configured, enabled or moving, then compare the affected axis's encoder count against its destination count.

Record at every occurrence, before resetting anything:

  • Which axis and drive channel moved, and in which direction.
  • The time between drive energization and first motion.
  • Whether the console shows any axis configured, enabled or moving at that moment.
  • The affected axis's encoder count next to its destination count, where the console exposes both.
  • The drive's own fault or position-error register after the stop.
  • The startup order: PC already running or cold, controller first or drives first.

Resetting only the misbehaving drive restored normal operation for the rest of the session in the reported case, which confirms the drive, not the controller, ended the motion — and that the trigger lived in the enabled-but-unconfigured interval. The reported accounts also drifted between sessions: the knee channel most often, sometimes a second channel, a different pairing later. That drift is typical of an intermittent, noise-driven fault, so log each event instead of assuming one bad output.

How do I sequence drive enable so no input can step the motor early? #

Route every drive's enable input through one relay driven by a Kanalog FET switch, keep that relay open until the initialization program has configured and zeroed all the axes, then close it with SetBit(155).

The reported machine routed each drive's servo-on wiring to a central point and drove the shared relay from a Kanalog FET switch, so all five drives enabled together under software control; the original power contactor can keep feeding the drives and the VFD, because the change is only that no drive's enable input goes true until the controller closes the relay. Mind the numbers: a Kanalog example activates FET Switch #0 with SetBit(152), and the reported machine's rewiring put its enable relay on output 155 — both belong to that installation, so map your own FET switch to its bit and confirm with a meter before using either.

The order in the initialization program is the fix:

#include "KMotionDef.h"

int main()
{
    /* configure and zero every axis first; indices are this machine's mapping */
    DisableAxis(0); Zero(0);
    DisableAxis(1); Zero(1);
    DisableAxis(2); Zero(2);
    DisableAxis(3); Zero(3);
    DisableAxis(4); Zero(4);

    /* only now can the drives be enabled */
    SetBit(155);
}

ClearBit on the same output drops the relay when the drives must be disabled. The functions shown are the controller's documented axis calls; the axis indices and the bit number are the reported wiring, not a standard.

How do I drop the drives out when the PC software closes? #

Poll status: while a PC application talks to the controller it requests status continuously, the controller's StatusRequestCounter increments, and a small watchdog loop drops the drive-enable relay the moment those requests stop.

The controller counts status requests in StatusRequestCounter, and every PC application that polls it — console or CNC software — advances the count while it runs. When all of those applications close or the PC powers off, the requests stop, and the WatchdogStatusRequests.c example detects exactly that condition so the program can act on it: drop the drive-enable relay.

The second loop is watchenable.c, written as a forever loop at the end of the initialization program: it watches axis-enable state and disables the drive relay whenever a monitored axis becomes disabled. Both loops belong in the initialization program so they exist before the relay closes for the first time — together they close the other half of the exposure, drives left enabled with nobody driving them.

Why can the drives come back enabled after drive power is cycled? #

Because the relay follows the controller, not the drives: if the controller stays powered while drive or VFD power is removed, its output bit stays set, and restoring drive power brings the drives back already enabled.

The reported installation hit exactly this: with the controller left on through a drive-power outage, the relay held closed, so power returned to drives that were enabled with no new enable sequence and no fresh configuration.

Close it at the source. If the drives expose a drive-ready or controller-ready signal, interface it and clear the enable output and all axes the moment ready is lost, so the drives must wait for a deliberate new enable after power returns. Whether the reported drives offer a usable ready signal was never established, so read their manual and wire that input before the next power cycle rather than assuming it.

Treat every power-up as live until the sequence has proven itself: in one reported runaway the motor stopped only when it reached a limit switch, so keep hardware limits and the emergency stop wired to functions the drive itself honors, per the machine's risk assessment.

Example: how far do stray pulse counts move a 5 mm-lead screw? #

Distance per stray count is small, and it compounds: on a 1.8-degree motor at 200 full steps per revolution driving a 5 mm-lead screw directly, thirty stray counts move the screw 0.75 mm.

Every input here is assumed for the calculation; none comes from the reported machine:

  • Counts per revolution: 200 (a 1.8-degree stepper at full-step equivalent).
  • Screw lead: 5 mm, directly coupled, no reduction.
  • Stray counts during the exposed window: 30.

Revolutions moved = 30 counts ÷ 200 counts per revolution = 0.15 revolutions. Distance = 0.15 revolutions × 5 mm per revolution = 0.75 mm.

Scale the answer with the real settings: at a 2,000 counts-per-revolution microstepping setting the same stray-count burst moves 0.075 mm, and a 2:1 belt or gearbox between motor and screw divides it again. The example stops at a fixed count on purpose — noise that toggles continuously accumulates distance until the drive trips its position error, and the following-error window that sets that limit is a drive-manual number this example does not carry. Treat the result as a calculated illustration for these assumed inputs, not a measurement.

How do I verify the sequencing fix start after start? #

Verify by repetition and measurement, not by one good session: the reported machine went from roughly one runaway in ten cold starts to none, and every check below must pass on every start before you trust the sequence.

  1. Relay open and controller unconfigured: measure each drive's enable input and confirm no drive is enabled.
  2. Boot the controller and run the initialization program: confirm the relay closes only after the last axis is configured and zeroed.
  3. Disable a monitored axis: confirm the watchenable loop drops the relay.
  4. Close every polling application, or power the PC off: confirm the status-request watchdog drops the relay.
  5. With the controller still powered, remove and restore drive power: confirm the drives cannot come back enabled without a deliberate new enable.
  6. Repeat cold starts until the count means something: the fault showed about once in ten starts on the reported machine, so a dozen consecutive clean starts is the minimum evidence, and more is better.

The decision: motion at drive energization, before any software loads, is an enable-sequencing fault — configure first, enable the drives last under controller control, and watchdog that enable against both axis state and lost status polling. The reported machine made exactly that change and the startup runaway was solved. Motion that appears during a commanded move, mid-cycle or during tuning follows different fault paths, and the articles on those symptoms are the ones to open next.

Questions asked

Can the PC dump stored pulses into a drive at controller power-up?

No path exists. The reported pattern of failing more often after the PC sat on between sessions reflects startup order and timing, not data. Test warm and cold PC starts the same way, because the vulnerable window is identical.

Is the bit number in SetBit(155) a standard for drive-enable relays?

No. In the reported installation the drives were wired so SetBit(155) controlled the enable relay, and 152 appeared in a Kanalog example as FET Switch #0; both numbers belong to that wiring and that board. Map your own FET switch to its output bit from the board documentation, label the relay, and confirm the pairing with a meter before using either number on another machine.

Does microstepping change how far noise pulses move the axis?

Yes, in proportion. The example used 200 full steps per revolution; at a 2,000 counts-per-revolution microstepping setting, the same thirty stray counts move a 5 mm-lead screw only 0.075 mm instead of 0.75 mm. Take the counts-per-revolution value from the drive's own configuration, divide by any gear or belt reduction, and use that number in the distance formula.

Should limit switches be wired to the drives as well as the controller?

Where the drives accept them and the machine's risk assessment calls for it, yes. In one reported runaway the motor did not stop until it reached a limit switch, so the hardware limit ended motion the software could not. Software sequencing prevents the unwanted start; a limit or stop function wired where the drive itself honors it limits the travel when anything else goes wrong. Select those functions per the risk assessment and the applicable machinery safety standard.

What if a runaway still happens after enable sequencing?

Then the drive is being commanded or disturbed while enabled, and the checks move upstream: capture the pulse lines with a scope or logic analyzer across a cold start, verify shield termination and ground bonding on the pulse wiring, and read the drive's fault and position registers immediately after each event. A captured waveform during a failure is the only evidence that separates input noise from a drive-side position mechanism, and no such capture was ever made on the reported machine.

Keep reading

  • Troubleshooting

    Fixing a Stepper Power-Up Timeout on an EtherCAT Axis

    The drive is healthy: it reaches run mode with no alarm while the motion runtime errors, because the CiA 402 handshake finishes after the master's power-on supervision time expires. Log statusword 0x6041 during a power attempt; bit 2 setting late with bit 3 clear means a timeout. Raise the supervision time or update the runtime — the wiring is not the fault.

    Servo and stepper motion

  • Troubleshooting

    Why a Closed Loop Stepper Will Not Move Above 200 kHz

    The axis sits dead because the kernel exceeds the drive's documented step input limit, making each high or low state narrower than the input can latch. Set the kernel to half the ceiling, derive steps per mm from the drive's command resolution divided by the screw's travel per revolution, and verify the encoder A-channel polarity at the drive terminals.

    Servo and stepper motion

  • How-to

    Tuning a Pulse-and-Direction Stepper in Closed Loop

    Tune a pulse-and-direction stepper in closed loop with ramped trajectories and a small step amplitude, not the textbook half-revolution position step. The first-cycle demand is gain × step size, not the average over the step time, so a 5000-count step stalls while 2100 counts at Ixx30 = 35 moves. Raise Ixx30 only until rise time stops improving, and leave Ixx68 at 0 or 1.

    Servo and stepper motion

Stepper rail binary position selection: one writer, all bits