3D printer G-code · Marlin

M303: PID autotune (Marlin)

PID autotune — Heats and cools the heater around the target a few times and calculates new PID values. Needed after a new heater cartridge, thermistor, hotend or silicone sock, and…

By cnccode · Updated
On this page
  1. What does M303 do?
  2. Parameters
  3. Example
  4. Tips from practice
  5. Related commands
  6. More temperature commands
  7. Frequently asked questions
PropertyValue
CommandM303
FunctionPID autotune
FirmwareMarlin
GroupTemperature
SyntaxM303 E<heater> S<°C> C<cycles> [U1]

What does M303 do?

Heats and cools the heater around the target a few times and calculates new PID values. Needed after a new heater cartridge, thermistor, hotend or silicone sock, and when the temperature swings.

Parameters

ParameterMeaning
EHeater: 0 = first hotend, -1 = bed
STarget temperature
CNumber of cycles, 8 is a good value
U1Use the result at once

Example

G-code
M106 S255           ; part fan as when printing
M303 E0 S215 C8 U1  ; tune hotend
M500                ; save

Tips from practice

  • Tune with the part fan at the speed you print with.
  • In Klipper the same is PID_CALIBRATE.

Marlin. Many Marlin commands only exist when the feature is enabled in the firmware build. If the printer answers "Unknown command", the feature is missing. Klipper does not understand most of these settings codes; it uses printer.cfg instead.

More temperature commands

CommandFunctionFirmware
M104Set hotend temperature (no wait)Marlin and Klipper
M109Set hotend temperature and waitMarlin and Klipper
M140Set bed temperature (no wait)Marlin and Klipper
M190Set bed temperature and waitMarlin and Klipper
M141Set chamber temperatureMarlin
M301Set hotend PID valuesMarlin
M304Set bed PID valuesMarlin
PID_CALIBRATEPID tuning (Klipper)Klipper
TEMPERATURE_WAITWait for a temperature rangeKlipper
SET_HEATER_TEMPERATURESet a heaterKlipper

Test it before you print

Paste your start code or a whole file into the 3D printer simulator. It plans every move, shows the time and finds missing waits, cold extrusion and moves outside the bed.

Open the simulator

Frequently asked questions

What does M303 do on a 3D printer?
M303 is pID autotune. Heats and cools the heater around the target a few times and calculates new PID values. Needed after a new heater cartridge, thermistor, hotend or silicone sock, and when the temperature swings.
Does M303 work in Klipper and Marlin?
M303 is a Marlin command. Klipper uses its own commands and printer.cfg settings for this task.
Was this page helpful?