What a PID controller is doing in your printer
Every time your printer heats the nozzle or the bed, something has to decide how much power to send to the heater cartridge at any given moment. That something is a PID loop, short for Proportional-Integral-Derivative. It runs many times per second, compares the measured temperature to the target temperature, and adjusts the power output based on three things: how far off you currently are (proportional), how long you have been off and by how much cumulatively (integral), and how fast the temperature is changing right now (derivative).
Without this kind of control, a printer would default to a much cruder method: full power until the target is reached, then off, then back on when the temperature drops below target. That is bang-bang control, and it works, but it produces a temperature that saws up and down instead of settling. A tuned PID loop instead ramps power down as it approaches the target, so the hotend or bed arrives at the setpoint and holds there with minimal overshoot.
The three terms work together. Proportional power responds to the current error and does most of the work. Integral power corrects for the fact that a printer sitting near its target temperature still loses heat to the surrounding air and the incoming filament, so some baseline power is needed just to hold steady. Derivative power watches the rate of change and pulls back early when the temperature is climbing quickly, which is what prevents overshoot. Marlin exposes these as Kp, Ki, and Kd; Klipper uses the same three constants under the hood, just stored differently.
Why the default values are a guess, not a fit
Firmware ships with PID constants that are reasonable for a generic setup, not for your specific hardware. Marlin’s default Kp/Ki/Kd values and Klipper’s example configs are starting points, and they assume a certain heater block mass, a certain heater cartridge wattage, a certain thermistor response curve, and a certain amount of airflow from the part cooling fan and hotend fan.
Your printer will not match that assumption exactly. A heavier heater block with more thermal mass responds more slowly and needs different integral and derivative behavior than a small, light one. A higher-wattage cartridge injects heat faster and can overshoot more if the proportional term is too aggressive. A different thermistor type changes how quickly temperature changes are detected, which affects the derivative response. And the hotend fan matters more than people expect: an aggressive fan pulling heat away from the heat break constantly fights the heater, and a loop tuned without accounting for that will drift or oscillate once the fan kicks in during a print.
Any of these on their own might be a small mismatch you never notice. Stack a swapped hotend, a different nozzle, and a stronger fan on top of the printer’s stock configuration, and the default PID values are tuning for a machine that no longer exists.
What a bad PID tune looks like in practice
The clearest sign is on the printer’s own display or in your slicer’s connected interface: watch the temperature graph while it holds at a target, and instead of a flat line you see a wave, cycling a few degrees above and below the setpoint on a regular rhythm. That is the loop hunting instead of settling.
On the printed part, this shows up subtly. Extrusion pressure and flow are somewhat temperature-dependent, so as the hotend cycles a few degrees warmer and cooler, you can sometimes see faint banding correlated with that cycle: slight shifts in layer sheen or texture at a regular interval up the wall of a print. It is not the dramatic layer shifting or blobbing you would get from a mechanical problem, it is subtle and easy to miss unless you are looking for it specifically.
In more extreme cases, bad tuning triggers false thermal runaway shutdowns. Marlin and Klipper both monitor whether the actual temperature stays within an expected window of the target over time, and if oscillation is wide enough or a heater struggles to recover fast enough after a temperature dip, the firmware can conclude something is actually wrong with the heater or sensor and shut the print down as a safety measure, even though the hardware itself is fine.
Running the autotune on Marlin
Marlin’s built-in tool is M303. The basic form is:
M303 E0 S210 C5
E selects which heater to tune: E0 is the first hotend, E1 the second on a multi-extruder machine, and E-1 targets the heated bed. S sets the target temperature for the test, which should be close to a temperature you actually print at. C sets the number of heating and cooling cycles the test runs, and Marlin’s documentation notes it should be greater than 3, with 5 as a reasonable default for a useful result.
During the test, the firmware deliberately heats past the target and lets it cool repeatedly, several cycles in a row, and measures how the real hardware responds each time: how fast it heats, how far it overshoots, how it decays back down. From that response curve it calculates Kp, Ki, and Kd values suited to your actual heater block and thermistor rather than a generic assumption.
Once the test finishes, Marlin prints the calculated values to the console. If you add U1 to the command, Marlin applies the results automatically once the test completes. Either way, those values live in RAM until you write them to EEPROM, so run M500 right after to save them permanently. Skip that step and the PID values you just measured are gone the next time the printer restarts.
Running the autotune on Klipper
Klipper’s equivalent command is PID_CALIBRATE, and the syntax is:
PID_CALIBRATE HEATER=extruder TARGET=210
For the bed, swap the heater name:
PID_CALIBRATE HEATER=heater_bed TARGET=60
HEATER takes the config section name for the heater you are tuning, extruder for the hotend or heater_bed for the bed, and TARGET is the test temperature. Klipper runs the same kind of cycle Marlin does internally, heating to target and then oscillating through several on/off cycles to characterize the real thermal response.
Klipper does not write to EEPROM. Once PID_CALIBRATE finishes, run SAVE_CONFIG, and Klipper appends the new PID constants to your printer.cfg and restarts the firmware to load them. Until you run SAVE_CONFIG, the newly calculated values only exist for the current session and disappear on the next restart, the same practical trap as forgetting M500 on Marlin.
When it is worth doing again
PID tuning is not a one-time-forever setting. Rerun it whenever something changes the thermal characteristics of the heater block: a new hotend, a replacement heater cartridge, a different thermistor, or a mechanical change to the block itself, including something as small as swapping to a nozzle made of a different metal, since that shifts the mass and heat transfer slightly. Any of these changes the physical system the old PID values were calculated for.
A move to a location with a very different ambient temperature can also justify a retune, since the loop’s baseline power draw to hold steady changes with a colder or warmer room. It is a real factor, but a minor one next to a hardware swap. If your printer sits in a garage that goes from 15C in winter to 30C in summer, that is worth a note, but it is not going to move the needle the way changing hotends does.
If you have not touched the hotend hardware and your room temperature is stable, there is no need to run this on any kind of schedule. It is a set-it-and-check-it-later job, not routine maintenance.
Do the hotend and the bed separately
Treat these as two independent tuning jobs, because they are two independent thermal systems. The hotend has a small heater block, low thermal mass, and reacts fast. A heated bed is a large slab of aluminum or a PCB with much greater thermal mass, heats and cools far more slowly, and often has a different degree of insulation underneath it depending on your build. Values that work for one tell you nothing about the other.
If your bed graph shows the same kind of oscillation the hotend does, or it takes an unusually long time to settle at temperature, run M303 with E-1 on Marlin or PID_CALIBRATE with HEATER=heater_bed on Klipper, separately from the hotend tune, and save that result independently too.
How much this actually matters
Be realistic about what PID tuning fixes. On a modern printer that came reasonably well assembled, with a stock hotend and stock firmware defaults, the visual effect of imperfect PID tuning on print quality is usually mild, sometimes invisible without close inspection under good lighting. If you are chasing an obvious quality problem such as stringing, layer shifting, poor first-layer adhesion, or under-extrusion, PID tuning is very unlikely to be the cause and shouldn’t be the first thing you check. Look at other calibrations first, like E-steps calibration or Z-offset calibration, since flow and first-layer problems are far more commonly traced back to those.
Where PID tuning earns its place is after a hardware change, or as a quick pass to rule a variable out entirely. The whole process takes a few minutes per heater, the commands are simple, and once the values are saved you do not have to think about it again until you change the hardware. It will not fix a printer with a bigger underlying issue, but it removes one more thing you would otherwise have to wonder about.