PID Tuning: Stabilize Nozzle and Bed Temperature

the3dfix 3 min read
Contents
  1. When do you need it?
  2. Consequences of temperature fluctuation
  3. Before you start
  4. PID tuning the nozzle in Marlin
  5. PID tuning the bed in Marlin
  6. PID tuning in Klipper
  7. Check the result
  8. If PID does not fix it, check the hardware
  9. Frequently asked questions
A temperature curve graph that first fluctuates and then settles on the target line

If the nozzle temperature on screen keeps swinging between 207 and 213 instead of holding 210 °C, the settings that control the heater do not suit your printer. The printer does this control with a method called PID and needs three coefficients. These coefficients vary with the hotend, the fan and the environment. Luckily the printer can measure them itself; all you do is start the process with one command.

When do you need it?

  • When the nozzle or bed temperature on screen swings more than ±2 °C around the target.
  • After replacing the hotend, heater cartridge, thermistor or nozzle.
  • When a silicone sock is fitted to or removed from the hotend.
  • When the part cooling fan is replaced or the duct is redesigned.
  • When you move the printer into a closed enclosure.
  • If you get a "thermal runaway" or "heating failed" error while heating (check the hardware first, see below).

Consequences of temperature fluctuation

  • If the nozzle temperature fluctuates, the amount of extrusion changes and uneven bands appear on the surface.
  • If the bed temperature fluctuates, the bed expands and contracts and Z banding can appear.
  • Excessive swings can trigger the thermal safety protection and stop the print.

Before you start

  • Run the printer under normal printing conditions: the same room, with the enclosure closed if you print with it closed.
  • Clean the nozzle.
  • Make sure the cable connections are solid. A loose thermistor cable causes sudden jumps that PID cannot fix.

PID tuning the nozzle in Marlin

  1. Connect to the printer through a terminal (screen menu, OctoPrint console or Pronterface).
  2. Turn the part cooling fan on at the speed you use while printing. For example M106 S255 (100%). Because the fan cools the hotend, tuning with the fan on gives a more realistic result.
  3. Send this command:
M303 E0 S210 C8 U1
  • E0: The first hotend.
  • S210: Target temperature. Enter the temperature you print at most.
  • C8: Eight heating-cooling cycles.
  • U1: Applies the found values automatically. If your older Marlin version does not have this option, note the Kp, Ki, Kd values in the output and apply them by hand with M301 P... I... D....
  1. The process takes a few minutes. During this the nozzle temperature rises and falls around the target several times.
  2. Save the values:
M500

PID tuning the bed in Marlin

If bed PID control is enabled in the firmware:

M303 E-1 S60 C8 U1
M500

E-1 selects the bed. For the target temperature, enter the bed temperature you use most. The process takes longer because the bed has to heat.

On some firmware the bed runs in "bang-bang" (on-off) mode and PID is off. In that case you need to recompile the firmware to turn on bed PID.

PID tuning in Klipper

PID_CALIBRATE HEATER=extruder TARGET=210

For the bed:

PID_CALIBRATE HEATER=heater_bed TARGET=60

When it finishes, save the result with:

SAVE_CONFIG

Klipper restarts and the new values are added to the end of printer.cfg.

Check the result

  • After reaching the target temperature, the value on screen should stay within ±0.5–1 °C.
  • A few degrees of overshoot while heating is normal and should settle quickly.
  • Small dips can appear when the fan turns on and off during a print, but the temperature should recover quickly.

If PID does not fix it, check the hardware

If you still see sudden dips and jumps after PID tuning, the problem is in the hardware:

Symptom Possible cause
Sudden, large jumps Loose thermistor cable or connector
Temperature never reaches the target Weak heater cartridge or insufficient power supply
Temperature drops a lot when the fan turns on Fan blows directly on the heater block, a silicone sock is needed
Slow but regular swings PID values are wrong, tuning needed

The heater and thermistor are directly tied to the printer's safety. Never turn off thermal runaway protection. If you see damage on the cables, replace the part before using the printer.

Frequently asked questions

Do I need to PID tune for every filament?

No. If you print at very different temperatures (for example PLA at 200 °C and ABS at 250 °C), tuning at the temperature you use most is enough. If the difference is big, you can pick a temperature in between instead of switching between two separate tunes.

Does a silicone sock really make a difference?

Yes. A silicone sock insulates the heater block from fan air and the environment. Temperature becomes more stable and less plastic sticks to the nozzle tip. Repeat the PID tune after fitting it.

By the3dfix. If you spot a mistake or your problem is still not solved, get in touch.