PID auto-tune is a function of Marlin 3D printing firmware that controls the temperature settings of your heated print bed and the hot end.
It can be altered to whichever settings are appropriate to the printer or filament type you’re using, and allows for a constant temperature to be maintained.
PID stands for Proportional, Integral and Derivative.
These settings use algorithms to specifically control how your printer handles temperature adjustments to the hot end and heated bed.
The correct calibration of these parameters will ensure the correct operation of your printer and, in turn, produce consistent results with your next printing projects.
In this article, we’re going to be looking specifically at the function of the PID auto-tune in Marlin software. But, first let’s take a step back and remind ourselves of what Marlin is.
Marlin is quite possibly the most well-known software in the world of 3D printing.
First created in as an open-source project in 2011 by a group of developers led by Erik van der Zalm, it was originally produced as operating software for RepRap and Ultimaker machines.
However, today Marlin drives the vast majority of home and hobbyist 3D printers to roll off the production line.
Certainly, if you own or have used a Fused Deposition Modelling (FDM) 3D printer yourself, you will be aware of Marlin.
The software itself operates every function of the 3D printer such as the stepper motors, axis control, heaters etc. and is installed directly into the mainboard of your machine.
The controls follow a derivation of G-Code commands and as such are fairly straightforward with “common sense” settings.
This is part of Marlin’s popularity among users and manufacturers alike, as it does the job in a no-frills way.
So, that’s just a brief look at Marlin, but now let’s get down to the point in hand and look at PID auto-tuning.
But what does PID stand for?
- Proportional – This measures the proportion of the actual temperature in relation to that which has been requested. For example, if the target temperature is 200° C and its reached 150° C, then the proportion would be 75%
- Integral – This is a measure of what’s known as the historical error of the heating process. By that we’re looking at how the heated element has performed in previous heating cycles. This will return an adjustment value to ensure that future cycles are more consistent.
- Derivative – The measurement of how quickly that the temperature changes either above or below the target. For instance, a heater element in an oven could be set to 200° C and will then cut out once it reaches but usually exceeds that target. It will then continue to heat/cool/heat and so on, all the while the dial is on 200° C. This set up is known as “bang-bang” hearting and is no good for a heated element on a 3D printer as it needs to be at a steady constant throughout.
When you run PID auto-tune, you’re sending a command to your printer, which then performs these actions and returns a set of results.
Importance of PID Tuning in 3D Printing
As Marlin is an open-source program, it allows you to change the lines of code to fit with the settings that you need.
Therefore, it follows that you can change the PID setting to whatever you need it to be.
Incorrect temperature settings and heat fluctuations can have a detrimental effect on any print, and as we all strive for perfection, it makes sense to use any and all tools available.
For example, the correct hot end temperature for using standard PLA filament should probably be around the 190-220°C mark, but will depend on the make and manufacturer’s guidelines.
I generally go for 200°C and 55°C for the bed on most brands of PLA that I use.
Let’s look at the hotend first.
If the temperature is wrong or changes too much during the printing process, it can cause problems such as under extrusion, blockages, stringing etc.
Any of these could cause your print to fail, or at least be of poor quality.
With the heat bed, the end results will be the same, but you may not even get that far if the bed temperature is wrong or fluctuating, as your print may not even stick to the plate.
You may also encounter layer shift as the print progresses and even damage to your heat bed itself if it overheats.
All of these are good reasons to use the PID auto-tune in Marlin.
How To PID Auto-Tune on Marlin
As we’ve mentioned, Marlin operates by sending a set of commands to operate the machine it’s controlling.
These commands are prefixed with the letter “M” followed by a number.
Experienced Marlin users will be able to tell, directly from the number being used, to which parameter the command is referring.
However, it’s not important whether you know them all, just the ones you need!
In this explanation however, we’ll be using Pronterface.
To run PID autotune for your hot end in Marlin, you would enter a line of code like this:
M303 E0 S200 C8
In this command M303 is the PID autotune “tag”, E0 is the number of the hotend (P), S200 is the target temperature (I) and C8 is the number of cycles (D).
The cycles refer to the number of times the temperature runs around its target of 200° C and sends results back to determine the correct target: in this case 8.
This is where the auto-tune aspect of the command comes into play as the cycling of the temperature setting is designed to maintain a constant heat and auto-adjust or tune as necessary.
These settings can obviously be changed to accommodate your own needs and aren’t limited to controlling just one hot end at a time.
You can also control the heat bed settings in a similar manner so let’s take a closer look at how you’d do this.
When we’re dealing with the hotend, we’re obviously talking about the business end of your printer that delivers the extruded and heated filament to the print bed.
As we’ve discussed previously, this needs to be at a certain temperature appropriate to the filament you are using and needs to maintain that temperature at a constant level.
The PID Auto-Tune would therefore be set as in the above example.
1. Connect Pronterface with the printer
Open up Pronterface on your laptop or PC and ensure it’s connected to your printer.
This should bring up a list of all the Marlin settings that are present for your machine.
2. Find the “M303” line and change the settings to your own
You then need to send this G-Code to your printer and wait for it to do its thing. The returned results will show you the new PID values prefixed in each case by a “k” (so kP, kI, kD).
3. Resend the PID values
You then need to resend these to your printer as a “M301” command, and this will reset the PID to the new parameters.
Now, a common error when doing this is that people forget to save the new settings so make sure to do this using the “M500” command.
Your PID settings are then saved to your mainboard and form part of the firmware.
We have also touched on the fact that these settings can control more than one hot end.
If your printer is set up to allow multiple extrusion (for different colour filaments for instance) you may then have the following line of code:
M303 E0 E1 E2 S200 C8
This shows three hot ends (0,1 & 2) set to 200°C with the same cycling routine. The process to set these will be the same but the results will look slightly different.
The Heated Bed is the surface onto which your filament is extruded to print your chosen 3D model.
The process for setting the PID auto-tune for the bed is pretty much the same as for the hotend except that the designator for the bed is different.
However, and this is important, to ensure correct operation of the PID you’ll need to ensure that the PIDBEDTEMP setting is “uncommented”.
This means that you remove the “//” in front of the command in Marlin.
Once you’ve done that, your M303 line this time could look like this:
M303 EBED S70 C8
Also, when you have the returned results, you’ll need to send the “k” values back using the “M304” command.
Once done, remember to save again with M500.
Commonly Encountered Issues With Marlin PID Auto-Tune
As with everything, Marlin isn’t perfect and issues crop up from time to time with many of its settings.
The PID auto-tune function is not alone in this respect and there are a few commonly encountered issues that you may come across as you use it.
Let’s have a look at the main ones.
PID Auto-Tune Timeout
This is an error message which shows when the command has failed to operate properly and fails due to a pre-set timeout parameter.
An example of this could be that the target temperature for your heated bed could be set to 110° C which you might straight away say is fairly high.
As a heated bed may typically heat to a maximum of around 80° C it will take time to reach a much higher target.
Any external elements which may affect the heating process, faulty or overworking fans or poor power supply can slow this process down leading to the target not being reached within the requisite time leading to the timeout failure.
Bad Extruder Number
This is another error message that occurs when there is a discrepancy between the information in the command line and the main setup of the Marlin firmware.
For example, you have entered “E0” as the heat bed, but this value isn’t already present in the Marlin firmware.
The M303 command will then fail as it’s unable to find the heat bed to which you’re referring.
The most common causes of this are that you’ve either mistyped the command line or you’ve forgotten to enable the PIDTEMPBED setting.
Temperature too High
This may seem obvious but can happen.
Every printer and the heated elements of it (i.e., hot end and print bed) will have a maximum usable temperature.
Each range of printers may have different upper limits, and quite often it will depend on whether the machine is powered by a 12v or 24v supply.
Higher temperatures obviously need more power and will take time for PID to kick in as it comes close to the target.
So, if you set the target temperature to say 250°C then it will only start the PID process when the temperature comes within 10°C and will more than likely overshoot the target.
This will then bring up the error.
The solution to this is either to change the “PID_FUNCTIONAL_RANGE” from 10 to say 50 or 60 to allow more time for the PID to work or; decrease the power to the heater by reducing the “PID_MAX” setting.
This slow the heating process but will again allow more time for PID to work properly.
We’ve had a good look at PID auto-tuning and I think you’ll agree that it’s an essential setting if you want to maintain consistent heat settings and in turn, quality prints.
The settings we’ve gone through are the basic Marlin commands for the PID auto-tune function.
We’ve also touched on other settings and commands but, as you’ll hopefully understand, it wouldn’t be possible to go into every setting in Marlin within this article alone.
I hope however that this will give you an insight into changing Marlin settings and provide the incentive to learn more about this essential piece of 3D printing firmware.