Tuning
foci-tune measures how an axis actually responds to motor commands and helps you pick the position and speed control gains for your specific motor and mechanics. It is a service on the Pi with a browser UI. Tune each axis once after Bring-up, before printing. If foci-tune is not installed yet, see Installation.
Before you tune
Section titled “Before you tune”- Run
FOCI_SETUPfor the axis (from Bring-up). foci-tune refuses to run an axis that has no identified electrical model. - Home the printer. X, Y and Z must all be homed. Use the Home button
in the UI or run
G28. - No print can be active.
Open the UI
Section titled “Open the UI”Open http://<pi-address>:7130 in a browser. The sidebar has three
pages: Printer, Tune and Sessions. Under Tune, choose
Guided.
Tune an axis
Section titled “Tune an axis”The guided tune has five steps, shown across the top: Setup, Velocity P, Velocity I, Position P and Result. You can open any step you have reached.
- Setup. Choose the stepper and the test speeds. foci-tune lowers
any speed that would take the path past Klipper’s
max_velocity. The UI proposes a stroke for you in the Path card: a 100 mm stroke centered on the bed. On CoreXY it runs diagonally, so the stroke isolates the one motor you picked. Click Next to create the tune. - Velocity P, Velocity I, Position P. Each step tries a series of gains around the current value, one after another, and measures how well the axis follows each one. Before a step runs, the card shows the sweep: the starting value, how many repeats, the step size and the lowest and highest gain. Click Run to start it. A table fills in as the runs finish, with a status for each gain.
- Choose a gain. When a step finishes, the UI recommends a gain. Click Accept to take it. The arrow next to Accept lets you pick any measured gain instead, or enter a value. The chosen gain is applied to the axis, and the next step starts from it. If the best gain is at the edge of the range, you can try a lower or higher gain.
- Result. The last step shows the three chosen gains before and
after, and a Printer config card with the
[foci <stepper>]block.
A step can pause when it needs your decision, for example when the damping of a gain could not be measured. The pause card shows the evidence. Stop ends the step, Rerun repeats the gain and Continue carries on. Abandon tune puts the axis back on the gains it had when the tune started.
Run the tune once per axis. For the other axis, click New tune.
Apply the result
Section titled “Apply the result”The gains foci-tune applies are live only. Homing or a restart loads the
gains from printer.cfg again. To keep the result, paste the block from
the Printer config card (use the copy button) into the matching
[foci <stepper>] section of printer.cfg:
[foci stepper_x]pid_velocity_p: <raw value>pid_velocity_i: <raw value>pid_position_p: <raw value>pid_position_i: <raw value>velocity_filter_hz: <Hz>torque_filter_hz: <Hz>position_filter_hz: <Hz>flux_filter_hz: <Hz>The card shows the real values. Replace any lines that already exist rather than adding a second copy.
FOCI_SETUP already wrote these four gain keys (they sit in the
SAVE_CONFIG block at the bottom of printer.cfg), so the pasted values
replace them. Nothing else needs to change. Save the file and run
RESTART, and FOCI runs the axis on the pasted gains from then on.
Running FOCI_SETUP again replaces them with its own values. See
Config Reference for every field.
Set each option in one place only. If Klipper reports that a
SAVE_CONFIG value conflicts with an included value, the option is set
both in the SAVE_CONFIG block and elsewhere. Keep one copy and
restart.
The UI keeps every tune under Sessions. The files are in the
foci-results folder of Moonraker’s config root.
Validate the result
Section titled “Validate the result”foci-tune checks how each motor responds on its own. It does not run print-like paths, so a finished tune doesn’t prove your printer moves well at the speeds and accelerations you actually print at. Check that before trusting it.
Validate with the gains live, before you paste them into printer.cfg.
If the result is bad, RESTART loads the gains from printer.cfg again
and you’re back to where you started.
1. Full-speed moves, both directions
Section titled “1. Full-speed moves, both directions”Home, then run full-travel moves on each axis at your print speed, in both directions. Repeat each move several times, back and forth:
G28G90G1 X<min> F<speed, mm/min>G1 X<max> F<speed, mm/min>G1 Y<min> F<speed, mm/min>G1 Y<max> F<speed, mm/min>On CoreXY, also run diagonal moves, from X<min> Y<min> to
X<max> Y<max> and between the other two corners. Pure X and Y moves
drive both motors together, but each diagonal is driven by only one
motor, so a weak axis can hide until you run one.
Step up rather than starting at the target: run everything once at about half your speed and acceleration, then at your target, then once at 10 to 20% above it. The last pass tells you how much margin you have.
2. What to look for
Section titled “2. What to look for”- Sound. Smooth motion, and quiet when holding position. A buzz at rest, or a tone during moves that wasn’t there at half speed, means gains that are too high. See Troubleshooting.
- Endpoints. The toolhead stops cleanly at each end with no bounce, overshoot, or slow creep into position.
- Errors. No
Timer too close, stall, or motor-fault messages in the console during any pass. Afterwards, runDUMP_FOCI STEPPER=<stepper>, which only reads state, and look for stall or fault flags.
If a pass fails, don’t keep the result. Lower the affected gains by 10 to 20%, as described under Manual tuning, or tune the axis again.
3. Keep the result
Section titled “3. Keep the result”Once the moves pass, paste the block into printer.cfg and restart, as
described under Apply the result. If buzzing or a
loose stop shows up later, after a long print, lower pid_position_p
a little rather than re-tuning.
4. Other checks
Section titled “4. Other checks”- Print a ringing tower with your usual settings. Look for rounded corners, ringing, and dimension errors.
- Re-run input shaper calibration. Tuning changes axis stiffness,
which moves the resonance frequencies. Run
SHAPER_CALIBRATE, or your usual routine, again and save the new shaper values. - Re-tune after mechanical changes. Tune again after changing
belts or belt tension, toolhead weight,
run_current, or the motor.