Autotune PID is a feature that is included in Marlin and most branches of it to help determine the best settings for the hot-end temp control.
So what does it do? Well simply put it heats up the hot-end and cools it several times to determine the optimum setting for the heating element part.
PID tuning refers to a proportional-integral-derivative control algorithm used in most “reprap” style machines for hot ends and heated beds.
PID needs to have a P, I and D value defined to control the nozzle temperature. If the temperature ramps up quickly and slows as it approaches the target temperature, or if it varies by a few degrees either side of the target temperature, then the values are wrong, and you need to run Autotune
So let’s look at that part of it in marlin here is a sample of the code from one of my machines
// PID settings:
// Comment the following line to disable PID and enable bang-bang.
#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current 2014-8-27
#define PID_MAX 255 //255 2014-8-27
//#define PID_DEBUG // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
#define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature
// is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max.
#define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term
#define K1 0.95 //smoothing factor within the PID
#define PID_dT ((OVERSAMPLENR * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
// If you are using a pee-configured hot-end then you can use one of the value sets by uncommenting it
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki 1.08
#define DEFAULT_Kd 114
// Prusa r2d2 I3 2014-8-27
#define DEFAULT_Kp 17.52
#define DEFAULT_Ki 0.62
#define DEFAULT_Kd 123.43
This section is where you update your PID settings after you have run the Autotune
Here’s the code to run Autotune – M303 E0 S200 C8 Let me break it down so you can see what each part of this isM303 the machine CODE TO START AUTOTUNE E0 the hot-end to use S200 how hot we want it to get in this case 200 degrees. C8 this is how many cycles we want to run the Autotune you need to run it at a minimum of at least 8 times I do it 10 times but that’s me How do we use this?Well now that we know what it does let’s use it in a program you can use one of the FREE and popular programs either Promtierface or Repeater-host both of them work just fine first connect your printer to the software then in the space where you can enter g-codes type M303 E0 S200 C8 press enter and just wait it does take a few minutes you should see some results scroll on the screen like this
Info:PID Autotune start
00:10:51.020 : bias: 39 d: 39 min: 149.51 max: 153.52
00:11:10.066 : bias: 39 d: 39 min: 149.12 max: 150.85
00:11:27.180 : bias: 37 d: 37 min: 149.41 max: 150.80
00:11:27.181 : Ku: 34.12 Tu: 17.11
00:11:27.181 : Classic PID
00:11:27.182 : Kp: 20.47
00:11:27.182 : Ki: 2.39
00:11:27.183 : Kd: 43.79
00:11:44.316 : bias: 37 d: 37 min: 149.41 max: 150.80
00:11:44.317 : Ku: 34.12 Tu: 17.14
00:11:44.317 : Classic PID
00:11:44.318 : Kp: 20.47
00:11:44.318 : Ki: 2.39
00:11:44.319 : Kd: 43.85
00:12:01.616 : bias: 37 d: 37 min: 149.41 max: 150.80
00:12:01.618 : Ku: 34.12 Tu: 17.30
00:12:01.618 : Classic PID
00:12:01.619 : Kp: 20.47
00:12:01.619 : Ki: 2.37
00:12:01.620 : Kd: 44.27
00:12:01.624 : Info:PID Autotune finished ! Place the Kp, Ki and Kd constants in the Configuration.h or EEPROM
(This is an abbreviated list you should have a total 8 test and then it will give you the classic PID this is what you need)
At the end you will get three values, the classic PID Kp, Ki, Kd.
You will need to open and update the default values in Configuration.h in the Marlin Software.
#define DEFAULT_Kp 20.47
#define DEFAULT_Ki 2.37
#define DEFAULT_Kd 44.27
Then re-upload the firmware and you all set your hot-end is tuned for that machine.
If you can write to EEPROM on then you can do this
M500 P20.47 I2.37 D44.27 and that will write it to the EEPROM
Or temporarily you can use but not save it to the machine and you will have to do it every time you power up the 3d printer
M301 P20.47 I2.37 D44.27
Well there it is how to use Autotune for your hot-end this will help stabilize you temp on the hot-end and help make nicer prints.
Here is the wiki page for Autotune http://reprap.org/wiki/PID_Tuning