Tuning Hot End PID

Post your advice, tips, suggestions, etc...
Mount PrintMore
Posts: 34
Joined: Mon Apr 14, 2014 4:09 am

Tuning Hot End PID

Post by Mount PrintMore » Sun Apr 27, 2014 4:03 am

Hello,

I've noticed my hot end has a lot of overshoot when it comes on. I'm running an older 19V/12V machine with the ceramic hot end. My original heater was damaged and the one I'm running is a replacement that I built from the kit. Based on who put it together, the quality is dubious at best.

The settings that were in the firmware were P7.0 I0.1 D12.0 C0.13

My first question is does anyone know what exactly the "C" value is? The documentation I was looking at says is has something to do with extrusion, which doesn't seem right.
http://reprap.org/wiki/G-code#M303:_Run_PID_tuning

I thought I'd have a go at tuning the PID controller, as I read some claims there was an autotuning algorithm in Marlin.
So, the autotune fails because the temp error in the first attempt gets too high (it looks like it aborts at 20C overshoot). I have no idea what values it starts trying to tune with. Doing more digging, I read that other people have had these problems.

So, I began some trial and error tuning and have the following observations:
Even with P0.1 I0.0 D0.0 I get 15C of overshoot. This seems crazy. I've just been using M301 to set the values. I've also been using M500 to save them to the EEPROM. They echo back fine, so I believe it is taking them. Further, as I have tried various I and D values (ranging from I=0.1 to i=3 and D=6 to D=425) the response after the initial overshoot is very different.

I've done some runs with P set as high as 48 and can get the overshoot to increase as high as 24C.

To confirm my suspicion, I just did a run with P, I, and D all set to zero and the hot end still heated up with a 13C overshoot. i attached some screenshots of this behavior.

It is acting like there is some minimum value for P below which it is ignoring my commands. Is this possible?
Attachments
Overshoot2.JPG
Overshoot2.JPG (72.7 KiB) Viewed 22348 times
Overshoot.JPG
Overshoot.JPG (102.48 KiB) Viewed 22348 times

jsc
Posts: 1864
Joined: Thu Apr 10, 2014 4:00 am

Re: Tuning Hot End PID

Post by jsc » Sun Apr 27, 2014 5:30 am

Yes, there is a parameter in the firmware that determines at what point below the target temperature to switch from full on to PID control. I believe the default is 15C. You have two options: you can modify that setting to be lower to have PID kick in earlier, or you can modify the firmware to use less current to the hot end so that it doesn't overshoot. One or both of those settings may be settable through special M codes, I don't know.

Mount PrintMore
Posts: 34
Joined: Mon Apr 14, 2014 4:09 am

Re: Tuning Hot End PID

Post by Mount PrintMore » Sun Apr 27, 2014 1:16 pm

Thanks for the tip. A strategy like this makes sense as a simple way to manage error accumulation during the initial heat up.

I downloaded the marlin firmware files and have been looking through the config and advanced config files, however I don't see a parameter there like what you are describing. Can anyone shed some light on where these would be or what they are called?

jsc
Posts: 1864
Joined: Thu Apr 10, 2014 4:00 am

Re: Tuning Hot End PID

Post by jsc » Sun Apr 27, 2014 4:18 pm

In the version of Marlin that I am using (my own fork of the Marlin tree on github), I see PID_FUNCTIONAL_RANGE as the define in Configuration.h as the parameter I was referring to. It is set to 10.

#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.

You may also try playing with:

#define BANG_MAX 255 // limits current to nozzle while in bang-bang mode; 255=full current
#define PID_MAX 255 // limits current to nozzle while PID is active (see PID_FUNCTIONAL_RANGE below); 255=full current

Mount PrintMore
Posts: 34
Joined: Mon Apr 14, 2014 4:09 am

Re: Tuning Hot End PID

Post by Mount PrintMore » Sun Apr 27, 2014 8:09 pm

I'm looking in the firmware files downloaded from here:
http://makergear.wikidot.com/m2-firmware#toc0

I don't see either of these parameters in any of the files associated with that firmware. All I have is the PID_MAX.

I may need to send this discussion into support for guidance on what to do next.

Would you send me a link to the fork you are referring to?

Thanks!

ketil
Posts: 45
Joined: Wed Apr 09, 2014 9:58 pm

Re: Tuning Hot End PID

Post by ketil » Mon May 05, 2014 11:59 pm

A couple of days ago I finally got around to compiling the latest Marlin with modifications to fit the original M2 , including adding support for the M108 instruction. I also have the older machine (purchased late 2012), so since it works for me it should work for you. My clone of Marlin is at https://github.com/kefir-/Marlin.git and the branch with my modifications to get it working with the M2 is MakerGearM2-original-fw ("original" doesn't mean this is the original firmware, I mean it's the original M2).

Part of my reason for doing this was actually to increase the PID_FUNCTIONAL_RANGE. I haven't commited any changes to it yet, but I tested setting it to 50, and then 100, and it didn't seem to reduce overshoot much at all, if any. Even when I tried modifying the Marlin M303 PID numbers according to the formula for "No overshoot", and setting the PID functional range to 100, I still get a 10 degree overshoot.

http://reprap.org/wiki/PID_Tuning#Modif ... parameters

I'm no PID expert, but unless I'm doing something wrong, I find this is strange. As I'm watching the power as the heater is warming, and I can see that the power is reduced a little at T - 100 degrees, but the power remains on (at a low value) until the temperature is 10 degrees too high. Hopefully it's possible to tune this better, but I'm not there yet... Let me know if you figure it out (or get different results!), and I'll do the same. :)

jsc
Posts: 1864
Joined: Thu Apr 10, 2014 4:00 am

Re: Tuning Hot End PID

Post by jsc » Tue May 06, 2014 12:22 am

Did you run an M301 autotune and use those numbers?

Dale Reed
Posts: 376
Joined: Thu Apr 10, 2014 1:39 am
Location: Cleveland Heights, Ohio USA

Re: Tuning Hot End PID

Post by Dale Reed » Tue May 06, 2014 1:36 am

jsc wrote:Did you run an M301 autotune and use those numbers?
What Jin is referencing is the Autotune sequence built into the Marlin firmware of the M2. See http://reprap.org/wiki/G-code and http://blog.lincomatic.com/?p=773 (especially the former) for more info.

To simplify, the method is something like this:
1. Send:
M303 E0 S220 C8
This runs the autotune sequence, on Extruder 0 (E0), with a target temperature of 220C (S220), and runs 8 cycles (C8). Start with the temperature more than about 30 degrees below the target so it's outside the PID range and in the "bang-bang" control (full on) range.

2. Monitor the feedback from the M2 in your communication window. Look for the final autotune results, something like this:
.....
bias: 92 d: 92 min: 216.56 max: 223.75
Ku: 32.59 Tu: 54.92
Clasic PID
Kp: 19.56
Ki: 0.71
Kd: 134.26
PID Autotune finished ! Place the Kp, Ki and Kd constants in the configuration.h

3. Send:
M301 P19.56 I0.71 D134.26
(only use the numbers for Kp, Ki and Kd that get reported back to you) (but you already know how to do this).

4. To save those (and any other EEPROM parameters you've changed, like acceleration/jerk) so the M2 powers up with them next time, Send M500 (but you already know that one, too).

The thing you need is the M303. Also note the description of the "E-1" parameter for the M303 command and the M304 command, if you want to PID tune the bed temperature.
Dale

ketil
Posts: 45
Joined: Wed Apr 09, 2014 9:58 pm

Re: Tuning Hot End PID

Post by ketil » Tue May 06, 2014 7:11 am

If you're asking me, yes I've run M303 and then M301 with the resulting numbers. The only thing I haven't tried so far (that I can think of) is to run M303 with more iterations, until now I've only done the default of 3.

The numbers are being set, because after running M301 the undershoot following the initial overshoot is much smaller and stays within the 3 degree limit, so that saves me some time. But I still think this must be possible to improve on.

Have you managed to tune the PID parameters to avoid the initial 10 degree overshoot? What are your PID values? I get around 18, 1.3 and 58 when I run M303. When adjusting these for the "no overshoot" profile I set them to around 6, 1.3 and 155.

Mount PrintMore
Posts: 34
Joined: Mon Apr 14, 2014 4:09 am

Re: Tuning Hot End PID

Post by Mount PrintMore » Mon May 26, 2014 9:50 pm

I've tried to run the autotune, but it always fails I believe because the initial overshoot is so great it stops the procedure.

I sent in a request for help to MakerGear and got the following response:
----------------------------------------------------------------------------------------------------------------------------------------------------
The best approach is subjective; the two simple approaches would be to either use a new copy of Marlin, that has those PID settings that you would like, or to decrease the PID_MAX value in your current firmware. PID_MAX is the max power value that will be applied to the heater while heating (in both the active an inactive PID regions; also, for some reason it seems to be divided in half, so setting it to 255, you will only see a high of 127 reported when heating in Pronterface/S3D). Reducing PID_MAX will slow the heating down, giving you both a better shot at PID autotuning, and PID managing properly.
----------------------------------------------------------------------------------------------------------------------------------------------------
I haven't had a chance to mess with this yet, as my machine was down for some other issues (hbp thermistor failure), but it seems reasonable.

The only other input I have for this issue is that if you use your printer interface to go ahead and set the hot end to 200C prior to starting your SD Card print, it heats up and overshoots to 220 or so which is fine. Then, when the sd print gets going (it takes a while for the heated bed to warm up) the hot end only needs to warm up 20 or 30C, which results in much less overshoot.

Post Reply