If you’ve worked with 3D printers before, you’ll be familiar with the heating components on your machine. If you have a heated bed, you probably have two heating components: one for the nozzle and one for the bed.

These components use algorithms to keep the temperatures stable by using three variables: the proportion of the actual temperature to the requested temperature; the integral, which is a measurement of the historical error of the heating process; and the derivative, which is a measurement of how quickly the temperature changes from above and below the requested temperature.

Together, these are typically called PID settings, and they can be used for a wide variety of applications. Essentially, PID is all about maintaining a proper balance. In this article, we’ll go through all the ins and outs of PID tuning, including how to do it on your printer!

Back to Contents

3D Printer PID Tuning / Auto-tune PID

What Is It?

Temperature variations can cause inconsistent extrusion and lines on the side of prints
Temperature variations can cause inconsistent extrusion (Source: Fordari via Reddit)

So how does PID heating work on a 3D printer? In simple terms, the machine’s firmware accepts three values – P, I, and D – and an algorithm calculates how to maintain the proportion of heat, integrating the recorded error, using a derivative to modulate speed.

PID vs. Bang-Bang

PID heating is more commonly used on 3D printers than the alternative heating method: “bang-bang” heating. “Bang bang” heating is typically used by ovens and heaters in the home, involving a basic process of activating the heating element when the temperature is below the requested value and turning it off when the temperature is reached. “Bang bang” heating is ineffective for 3D printers because, if the true temperature fluctuates too wildly above and below the target, print quality can worsen.

Tuning

While PID values may seem insignificant, their impact should not be underestimated when it comes to 3D printing. If your nozzle or print bed has a lot of temperature variation, this can create lines on your prints (not the normal layer lines), significantly worsening a printed part’s appearance. That’s because varying temperatures can cause inconsistent extrusion, especially if the nozzle has a heating problem. (The bed can cause its own set of problems, too.)

PID tuning allows you to tweak the P, I, and D values on your printer to minimize any heating element temperature fluctuations. In this article, we’ll be going over how to auto-tune the PID settings for the hot end or heated bed. We’ll outline the process for Marlin 1, Marlin 2, and Smoothieware. Still, the processes are very similar for other firmware, too, with the only real differences depending on the G-code syntax. Usually, if the firmware is open source, you should see which G-code commands are used for PID tuning on the firmware developer’s website.

Back to Contents

Advertisement
Advertisement
3D Printer PID Tuning / Auto-tune PID

How It Works

Flatten the curve!
You want to avoid a graph with too much variation in temperature (Source: Danny Tuppeny via 3D Printing Stack Exchange)

As we said, PID tuning works by adjusting the P, I, and D values on your printer’s firmware. These changes are kept in the printer’s onboard memory and are used for every print and action that involves heating.

When you get a new hot end or heated bed or switch to a significantly new printing temperature, you should perform a PID tune to get the best results with your new gear or settings. The easiest way to PID tune your printer’s heating elements is by sending G-code commands through a G-code terminal like Pronterface or OctoPrint‘s integrated terminal.

The P, I, and D values are auto-generated by your printer during PID tuning, which is performed by your printer heating up a specified element a certain amount of times. During this testing process, your printer takes automatic measurements and then, through the G-code terminal, returns the calculated values.

When you start a PID tune, first set which heating element you want to tune and then the target temperature at which you want to tune the heating element. This temperature should be the same temperature you plan to use for printing. Finally, set the number of repetitions that the printer should heat the specified element up and down, let the PID tuning commence, and then re-input your newly calculated P, I, and D values into your G-code terminal.

Now, let’s move on to the instructions for auto-tuning PID on machines running Marlin 1, Marlin 2, or Smoothieware firmware!

Back to Contents

Advertisement
Advertisement
3D Printer PID Tuning / Auto-tune PID

Before You Tune

OctoPrint has a great G-code terminal integrated into their interface
OctoPrint has a great G-code terminal integrated into the interface (Source: Jackson O'Connell via All3DP)

For this process, we’ll take you through tuning your printer’s PID settings if it is running on Marlin (or Marlin-based firmware like TH3D Unified) or Smoothieware firmware. We’ll go over how to tune your first hot end (“E0”) and your heated bed, and because the processes are slightly different for the two, we’ll split the procedure into two parts.

Before doing anything, if your printer is running Marlin, check to see which version of Marlin your printer’s firmware is based on (Marlin 1.X or 2.X). Also, make sure you have a G-code terminal. Pronterface is a compatible with many printers and is easy to use, and OctoPrint‘s terminal is another commonly-used option.

If you’re not running Marlin or Smoothieware firmware, the process will be very similar, if not the same, on other firmware programs. Check your firmware company’s website for their G-code syntax to find the right commands for PID tuning, and if you can’t find that, use the following process as a starting point.

Back to Contents

Advertisement
Advertisement
3D Printer PID Tuning / Auto-tune PID

Marlin Firmware: Hot End

For Marlin 1 or Marlin 2 firmware, you can use this format to PID tune your hot end
For Marlin 1 or Marlin 2 firmware, you can use this format to PID tune your hot end (Source: 3DAddict)

Follow the steps below to PID tune your printer’s hot end if your machine is running Marlin firmware:

  1. Open your G-code terminal and connect your device (with the terminal) to your printer’s mainboard.
  2. Choose a nozzle temperature that will be closest to the one you will most often print with.
  3. Choose which heater you want to PID tune (E0, E1, and so on).
  4. Choose how many heating cycles (repetitions of heating the element up to and down from the target temperature) you want to run.
    • The more cycles, the longer it takes, but the more accurate the results.
    • The default number of heating cycles is 5.
  5. Enter “M303 E{heater number} S{target temperature} C{number of cycles}” and then send it using your G-code terminal. For example, “M303 E0 S230 C7” will PID tune the first heater to 230 °C using 7 cycles.
  6. Wait for the terminal to finish cycling and show the calculated P, I, and D values. These will read as “kP, kI, kD”.
  7. Enter “M301” followed by “P{generated kP value} I{generated kI value} D{generated kD value}” and send the command. For example, “M301 P70 I3 D65” will input new hot end PID values of P = 70, I = 3, D = 65.
  8. Send the M500 command to save and store these values to your mainboard. Or, if you prefer to use the LCD interface, you can accomplish the same task by selecting, “Save Settings”.

Back to Contents

Advertisement
Advertisement
3D Printer PID Tuning / Auto-tune PID

Marlin Firmware: Heated Bed

PID tuning your heated bed can prevent the bulging layers seen on the cube to the left
PID tuning your heated bed can prevent the bulging layers seen on the cube to the left (Source: bjoern-h2 via PrusaPrinters)

PID tuning your bed is very important, and it can prevent unnecessary extra layer lines on your 3D prints (like the ones seen on the left side of the image above). Follow the steps below to PID tune your printer’s heated bed if your machine is running Marlin firmware:

  1. Open your G-code terminal and connect your device (with the terminal) to your printer’s mainboard.
  2. Choose the heated bed temperature that you will most often be printing with.
  3. Identify the version of Marlin you have: If you have firmware based on Marlin 1.X, use the heating element “E-1”. For Marlin 2.X, use “EBED”. (Some readers have noted that “E-1” is also used for 2.X.)
  4. Choose how many heating cycles (repetitions of heating the element up to and down from the target temperature) you want to run.
    • The more cycles, the more accurate and the longer the time it takes for the tuning.
    • The default number of heating cycles is 5.
  5. Enter “M303 E{heating element firmware name} S{target temperature} C{number of cycles}”, which is the “PID autotune” command, and then send it using your G-code terminal. For example, “M303EBED S100 C6” will PID tune the printer’s heated bed (on Marlin 2.X) to 100 °C using 6 cycles.
  6. Wait for the terminal to finish cycling and show the calculated P, I, and D values. These will read as “kP, kI, kD”.
  7. Enter “M304” followed by “P{generated kP value} I{generated kI value} D{generated kD value}” and send the command. For example “M304 P70 I3 D65” will input new bed PID values of P = 70, I = 3, D = 65.
  8. Send the M500 command to save and store these values to your mainboard. Or, if you prefer to use the LCD interface, you can accomplish the same task by selecting “Save Settings”.

Back to Contents

Advertisement
Advertisement
3D Printer PID Tuning / Auto-tune PID

Smoothieware

The G-code syntax on Smoothieware firmware is slightly different than Marlin's syntax
The G-code syntax on Smoothieware firmware is slightly different from Marlin's syntax (Source: shai via RepRap)

Below is a guide to PID tuning the hot end or bed on a 3D printer running Smoothieware firmware:

  1. Open a non-web-interface G-code terminal, such as Pronterface, and connect your device (with the terminal) to your printer’s mainboard.
  2. Identify the heater element ID you want to PID tune. The hot end ID is “E0”, and the heated bed ID is “E1”.
  3. Choose the temperature that you will most often be printing with.
  4. Enter “M303 E{heating element firmware name} S{target temperature}” and then send it using your G-code terminal. (Again, this is the “PID autotune” command.) For example, “M303 E1 S60” will PID tune the printer’s heated bed using 3-8 cycles to 60 °C. The exact number is not specified by Smoothieware.
  5. Wait for the terminal to finish cycling and show the calculated P, I, and D values. These will read as “kP, kI, kD”.
    • These values are immediately loaded onto your board’s memory, but not the firmware.
  6. Send the M500 command to save and store these values to your mainboard.

And that’s all it takes to PID tune your printer!

Back to Contents

Advertisement
Advertisement
Advertisement