Not happy with how your 3D printer keeps its temperatures? Fix it with Marlin’s awesome PID autotune and improve the quality of your prints at the same time.
Now where did i put my exciting voice?
Using PID autotune
I’m Tom, and today i’m going to show you how to use the PID autotune feature of the Marlin firmware.
So, temperature control is one of the most crucial features of our 3D printers – while the earlier printers simply controlled the temperatures of the hotend and later on, the heated bed, by simply turning the heaters on when the temperature was below the setpoint and off when it was above, todays firmwares use a much more elegant way of managing heating. Simply speaking, they determine how much power to send to the heaters by looking at how large the difference between the actual temperature and the setpoint is, how long the actual temperature has been off from from the setpoint and how quickly the temperature is changing at the moment. These three factors make up the proportional, P, integral, I and differential, D part of what is call the P-I-D loop.
Now, the PID loop is not an intelligent system on its own and you need to tell it how much it should care about each of the P, I and D terms by giving the PID loop a set of Kp, Ki and Kd values. Figuring those out by hand is pretty tedious and probably won’t get you a PID loops that works well. So what the guys behind the Marlin firmware implemented is what is known as PID autotune, and it’s an effective and easy way of figuring out a set of Kp, Ki and Kd values. Let’s try that out.
To get started, you need a version of the Marlin firmware on your printer, a working hotend and/or a heated bed that reads correct temperatures and a RepRap host that lets you send commands to your printer via a command line. I’m using Octoprint for this, but for example pronterface will work just as well.
So the basic command for autotune is M303 – if you just send that command without any options, it will tune your hotend number one for a temperature of 150°C. That will give you a somewhat usable set of values, but to get better ones, you can add two more options: One is S to tell autotune the temperature you want to tune for, for example S230 for a hotend that’s going to print ABS or S120 for a heated bed for ABS. The other option is C as in Cesar, which tells autotune to run the tuning process a couple times in a row and improve the results with each pass. By default, it does three passes, but since they don’t really take long, i’m going to use C10 for ten passes. So let’s try that out, i’ll send M303 S230 C10. The hotend will heat up and then cool and heat again around the target temperature for ten times. It will report back to you each time it has finished a pass and give you a set of PID tunings. When it’s done, it will write back a final set of Kp, Ki and Kd values back to you. You can temporarily set them until the next time you reset the printer by using M301 with P, I and D and each of the calculated tuning values as arguments. So in my case, i’ll send it M301 P12.6 I0.66 D60.6 for my E3D hotend. If you’re also using an E3D hotend, you can use these values as a basis. You can then go and try these shiny new PID tuning on a print – Marlin will use them until the next time you disconnect from your printer.
Now, that was for tuning a hotend. If you want to use PID for your heated bed, there is one more option you need to add to the M303 command, and that is E for extruder. The heated bed is extruder negative one, the first hotend is zero, the second hotend is one and so on. To set the values, you’ll need to have PID enabled for the heated bed in Marlin’s configuration and you can then use M304 instead of M301 with the same arguments as for a hotend. By the way, if you have more than one hotend, Marlin will use the same PID tunings for all hotends, no matter which one you used for autotune.
To make the settings permanent, you can either send a simple M500, which will make Marlin automatically load up the values you just set with M301 and M304 each time you power up your printer. You can also change the values in Marlin’s configuration files and re-upload the whole firmware.
So that’s all there’s to it – autotuning is a one-time process and can really improve your prints, so if you haven’t tuned your printer yet, do it now.
That’s it for today! As always, thanks for watching and don’t forget to like, subscribe and comment you heart out!