PID Tuning

From RepRap
Revision as of 04:46, 21 January 2014 by XoanSampaiño (talk | contribs) (Fix typo)
Jump to: navigation, search

PID tuning refers to a proportional-integral-derivative control algorithm used in some repraps for hot ends and heated beds.

PID needs to have a P, I and D value defined to control the nozzle temperature. If the temperature ramps up quickly and slows as it approaches the target temperature, or if it swings by a few degrees either side of the target temperature, then the values are incorrect.

To run PID Autotune in Marlin and other firmares, run the following gcode with the nozzle cold:

 M303 S175 C8

This will heat the nozzle, and cycle around the target temperature 8 times (C8) at the given temperature (S175) and return 3 values for P I and D.

These values can be entered with:

 M301 P1 I2 D3 

If the EEPROM is enabled, save with M500. If it is not enabled, save these settings in Configuration.h.

For the bed, use:

 Bed: M303 E-1 S60 C8 

and save bed settings with:

 M304 P1 I2 D3 

For manual adjustments:

  • if it overshoots a lot and oscillates, either the integral gain needs to be increased or all gains should be reduced
  • Too much overshoot? Increase D, decrease P.
  • Response too damped? Increase P.
  • Ramps up quickly to a value below target temperature (0-160 fast) and then slows down as it approaches target (160-170 slow, 170-180 really slow, etc) temperature? Try increasing the I constant.


A good article on PID tuning is here

See also Wikipedia's PID_controller and Zeigler-Nichols tuning method. Marlin autotuning (2014-01-20, https://github.com/ErikZalm/Marlin/blob/Marlin_v1/Marlin/temperature.cpp#L250 ) uses the Ziegler-Nichols 'Classic' method, which first finds a gain which maximizes the oscillations around the setpoint, and uses the amplitude and period of these oscillations to set the proportional, integral, and derivative terms.