Ad Space — Top Banner

PID Tuning Formula for 3D Printers

How PID control regulates hotend and bed temperature in 3D printers.
Covers Kp, Ki, Kd terms, autotune commands, and common temperature oscillation causes.

The PID Formula

u(t) = Kpe(t) + Ki∫e(t)dt + Kd(de/dt)

u(t) is the heater output (0-255 in Marlin, 0-100% in Klipper). e(t) is the error: target temperature minus actual temperature. The three terms each handle a different aspect of temperature control.

The Three Terms

TermWhat it doesToo highToo low
Kp (proportional)Reacts to current error sizeOscillation, overshootSlow response, large steady-state error
Ki (integral)Eliminates persistent offsetWindup, slow oscillationTemperature settles below setpoint
Kd (derivative)Brakes as temperature approaches targetAmplifies noise, jitterOvershoot on heat-up

Running Autotune

In Marlin: M303 E0 S220 C8 runs 8 autotune cycles for the hotend at 220C and reports Kp, Ki, Kd. Save with M301 and M500.

In Klipper: PID_CALIBRATE HEATER=extruder TARGET=220, then SAVE_CONFIG.

Run autotune with the printer in its typical operating state: enclosure closed if you use one, cooling fan at its normal speed, and the same ambient temperature you print in. PID constants calibrated at 20C room temperature will oscillate in a 40C enclosure.

Typical Values

ComponentKpKiKd
Standard 40W hotend (V6, Dragon)20–301.5–3.060–120
High-power hotend (50W+)15–251.0–2.550–100
120W heated bed50–805–10200–600

Key Notes

  • Temperature oscillation at print speed: if temperature drops when printing starts (cooling fan turning on), the PID was tuned with the fan off. Re-run autotune with M303 E0 S220 C8 U1 (U1 applies values immediately) with the fan at print speed.
  • Thermal runaway protection triggers when the hotend fails to reach or maintain target temperature within a time window. Proper PID tuning prevents false thermal runaway trips caused by oscillation.
  • Ki windup occurs when the heater is asked to hold a temperature it physically cannot reach, such as 300C on a 30W heater. The integral term accumulates error indefinitely, then overshoots severely when the target is lowered. Anti-windup clamps the integral term.
  • Bed PID is sometimes replaced with bangbang control in firmware for beds with slow thermal response and high thermal mass. Bangbang simply turns the heater fully on below setpoint and fully off above it. It works but allows temperature swings of 2-5C, which is noticeable in first layer consistency.

Ad Space — Bottom Banner

Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.