How-to
Tuning a Pulse-and-Direction Stepper in Closed Loop
Short answer
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.
On this page
- Why the position-step test behaves differently here
- Before you touch the gains
- Set the step amplitude before the gain
- Worked example: sizing the step test on a 10,000-count-per-revolution axis
- Tuning the position gains (Ixx30, Ixx31, Ixx33)
- Tuning the velocity gains (Ixx32, Ixx35)
- Setting Ixx68 feedforward
- When motion is lost during a test
- Questions asked
Tune this axis with ramped trajectories and a small step amplitude, and use the position-step test only as a check, not as a gain search. The loop structure is a normal servo loop, but its output is a pulse frequency, so the classic rules change: a 5000-count step in a 500 ms window averages 10 counts/ms, while the first servo cycle demands a rate set by gain × amplitude, far above that average. A stepper asked to start above its start rate stalls, energized, with the tone you heard. That is why the motor moved at Ixx30 = 35 with a 2100-count step, stood still with the default step at lower gains, and never oscillated about position like a torque-driven servo.
Why the position-step test behaves differently here #
Servo tuning lore - step the position half a revolution, raise the proportional gain until the motor oscillates, back off - assumes an amplifier that turns loop output into torque. A pulse-and-direction output turns loop output into frequency: the controller emits pulses at the rate the loop demands, and the drive steps the motor at that rate.
Two things follow. First, there is no oscillation to find. The motor tracks the commanded frequency with its own synchronizing torque, so as you raise Ixx30 the rise time shortens and the steady-state error shrinks - exactly what you observed - until the demand exceeds what the motor can follow. Second, there is a hard ceiling instead. Available torque falls as step frequency rises, and from standstill a stepper can only start below its start-stop rate. When gain × error demands more than that, the rotor never synchronizes: the motor sits still while energized and emits a tone at the commanded switching frequency for the duration of the move. The tone is a stall signature, not instability.
There is also a floor. If the demanded rate is too low to emit a pulse every servo cycle, the output rounds to nothing and the axis does not move at all - which is why no motion appeared until the gain reached the mid-30s.
Before you touch the gains #
- Establish a mechanically safe travel range and keep the controller's following-error and fault protections active. A stalled stepper holds full winding current, so keep the drive's disable within reach and let a stalled motor cool before you touch it.
- Record the controller configuration before changing anything, with access to commanded position, actual position, following-error and loop-output traces.
- Verify the feedback scale with a measured move. This axis reports 5000 encoder counts per half revolution, so 10,000 counts per motor revolution; the same scale and sign checks used when tuning a closed-loop stepper with linear scale feedback confirm the number against the transmission.
- Verify direction in both directions and inspect the actual-position trace for lost counts or direction-dependent offsets. Linear feedback measures the load, so backlash, compliance and coupling slip appear inside the loop directly.
- Confirm the drive's pulse interface matches the controller's output mode, and check the documented minimum pulse width and direction setup time - one closed-loop stepper driver family specifies 5 μs.
- Confirm the drive is enabled and not faulted during a low-demand move. A drive with no encoder input runs the motor open loop no matter what the controller does; whether an encoder makes a stepper motor closed loop separates the two architectures.
Set the step amplitude before the gain #
The tuning application's amplitude guidance - half to a quarter of a motor revolution - is written for a torque-source servo, whose amplifier saturates instead of commanding an impossible speed. A frequency source can command that speed. Half a revolution on this axis is 5000 counts, and that step produced no motion at the default gains, while roughly two tenths of a revolution moved. Treat amplitude as the first tuning variable, ahead of any gain.
Also check what the tool's step-time entry means on your commanded-position trace: if the trace jumps instantaneously, the move is a true step and the entry is only the observation window, not an acceleration ramp. A rule of thumb that works here: start at one tenth of the suggested amplitude and double it; the last amplitude that still moves the motor is your tuning step.
Worked example: sizing the step test on a 10,000-count-per-revolution axis #
Inputs. Feedback scale: 10,000 encoder counts per motor revolution, derived on this axis from 5000 counts per half revolution and confirmed with a measured move. Tuning tool defaults: a 5000-count step over a 500 ms window. Working point that moved: a 2100-count step at Ixx30 = 35. Proven jog speed: 50 counts/ms, reached by a controlled ramp.
Rule. On a pulse-rate output, the demand in the first servo cycle after a step is proportional to Ixx30 × step amplitude. The step time sets only the average rate and does not limit the initial demand.
Arithmetic.
- Average rate of the default step: 5000 counts ÷ 500 ms = 10 counts/ms.
- Average rate of the working step: 2100 counts ÷ 500 ms = 4.2 counts/ms.
- First-cycle proportional output at the working gain: 35 × 2100 = 73,500 output counts.
- The same gain with the default step: 35 × 5000 = 175,000 output counts, which is 175,000 ÷ 73,500 = 2.38 times the initial pulse-rate demand.
- Travel of the working step: 2100 ÷ 10,000 = 0.21 revolution.
Result. Both averages sit far below the 50 counts/ms jog speed, yet the motor stalled on the 5000-count step and moved on the 2100-count one. The average rate is not the governing number; the initial demand is. This is a calculated example for these inputs, not a measured motor rating.
Decision. Keep the product gain × step at or below the value already proven to move this axis - 35 × 2100 = 73,500 output counts. Anything larger belongs on a ramped trajectory, not a position step. When the motor stalls or tones during a step, cut the amplitude first and do not raise Ixx30 further.
Tuning the position gains (Ixx30, Ixx31, Ixx33) #
- Set the step amplitude to the value established in the worked example.
- Raise Ixx30 from a low value in small increments. Motion begins once the output generates a pulse in every servo cycle; below that floor the axis sits still.
- Watch rise time and steady-state error on the actual-position trace, and keep raising while both improve.
- Stop at the last value where the rise time still improved. The stall-and-tone point above it is a ceiling, not a target; the working gain sits between the pulse-generation floor and that ceiling.
- Add Ixx31 and Ixx33 only as needed to settle the response. A rate-driven stepper rarely overshoots, so expect small values, and verify with repeated steps in both directions.
Tuning the velocity gains (Ixx32, Ixx35) #
- Use the Parabolic Velocity trajectory for these terms: it ramps the commanded speed, so the motor accelerates through its torque curve instead of being asked to start at full rate, and it behaves like the servo the setup documentation describes.
- Raise each of Ixx32 and Ixx35 in turn until the following error during the ramp stops shrinking and the response settles on target without overshoot.
- Confirm the following error at working speed stays inside the fault limit you set in the safety checks, in both directions of travel.
Setting Ixx68 feedforward #
On a pulse-and-direction axis, set Ixx68 to 0 or 1 and leave it there. On this axis, 1 helped slightly; anything higher made the following error an inverted copy of the commanded velocity and destabilized the loop, far below the parameter's documented 0 to 32767 range. The mechanism is the same one that governs everything else here: with a rate output, velocity feedforward adds commanded speed straight into the output, so any mismatch between the feedforward scale and the drive's pulses-per-revolution setting injects error instead of cancelling it. If cruise following error matters, fix that scaling match rather than raising the gain.
When motion is lost during a test #
- Commanded position does not change: the output is limited, inhibited or misconfigured. Check output configuration and enable conditions before anything else.
- Commanded position changes, no pulses reach the drive and the drive is not enabled: clear the drive fault and its underlying cause.
- Pulses reach the drive, the encoder is silent and the motor makes no sound: suspect mechanical restraint or pulse timing outside the drive's specification. Run a bounded low-demand move and read drive status.
- Pulses reach the drive and the motor emits a tone without rotating: a start-rate stall. Reduce gain × step below the proven product.
- The motor rotates but linear position barely changes: lost motion in the transmission. The linear scale reports it directly, so check the coupling and the drive train between motor and load.
Questions asked
Why does the stepper hum without moving when I raise Ixx30?
The hum is the drive switching at the demanded pulse frequency while the rotor, asked to start above its start-stop rate from standstill, never synchronizes. That is a stall, not instability. Torque available from a stepper falls as pulse frequency rises, so a first-cycle demand above the start rate cannot accelerate the rotor. Reduce the step amplitude or the gain; raising the gain further only deepens the stall.
Does a linear encoder change how I set the step size?
Only through the counts. The loop works in encoder counts, so convert the recommended fraction of a revolution using your counts per revolution. On this axis that scale is 10,000 counts per revolution, which makes the 2100-count step 0.21 revolution. Confirm the scale with a measured move, and remember that a linear scale puts transmission backlash inside the loop, so check both directions of travel.
Should I use Ixx68 feedforward on a pulse-and-direction axis?
Set it to 1 at most. With the loop output a pulse rate, velocity feedforward adds commanded speed directly to the output, so a mismatch against the drive's pulses-per-revolution setting turns the following error into an inverted copy of the commanded velocity. That is the destabilization seen long before the documented 0 to 32767 range was exhausted. Correct the scaling match instead of raising the gain.
Is the position-step test wrong for steppers, or just different?
Keep it, but as a verification at small amplitude. On this axis it produced a stable working point once the step was cut to 2100 counts. The half-revolution default assumes a torque-source servo, whose amplifier saturates instead of commanding an impossible speed. A frequency source will happily command that speed, so amplitude, not gain, becomes the limiting variable.