Main /
PID Tuning
Key Notes
This covers tuning the PID parameters for use with stepper motors. The automatic method is shown first as it is recommended to use. For background, see this Wikipedia article on PID controllers.
Common Tuning Issues
- High following error: increase P or use feedforward terms
- Hunting or oscillation: add D or reduce P/I values
- Error spikes: reconsider all 3 terms, observe system with a scope, and test combinations.
Automatic PID Tuning Steps
For these actions, N is the axis to be tuned.
- Move the axis near the center of travel using either jogging or a Gcode command.
- Set tune-effort to a small value and increase as needed. Open a command prompt and then enter this HAL command:
| halcmd setp pid.N.tune-effort 0.1 |
- Enable tune-mode and set tune-start to true. Open a command prompt and then enter these HAL commands:
|
halcmd setp pid.N.tune-mode 1 |
- The process generates a square wave for system analysis and determines optimal PID settings.
- After tuning completes, compare the results, and test accuracy.
The pins to observe in HALMeter are:
- pid.N.Pgain
- pid.N.Igain
- pid.N.Dgain
- pid.N.FF0
- pid.N.FF1
- pid.N.FF2
- pid.N.FF3
Re-enable control, open a command prompt and then enter this HAL command:
| halcmd setp pid.N.tune-mode 0 |
Once those numbers have been obtained, you can use them to manually adjust from there.
Manual PID Tuning Steps
- Begin with very low values for all three gains:
- P (Proportional): Gradually increase P gain until the system starts to oscillate, then back off slightly for stability.
- I (Integral): Introduce I gain to reduce steady-state error, but too much can lead to instability.
- D (Derivative): Add D gain to dampen oscillations and improve responsiveness.
- Optionally adjust feedforward to further reduce error.
- FF0 (0th order feedforward gain).
- For position loops, it should usually be left at zero.
- For velocity loops, FF0 can compensate for friction or motor counter-EMF and may permit better tuning if used properly.
- FF1 (1st order feedforward gain) - affects Velocity.
- For position loops, the contribution is proportional to speed, and can be used to compensate for friction or motor CEMF.
- For velocity loops, it is proportional to acceleration and can compensate for inertia.
- FF2 (2nd order feedforward gain) - affects Acceleration.
- For position loops, the contribution is proportional to acceleration, and can be used to compensate for inertia.
- For velocity loops, the contribution is proportional to jerk, and should usually be left at zero.
- FF3 (3rd order feedforward gain)
- For position loops, the contribution is proportional to jerk, and can be used to compensate for residual errors during acceleration.
- For velocity loops, the contribution is proportional to snap(jounce), and should usually be left at zero.
- FF0 (0th order feedforward gain).
Additional Resources
Websites
LinuxCNC Manual
LinuxCNC Forum
Other
Videos
- PID tuning linuxcnc Chinese servos (YouTube video)
| spacer line |
|
eMail comments to |
