See Sending G-code for more information on how to send the commands below.
Usage:
M303 S<temperature> C<#cycles>
NOTE: Manually turn on the hotend fan before starting Autotune. M106 S200 will set the fan to about 75%. M106 S255 will set the fan to full speed.
Example:
M106 S200 M303 S210 C10
Note: Change the temperature (S value) to the temperature you anticipate using.
The above command will heat the nozzle and cycle around the target temperature 10 times (C10) at the given temperature (S210) and return the average values for P, I, and D.
Proceed to
M301 Set PID parameters below
Bed usage
M303 E-1 S<temperature> C<#cycle> Example: M303 E-1 S60 C5
Enter the values received after running M303 using M301 command
Newer firmware versions set the PID values returned by Autotune automatically.
The users must store the values to EEPROM with command “M500”
M301 P<Kp value> I<Ki value> D<Kd value> Example: M301 P20 I0.02 D250 ;Set new PID values M500 ;Save EEPROM Reboot printer to complete the process
Enter the values received after running M303 using M304 command
M304 P<Kp value> I<Ki value> D<Kd value> Example: M304 P10 I0.02 D305.4 ;Set new PID values M500 ;Save EEPROM Reboot printer to complete the process
References
http://reprap.org/wiki/PID_Tuning
http://reprap.org/wiki/G-code#M303:_Run_PID_tuning
http://reprap.org/wiki/G-code#M301:_Set_PID_parameters
http://reprap.org/wiki/G-code#M304:_Set_PID_parameters_-_Bed