Guides

[GUIDE] Guide to PID Tuning – Step by step

Pid tuning is the defined procedure in you happen to haves Printer halted error on your screen. This is really very very common. This error occurs when the printer fails to heat properly one of its parts: the nozzle or the bed. 

Under fault-free conditions, this problem occurs when installing, for the first time, the first fan duct. The air circulation at the level of the plate leads to the Hot-end’s cooling and the software, according to the default settings, can no longer heat up as it should. In this case, a fine Pid tuning can be the key.

Instead, if you receive the “Printer Halted” message without making any changes, you are dealing with a malfunction, which would be investigated, but also in this case, you should start with an Autotune P.I.D.

 

PID Tuning:  But what does P.I.D. mean ?

The Proportional-Integral-Derivative controller, commonly abbreviated as PID, is a control loop feedback mechanism widely used in industrial control systems. It is the most widely used feedback control system. This because it can, through a feedback, react to a positive or negative error value, correcting it according to the desired setpoint 0. The reaction to the error can be set through a process called Autotune.

In the 3D printer it is exactly this process that deals with the regulation of heating, and through this algorithm, it doses the power input. The PID is the reason why, if we set the nozzle temperature to 200 degrees, it remains so and does not range, for example, between 205 to 195 degrees.

Therefore, in our case, the PID serves to predict the behavior of the heating by the feedback given by the temperature sensor. This system, which is very easy to manage, also has limitations: one for all, is the lack of adaptability to process parameters’ changes. Basically, this problem is the reason why if you add a new fan duct you must proceed to recalibration.

If you often get the Prin

ter Halted error, or you can see that your printer does not keep the nozzle or the plate temperature stable, even with 10 degrees fluctuations, it’s time to make a PID tune.

PID Tuning: Practical Guide

Let’s see in a few simple steps how to carry out this “self-regulation”:

– Connection

First, connect the printer to a computer, through a control and dialogue software. You can choose among different software, such as Repetier Host, Pronterface, Astroprint and many others. (This guide is based on Repetier Host, but steps and controls are the same, whatever software you’ll use).

– Control

Once connected, go to the printer control board and enter the following code: M303 E0 S200 C8

Let’s break down this code to understand it:

M303 -> It is the autotune parameter. It can also be used alone, using the preset values ​​of the firmware, but it is not a good idea. It is better to use the data you need.

E0 -> This stands for the apparatus we are testin

g. The E0 is the extruder number. In some printers (with two extruders) we will also have the E1. In machines with heated plate we could use BED or E1 or E2, depending on the code used by the firmware for the plate.

S200 -> This part of the control indicates the temperature at which the test should be carried out. 200 stands for 200 degrees and you can choose temperature from 150 ° to 260 °, according to the material for which you want to set the printer. If you print mainly PLA, you must turn on the fans of the fan duct and then proceed to the autotune in the conditions in which you print normally.

C8 -> This is the number of heating cycles the software should carry out. More cycles mean a more precise PID, but there is no need to exaggerate. 8 cycles are enough and exceed 14/15 will be completely useless.

Once the control has been started, the temperature graph will go up until it reaches the set “letter S- – – “ data and it will start swinging around the value.

Paying attention, you will see that at each cycle the wave will be reduced to a line.

Once the set cycles have been completed, the software will give our new PID values: Kp, Ki and Kd.

Great! you have the new values, but where do you have to insert them?

 –  PID Setting

You could insert them at the beginning of a Gcode, to perform a first test and see how the printer reacts to the new values. To put it at the beginning of each Gcode, you must go to “start.gcode”, for example in Cura, and enter, after the M303 command, the values ​​supplied by the controller. For example, M301 P14.82 I0.8 D68.25 (insert the uppercase letters instead of these values). But in this way, you must manually edit all the files, but if you are sure the data are valid, this would be just a waste of time. So, it’s better set them on the printer via

M301 P14.82 I0.8 D68.25 command

and save these values ​​on eeprom with the M500 command or edit the firmware directly.

-PID Setting (manual)

Some printers let you insert value you found by display and just save them with pushing a button. (easyer way)

PID Tuning: Firmware change

The firmware can be edit in 2 ways:

First way to insert new value

  • The first, faster, is to directly add the values ​​found by the device’s operating system. You will just enter the code M301 followed by the values ​​found, in the software used to run the autotune.

                                 Example: M301 P14.82 I0.8 D68.25

NB: for the plate the procedure is the same. You will just use the M304 commandto communicate the values ​​to the eeprom. Example: M304 P14.82 I0.8 D68.25.

Be sure to save these values ​​using the saving option of the printer or using the M500 command.

 

Second way to insert new value

  • The second and slower way to edit the firmware is to enter the values ​​found in the firmware and replace it in the printer. In this way we will have a clean installation with the possibility of having fewer complications.

We will explain the procedure with MARLIN, perhaps the most widespread among the firmware:

Open Marlin.ino with the Arduino program:

If it has never been done, you will have to select the correct tab (for example Arduino Mega 2560) and the correct serial port (you can only see the connected printer, eg COM 4).

Once Marlin.ino is open, go to the configuration.h tab and look for the “PIDTEMP” section. Here you will replace the values ​​of “DEFAULT_Kp”, “DEFAULT_Ki” and “DEFAULT_Kd” variables with those found with the autotune.

Finally, pressing the right arrow icon (top left) will the codewill be loaded. Now, the PID is correctly set and there will be no longer error messages or annoying temperature fluctuations. It is possible to repeat this process several times, as the conditions change, in order to have the printer as efficient as possible.


If this guide has been useful and you want to stay up to date on new releases, please LIKE Easy 3D Home Facebook’s page! You can find other guides about 3D in our Guides section!

Leave a Reply