Welcome! Log In Create A New Profile

Advanced

PID settings in marlin, how important are they?

Posted by matrix4721 
PID settings in marlin, how important are they?
October 04, 2013 11:07AM
Hiya
Basically i dont really know what PID settings are and i dont know if its something i should be messing with? i know its something to do with the hotend / heatbed but thats asfar i know. Im using the standard mk2 heatbed and jhead mkV hotend with a 12v 30amp psu and marlin firmware. Do i need to alter any settings? Kind regards. Chris
Re: PID settings in marlin, how important are they?
October 04, 2013 12:16PM
PID pulse-width modulates current to the hotend in order to keep it at a constant temperature (more or less). The other method simply applys current if the temp is too low and shuts if off if the temp is too high, the result being that the temperature is constantly either too low or too high. Since you have marlin firmware, PID configuration is easy! It can be done with a command such as "M303 C8 S175". That will run the PID tuning through 8 cycles at 175C. When it's complete, it will give you a Kp, Ki, and Kd value to plug into your firmware.
Re: PID settings in marlin, how important are they?
October 04, 2013 07:57PM
Hi, thanks for your reply, i entered what you put and it gave the following results

PID Autotune start
ok T:21.33 @:128
ok T:28.66 @:128
ok T:37.65 @:128
ok T:46.78 @:128
ok T:56.55 @:128
ok T:65.48 @:128
ok T:74.30 @:128
ok T:82.93 @:128
ok T:91.80 @:128
ok T:100.13 @:128
ok T:108.16 @:128
ok T:116.68 @:128
ok T:124.43 @:128
ok T:132.07 @:128
ok T:139.59 @:128
ok T:147.48 @:128
ok T:154.70 @:128
ok T:161.96 @:128
ok T:169.50 @:128
ok T:176.58 @:0
ok T:181.75 @:0
ok T:182.69 @:0
ok T:181.66 @:0
ok T:180.12 @:0
ok T:178.65 @:0
ok T:177.02 @:0
ok T:175.33 @:0
ok T:174.22 @:128
ok T:177.23 @:128
ok T:183.53 @:0
ok T:188.75 @:0
ok T:189.69 @:0
ok T:189.04 @:0
ok T:187.50 @:0
ok T:186.07 @:0
ok T:184.57 @:0
ok T:183.05 @:0
ok T:181.47 @:0
ok T:179.98 @:0
ok T:178.69 @:0
ok T:177.40 @:0
ok T:176.02 @:0
bias: 42 d: 42 min: 174.12 max: 189.69
ok T:174.77 @:42
ok T:174.12 @:42
ok T:175.02 @:42
ok T:176.35 @:0
ok T:176.67 @:0
ok T:176.00 @:0
bias: 36 d: 36 min: 174.10 max: 176.75
ok T:174.94 @:36
ok T:174.24 @:36
ok T:174.71 @:36
ok T:175.79 @:0
ok T:176.00 @:0
ok T:175.33 @:0
bias: 34 d: 34 min: 174.14 max: 176.21
Ku: 41.87 Tu: 11.14
Clasic PID
Kp: 25.12
Ki: 4.51
Kd: 34.99
ok T:174.38 @:34
ok T:174.28 @:34
ok T:175.00 @:34
ok T:175.85 @:0
ok T:175.67 @:0
bias: 34 d: 34 min: 174.06 max: 175.94
Ku: 46.18 Tu: 10.50
Clasic PID
Kp: 27.71
Ki: 5.28
Kd: 36.36
ok T:174.69 @:34
ok T:174.38 @:34
ok T:175.00 @:34
ok T:175.98 @:0
ok T:175.94 @:0
ok T:175.08 @:0
bias: 32 d: 32 min: 174.28 max: 176.06
Ku: 45.65 Tu: 11.00
Clasic PID
Kp: 27.39
Ki: 4.98
Kd: 37.65
ok T:174.34 @:32
ok T:174.39 @:32
ok T:175.23 @:0
ok T:175.81 @:0
ok T:175.38 @:0
bias: 32 d: 32 min: 174.18 max: 175.92
Ku: 46.91 Tu: 10.62
Clasic PID
Kp: 28.15
Ki: 5.30
Kd: 37.36
ok T:174.59 @:32
ok T:174.38 @:32
ok T:175.02 @:32
ok T:175.92 @:0
ok T:175.67 @:0
bias: 31 d: 31 min: 174.32 max: 176.00
Ku: 46.89 Tu: 10.75
Clasic PID
Kp: 28.13
Ki: 5.24
Kd: 37.80
ok T:174.79 @:31
ok T:174.18 @:31
ok T:174.69 @:31
ok T:175.54 @:0
ok T:175.69 @:0
ok T:175.13 @:0
bias: 31 d: 31 min: 174.18 max: 175.83
Ku: 47.74 Tu: 10.62
Clasic PID
Kp: 28.64
Ki: 5.40
Kd: 38.01
PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h

Which one do i put into the marlin firmware? also can this tuning be done for the heatbed too? if so what command do i use? thanks, chris
Re: PID settings in marlin, how important are they?
October 04, 2013 09:00PM
Put the last set in firmware, each cycle of autotuning should improve on the last.

Marlin doesn't, IIRC, use PID for the heatbed since its response is much slower and temperature fluctuations less of a problem, so bang-bang control is sufficient.
Re: PID settings in marlin, how important are they?
October 05, 2013 11:42AM
Thanks again for your reply, im gonna be abit dense, there appear to be multiple versions in the marlin firmware of pid settings

// PID settings:
// Comment the following line to disable PID and enable bang-bang.
//#define PIDTEMP
#define BANG_MAX 256 // limits current to nozzle while in bang-bang mode; 256=full current
#define PID_MAX 256 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 256=full current
#ifdef PIDTEMP
//#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 withing the PID
#define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine

// Ceramic Chess Hotend
#define DEFAULT_Kp 19.66
#define DEFAULT_Ki 1.41
#define DEFAULT_Kd 68.74

// Makergear
// #define DEFAULT_Kp 7.0
// #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12

// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki 2.25
// #define DEFAULT_Kd 440
#endif // PIDTEMP

which one do i alter with the new settings?
Re: PID settings in marlin, how important are they?
October 05, 2013 12:28PM
The lines starting in // are comments rather that code, so two of the three settings are just there to suggest possible useful values. The only actual PID settings are the ones under //Ceramic Chess Hotend, so change those.
Re: PID settings in marlin, how important are they?
October 05, 2013 12:32PM
>Marlin doesn't, IIRC, use PID for the heatbed since its response is much slower and temperature fluctuations less of a problem, so bang-bang control is sufficient.

Marlin does support PID on the heatbed and I'd recommend using it (I do). It keeps artifacts caused by the varying expansion of the heatbed out of your prints.
Re: PID settings in marlin, how important are they?
October 05, 2013 10:21PM
how do you enable the pid for the heated bed?
Re: PID settings in marlin, how important are they?
October 05, 2013 11:09PM
PID are standard terms in process control meaning Proportional,Integral & Derivative
The settings determine how the controller deals with temperature variations during printing.
Proportional refer to how the control system reacts , proportionally, to a temperature difference. If set at 100% a 1 % deviation of the temp will result in 1% more power to the heater. Set at 50% would result in 2% more power for every 1% temp deviation and so on.
Plenty of documentation on this subject. This is quite a nice simple explanation PID control
Worth a quick read as it will give you a better understanding of what your PID settings do

In short the answer to your question is yes . It is important for your settings to be optimised and the auto tune is a great feature.

One thing i would recommend if you truly want the best from autotune is that during the process you feed filament into your hot end ( only when its hot enough of course) and so simulate actual printing. Autotune on its own will give you a great starting point and this is often enough.

Good luck
Re: PID settings in marlin, how important are they?
October 06, 2013 12:30AM
so if i wanted to use pid on a third output, for instance a peltier unit that cools/ heats water, is this doable.
Re: PID settings in marlin, how important are they?
October 06, 2013 01:17AM
Yes depending on what control board you are using.
If your not at all sure i would recommend going with a separate Arduino board and a shield ( expansion board(s)) to drive your heater.
There's tons of Arduino tutorials and examples on the net

You'd also need to know and understand the characteristics of the temp sensing and heating device(s) but those are usually well documented as well.

Good luck
Re: PID settings in marlin, how important are they?
October 06, 2013 01:24AM
sheck626 mentioned artifacts in the prints due to variations in the temps of the heat bed. What might those look like?


Yvan

Singularity Machine
Re: PID settings in marlin, how important are they?
October 06, 2013 01:46AM
bigfilsing Wrote:
-------------------------------------------------------
> Yes depending on what control board you are
> using.
> If your not at all sure i would recommend going
> with a separate Arduino board and a shield (
> expansion board(s)) to drive your heater.
> There's tons of Arduino tutorials and examples on
> the net
>
> You'd also need to know and understand the
> characteristics of the temp sensing and heating
> device(s) but those are usually well documented as
> well.
>
> Good luck


Ive got the megatronics 2.0, it has 1 large mosfet for just the bed, and 4 regular mosfets as well as two thermocouple inputs and 3 thermistor inputs.
Re: PID settings in marlin, how important are they?
October 06, 2013 04:39AM
Well in theory by the look of things ( ive never worked with Megatronics so no practical experience) it may be possible.
You would definitely need to ensure your power supply can accommodate the additional load !

I think id still tend towards a separate board, perhaps triggered by your megatronics board or maybe even serial communication link.

Having it separate will ensure no ill effects are passed to the megatronics and certainly make development / fault finding a whole lot easier.

Good luck
Re: PID settings in marlin, how important are they?
October 24, 2013 02:42AM
PID is proportional-integral-derivative. It is a method of tuning feedback loops. Proportional part is like if the output goes past the setpoint, drop the current in proportion with what the temp is.
Integral part is to measure the slope of the curve of the output temp with respect to time and feed back accordingly.
Derivative part is to measure the area under the curve.

Using a combination of these feedbacks can make your temp controller very efficient, wrong settings can make it unstable and run into occilations.

I believe there are some tutorials out there for tuning the arduino pid loops for max efficiency.

The desired effect of the PID is to reach the temp setpoint as quickly as possible with minimal overshoot and max stability once the temp is reached.
Re: PID settings in marlin, how important are they?
February 08, 2014 04:57PM
OK. I can tune my extruder. Thank you very much. What is the command to autotune the heatbed? From all of the references that I can find for Marlin M-codes, M303 is the only autotune PID instruction documented. How can I command the controller to heat and tune the heatbed? Is there a way to address the heatbed using the M303 instruction? I am running Marlin on a Melzi controller (RepRapPro Marlin). Any help is greatly appreciated.
Re: PID settings in marlin, how important are they?
February 09, 2014 01:23AM
Usually you would send code something like this M303 E0 S230 C8 where E0 is your extruder S230 temperature and C8 number of cycles to perform and would recommend at least 8.
Hope this helps.
Re: PID settings in marlin, how important are they?
February 12, 2014 09:39PM
The heatbed is heater "-1", so calling for 8 calibration cycles around 80C on the heatbed would be:

M303 E-1 S80 C8

If you have multiple extruders, you can set the different E?? for the calibration, but the underlying PID shares the resulting kP, Ki, and kD values for all the extruders.

In other words, you can use M303 E-1 to find bed_Kp bed_Ki, and bed_Kd to set them with M304, versus M303 E0 for first extruder to find Kp, Ki, Kd, ams M301 to set the PID values for all your extruders.

[reprap.org] has some hints.

Edited 1 time(s). Last edit at 02/12/2014 09:59PM by DaveX.
Re: PID settings in marlin, how important are they?
February 12, 2014 09:46PM
What DaveX said. I completely forgot to mention that heatbed is E18 -).
Sorry, only registered users may post in this forum.

Click here to login