A quick guide to PID tuning with Marlin

descriptionStandard

A brief guide on how to utilise PID temperature tuning in Marlin. You will need to ensure that the following definitions are present in your firmware’s configuration to utilise this the temperature tuning functionality:

Define Reference

  • #PIDTEMP for the hotend
  • #PIDTEMPBED for the bed

Checking the current values

First you may wish to make a note of the current P, I, D values stored in the firmware; this isn’t essential but useful to compare to new values:

  • Send G-code: M301 to the printer to get the current PID values for the hotend and make note of the returned values.
  • Send G-code: M304 to the printer to get the PID values for the bed and make note of the returned values.

Performing a PID tuning cycle

Next to start the P, I, D tuning process you need to send G-code:
M303 C < count > E < index > S < temp > U to the printer

G-codeDescriptionExample
M303HotendM303 C15 E0 S215 U
M303Heated bed M303 C15 E-1 S60 U
Hotend/Bed PID Tune examples

When you initiate the M303 G-code commands the PID autotune process will start. The temperature will start to increase to the target temperature and fluctuate around that for the given number of cycles. The operation will be complete once the temperature begins to drop. For more verbose output you should consider connecting to the terminal on the printer at the time as this will let you see the operations progress and completion.

Once this process is done you can check and make a note of the new P, I, D values as they will very likely differ to those defined in your firmware.

G-codeDescription
M301Get/Set Hotend PID
M304Get/Set Bed PID
Get or Set the Hotend/Bed PID

Example checking the current PID settings for the Hotend:
M301

Example checking the current PID settings for the Bed:
M304

Save all configurable settings to EEPROM

After you have compared the changed and are happy with the results; you can send G-code command M500 to the printer to save the changes to the EEPROM.

Save PID settings manually

Example: setting the PID on the Hotend; note that the values of P,I,D should be replaced with your own:
M301 p:25.04 i:1.79 d:87.38

Example: for setting the PID on the Bed; note that the values of P,I,D should be replaced with your own:
M304 p:134.10 i:26.64 d:450.05