AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

Troubleshooting

Why a Windows parallel port stepper pulse train pauses and shakes

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

Short answer

At a 1500 µs interval (666.7 pps) the irregular pauses in a Windows parallel-port stepper pulse train are operating-system scheduling jitter in a user-mode pulse loop. An explicit pulse high time, absolute-deadline scheduling and realtime priority on a pinned core shrink the pauses but never bound them. Bounding them takes hardware that generates the step edges — a counter output, indexer, motion controller or timer-driven microcontroller — with the PC sending rate and count.

On this page
  1. Worked example: a 0.72° motor stepped every 1500 µs
  2. Separate the causes with the cheapest check first
  3. Software changes that shrink the pauses but cannot bound them
  4. The pulse width the two-write pattern does not control
  5. Moving the step edges into hardware
  6. The decision for each case
  7. Questions asked

A stepper axis driven from a parallel port that turns smoothly and then stops for a beat at irregular moments is being paused by the operating system, not by the driver or the motor. At a 1500 µs interval the loop commands 666.7 steps per second; whenever the Windows scheduler delays the thread that toggles the port, the driver receives no step for that slot, the rotor settles toward its last commanded position, and the resumed burst arrives as a jolt — the pause-and-shake. Priority boosts and better delay calls shrink the pauses but cannot bound them, because a user-mode thread on a desktop OS carries no timing guarantee. The fix that stops the shaking is architectural: put hardware that generates the step edges between the PC and the driver, and let the PC send only the rate and the step count.

Worked example: a 0.72° motor stepped every 1500 µs #

Inputs, and where each comes from:

  • Interval between step pulses: 1500 µs — the delay at the end of each pass of the pulse loop as written.
  • Step angle: 0.72° per full step, the rating of the five-phase motor in this case.
  • Move length: 10 cycles of 500 steps, 5000 pulses per move, from the loop bounds.

The rules, in words: the step rate is one divided by the interval; the steps per revolution are 360° divided by the step angle; the shaft speed is the step rate divided by the steps per revolution.

The arithmetic:

  • Step rate: 1 ÷ 1500 µs = 1 ÷ 0.0015 s = 666.7 pulses per second.
  • Steps per revolution: 360° ÷ 0.72° = 500 steps.
  • Shaft speed: 666.7 pps ÷ 500 steps per revolution = 1.333 rev/s; 1.333 × 60 = 80.0 rpm.

Result: the loop paces the shaft at 80 rpm with no ramp, 5000 pulses per move. These are calculated values for these inputs, not measured ones.

The decision: the number that decides this case is the worst-case interval, not the average. Log the gap between consecutive step writes, motor disconnected, with a high-resolution counter. A maximum near the commanded interval means the timing is clean and the hunt moves to the wiring and the driver's pulse-input mode. A maximum of 3000 µs or more — two slots back to back — means at least one step slot went out empty: the 80 rpm rotor settled toward the last commanded position and the resumed train restarted it. That is the pause-and-shake, and it is a scheduling gap, not a motor fault.

Separate the causes with the cheapest check first #

The symptom — smooth rotation interrupted by short, irregular pauses — does not name a cause on its own. Work down the table; every check except the scope work costs nothing but a little code or a look at the driver.

Observed Likely cause, cheapest first Confirming check
Smooth rotation, then short irregular pauses with a small shake Scheduler jitter in the user-mode pulse loop Log the time between consecutive step writes with a counter such as QueryPerformanceCounter, motor disconnected; read the maximum interval, not the mean
Pauses shrink at realtime priority but never disappear Residual preemption from interrupts and drivers Same log, normal priority against realtime; compare the maximum intervals
Pauses multiply when all four axes run together Four pulse loops competing for the same cores Log one axis, then four; compare the maximum intervals
Position comes up short after the 5000-pulse move while intervals read steady Pulse high or low width below the driver's minimum, or a pulse-input mode different from the code's assumption Scope the pulse input and compare both widths against the driver's time chart; confirm the mode setting on the driver itself
Stalls instead of pauses near the fastest commanded speed Motor worked into its pull-in region with no ramp Take the pull-in and pull-out limits from the torque-speed curves in the motor's datasheet

The first row is the one this case points to. The last two rows are the faults that would still be there after the scheduler is removed.

Software changes that shrink the pauses but cannot bound them #

Each of these removes one contributor and leaves the desktop scheduler in the pulse path:

  • Write the pulse width explicitly. Drive the line HIGH, wait a deliberate high time, then drive it LOW. Size that high time from the minimum pulse HIGH width in the driver's input time chart, and prefer a counter-based wait over a sleep, which adds another quantized delay.
  • Schedule against absolute deadlines. Keep a target time, add the commanded interval after every step, and wait until the counter reaches that target, so one late step stops shifting every step after it.
  • Pin the pulse thread to one core and raise it to realtime priority. This improves the train and never cleans it, because interrupts and drivers still preempt the loop. A realtime spin loop can starve everything else on the PC, so give it a core that does nothing else and keep a stopping point for the axis that does not depend on that PC responding.
  • Shorten the delay argument to run faster than the current pace. If the measured interval stops shrinking, the delay routine has hit its resolution floor and the argument is no longer the limiting quantity — measure the interval, never trust the argument alone.
  • Test with DOS on a bare machine. No scheduler means deterministic timing; it works, and it ties the cell to legacy hardware and legacy port access.

The absolute-deadline pattern in code, with illustrative names for the counter and port calls:

/* Illustrative absolute-deadline pattern for one axis, not a tested program */
uint64_t next = counter_now();        /* snapshot of the high-resolution counter, ticks */
uint64_t slot = one_interval_ticks;   /* commanded interval expressed in counter ticks */
uint64_t high = one_high_time_ticks;  /* pulse high time from the driver time chart, ticks */

for (uint64_t i = 0; i != total_steps; i++) {
    port_write(HIGH_LEVEL);
    spin_until(next + high);
    port_write(LOW_LEVEL);
    next = next + slot;               /* the deadline advances by exactly one slot */
    spin_until(next);
}

QueryPerformanceCounter is the documented high-resolution counter on Windows; direct port writes from a user-mode program on NT-based Windows go through a kernel-mode port driver, so even the write itself crosses a layer the scheduler can slow. Run the interval log again after these changes: the average and the typical maximum drop, and the log — not the feel of the shaft — is the proof. None of these changes bounds the worst case.

The pulse width the two-write pattern does not control #

Writing the port HIGH and immediately LOW in two back-to-back calls produces a pulse only as wide as the gap between those two writes. The CPU and the bus set that width; nothing in the code does. It still has to clear the minimum pulse HIGH and LOW widths in the driver's input time chart — the chart that defines the acceptance window for every pulse — so read both limits from the input pulse specification in the MD5-MF14 manual rather than from the code's assumptions. A pulse narrower than the documented minimum is ignored or misread by the drive input; the same failure is documented in why a 150 ns pulse high time fails a servo drive input. The signature differs from a scheduler gap: a width problem loses steps while the logged intervals read steady, while a scheduler gap shows in the log itself.

While the cover is off, compare the port's output level and drive capability against the driver's input circuit rating in the same manual, and remember that a single data-port write drives every data line at once — give each driver its own line and hold the unused lines low in the mask, or four axes step together.

Confirm the driver's pulse-input mode as well. The code pulses one line, labeled CW, which matches two-pulse CW/CCW operation with the CCW line held inactive. If the driver is set to one-pulse-plus-direction instead, that lone line follows different rules and the motion stops matching the commands — the mismatch described in why a servo pulse input mode mismatch causes motion without rotation. Check the mode at the driver before changing any code.

Moving the step edges into hardware #

A train that never pauses needs its edges from hardware, with software setting only the rate and the count; the scheduler then has no say in the pulse path. Options that fit this driver set:

  • Counter output on a DAQ device. A hardware counter toggles the output line; the PC programs the rate and the pulse count and can queue the next move while the current one runs.
  • A dedicated pulse generator, indexer or motion controller. These accept a rate and a step count and add acceleration ramps; a controller velocity command converted to step and direction signals is the standard shape of that interface, as in driving step and direction inputs from a controller velocity output.
  • A microcontroller with a timer-driven output. One timer channel per axis, with the PC sending rate and count over a serial link. Build it after reading why a timer-driven stepper pulse train delivers the wrong step count; the counting side has its own pitfall.
  • DOS on the existing machine, when no new hardware is allowed: a bare-metal loop with no scheduler gives deterministic timing, bound to that one machine.

Underneath all four sits the same rule as in why a PLC digital output cannot make a stepper pulse train: whatever generates the edges must be able to guarantee their timing.

The decision for each case #

  • If a hiccup of one or two slots is invisible to the process — a metering feed, a transfer conveyor — keep the Windows loop with the software changes above: explicit high time, absolute-deadline scheduling, realtime priority pinned to one core. The pauses shrink; accept that they remain.
  • If the shake matters — a positioned load, a fixture that can be nudged out of place, a mark left on a surface — move step generation into hardware now, one timer or counter channel per axis between the PC and the driver. No software setting bounds the worst-case interval, so tuning cannot be the fix.
  • If no new hardware is allowed and the machine boots DOS bare, that is a deterministic path on that machine and only that machine.

Confirm the result with the measurement that convicted the software: log or scope the intervals at the driver input after the change. The maximum should sit within the timer's own resolution of the commanded interval, and the shake should be gone, not smaller.

Questions asked

Can any Windows setting make a user-mode pulse loop deterministic?

No standard Windows setting does. Realtime priority and a pinned core reduce how often the scheduler interrupts the loop, and absolute-deadline scheduling keeps one late step from shifting every step after it, but interrupts and drivers can still stretch any interval by any amount. The operating system gives a user-mode thread no worst-case timing guarantee, which is why the pauses shrink and never disappear.

Do the pauses get worse at higher step rates?

Yes. The scheduling delays behind the pauses do not scale with the commanded rate, so their damage grows as the interval shrinks: a hiccup that costs one step slot at a slow pace costs several at a fast one. Steps lost near the motor's pull-in speed show up as stalls rather than shakes, so leave headroom below the pull-in region or ramp the moves in whichever pulse source you choose.

What high time should the explicit pulse-width wait use?

Take it from the input pulse time chart in the driver's manual, not from the code's assumptions: choose a high time comfortably above the documented minimum pulse HIGH width, keep the LOW width above its own minimum, and confirm the real widths with a scope on the driver's pulse input lines. Re-check the chart whenever the driver model or its input circuit changes.

Can four axes share one Windows pulse loop?

Not cleanly. Four loops spin on the same cores and preempt one another, so the worst interval grows when all axes run together. The hardware fix covers this too: one timer or counter channel per axis, with the PC sending each axis its own rate and step count. If a software trial is unavoidable, log intervals for one axis and then for all four, and compare the maximums.

Is the 666.7 pps ceiling a motor limit?

No. That ceiling came from the loop's own delay call, not from the motor. The motor's pull-out curve sets how fast it can follow a steady train, and its pull-in region sets how fast it can start or restart; a jittery train effectively restarts the axis, so keep the working pace below those curve limits or add ramping in whichever pulse source you choose. Read both curves from the datasheet for the exact five-phase model.

Keep reading

  • Explainer

    Why a PLC digital output cannot make a stepper pulse train

    An ordinary PLC digital output switched by scan logic cannot produce a steady 2 kHz step pulse train: each pulse is just 500 microseconds wide at that rate, and scan-time jitter becomes pulse-timing error the driver counts as lost or extra steps. Feed the driver's step and direction inputs from a dedicated pulse-output channel, and set shaft speed from pulses per revolution.

    Servo and stepper motion

  • Comparison

    A step and direction servo drive versus an open-loop stepper

    A step and direction servo drive takes the same pulse train as an open-loop stepper drive but closes the position loop inside the drive on the motor's encoder counts, so lost steps become a following-error fault instead of silent drift. The deciding arithmetic is the pulse budget: steps per inch times feed gives the steps per second your controller must supply, and a high-count encoder can exhaust that budget before the motor runs out of torque.

    Servo and stepper motion

  • How-to

    Why a pseudo closed loop stepper counts endlessly

    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.

    Servo and stepper motion

Why a Mach3 parallel port PCI card outputs no step pulses