Jump to content
Ultimaker Community of 3D Printing Experts
Sign in to follow this  
misguided

Testing PID auto tune

Recommended Posts

For those who don't frequent the mailing list, I'm looking for people to try a PID auto tuning routine that I'm working on.

The code is at:

https://github.com/j-c/Marlin

After uploading the firmware, you can start the routine by sending "M302 S190". 190 is the temperature that the firmware will attempt to use for tests. The code doesn't deal well with tests with low target temps (140-150).

The resulting PID values might not be perfect, but it gives a pretty good starting point (and takes a lot less effort on the user's part than the ZN tuning method).

What the routine does:

1) Firmware slowly increments the heater output and see what temps it hits. Repeat till specified temp.

2) Firmware waits for printer to cool down and stabilise. It assumes this is room temperature

3) Firmware then heats up printer with output determined in step 2

4) As the temps increase, the printer gathers the process dead time. As the temperature stabilises, the printer gathers process time and process gain.

5) Firmware calculates PID+A values and outputs them via serial.

Note1: All tests are run with fan on (firmware should turn it on).

Note2: If at any time, the temp hit 275 degrees, the firmware aborts the test, turns off the printer but leaves the fan running.... In theory this should work, but I've never been in a situation where this happened (nor did I particularly want to force it to happen).

The "A" number is the heater output filter. It's not in standard Marlin, I just left it in there for testing.

If anyone tries this, could you please report back with any problems that you encountered, and also:

 


  • [*:2id0yiuh]The final PID values
    [*:2id0yiuh]Process gain
    [*:2id0yiuh]Process dead time
    [*:2id0yiuh]Process time
    [*:2id0yiuh]Temperature used and actual final temperature
    [*:2id0yiuh]If you have an insulated hot end (and what kind) or if your hot end is non-standard

 

For me, the untouched numbers this give me temps that are stable when not printing, but a 6 degree drop when printing (this can be mitigated by setting the "C" extrusion speed multiplier or Kc in the firmware config).

Thanks!

Hopefully this works for others as well and I can continue on with this approach.

Share this post


Link to post
Share on other sites

This is my most recent results Joel

[08] Machine stop called.

[08] Building...

[08] Estimating build time...

[08] Estimated build time is:

[08] Beginning build.

[08] echo: auto tuning pid values...

[08] echo: please keep watch over your printer and be ready to shut it down if it acts strangely.

[08] echo: discovering what controller output is required to reach 193c

[08] Yes, I have a Realtime Control feature.

[08] Supports RC

[08] echo: highest temp: 63

[08] echo: highest temp: 63

[08] Yes, I have a Realtime Control feature.

[08] Supports RC

[08] Done building.

[08] echo: highest temp: 63

[09] echo: highest temp: 407

.

.

.

[09] echo: highest temp: 414

[09] echo: temperature stabilised at: 202.15 (co: 105)

[09] echo: attempting to establish ambient temperature

.

.

.

[09] echo: highest temp: 396

[09] echo: final temperature: 193.36

[09] echo: 63% pv: 249.48

[09] echo: pv: 396 5468677ms

.

.

.

[09] echo: pv: 248 4867730ms

[09] echo: process time: 4869.70s

[09] echo: echo: process gain: 3.00 (deltapv: 332)

[09] echo: computed values:

[09] echo: kp: 3.000000000

[09] echo: tc: 4869.703613281

[09] echo: ti: 4874.203613281

[09] echo: td: 4.495845317

[09] echo: calculated p:333.025878906 ,i: 0.068324155, d:1497.232788085 a:999.08

[09] echo:

[09] echo: warning! pid settings were merely computed. to use them, please enter the following command:

[09] echo: m301 p333.025878906 i0.068324155 d1497.232788085 a999.077636718

Does that M301 right to enter?

Share this post


Link to post
Share on other sites

I put in the values and did some calibration prints at 183. They went very good though I had to turn the extruder RPM up a bit

When I printed at 183 it stopped extruding part way through on the down skins

I went back to 193, which had been oozing out extra material in patches on the down skins (I thought possibly by going over temp but not sure)

It printed very well onto top of the layers I already had there from the failure at 183.

No big patches of blobbing.

So it's possible it may have stopped the temp from overshooting.

Not too sure yet as I don't measure temp once I start printing.

I will be printing another copy of the same thing tomorrow from scratch (No layers already underneath)

As this has consistently been giving some blobbing lately on the down skins, more so with the Blue PLA, I will see if it's better or not and let you know.

Short story is so far so good.

Thanks for your efforts Joel.

Owen

Share this post


Link to post
Share on other sites

Thanks for the update Owen.

Yeah, the values need a little bit of tweaking to work for prints. It's more likely to undershoot than overshoot... I still haven't figured out how to mathematically tweak the values to cause it overshoot slightly while remaining stable.

You can modify the "C" extrusion speed bias (I think in Bernhard's branch, you need to modify and upload the firmware to change it). WIth my PID tuning firmware, M301 C0.17 will set the C bias (0.17 worked for me, but your mileage may vary). The higher it is, the harder it'll drive the heater based on your extruder speed.

Having said that, my fork's temps might behave a little differently. I added an error bias (seems to help) and a filtering factor (I can't tell if this makes a difference).

Share this post


Link to post
Share on other sites

I tried PID tuning on my Mendel today. It's a Prusa Mendel with Ramps1.4 and a 100k NTC-based hotend (reprap-fab). After hacking in the pin configuration for the Ramps and setting the Thermistor, i started the tuning process. My workshop is pretty cold atm, and i regularly run into MINTEMP at the start of a print, so i didn't think much about the initial "some value is too high" error, which went away after heating up the hotend a bit.

So when the tuning started, the hotend did heat up, but it reported the maximum raw temperature as 988, and the current temperature was dropping - I guess the tuning process ignores any thermistor/thermocouple setup made and just looks at the raw values. However, for an NTC this doesn't work. At all.

I guess i'll have to set up PID the hard way then.

-Tom

Share this post


Link to post
Share on other sites

I think this is what you want

SENDING:M302 S190

echo: Auto tuning PID values...

echo: Please keep watch over your printer and be ready to shut it down if it acts strangely.

echo: Discovering what controller output is required to reach 190C

.

.

.

echo: Highest temp: 275

echo: Temperature stabilised at: 134.28 (CO: 55)

.

.

.

echo: Highest temp: 312

echo: Temperature stabilised at: 151.86 (CO: 65)

.

.

.

echo: Highest temp: 347

echo: Temperature stabilised at: 169.43 (CO: 75)

.

.

.

echo: Highest temp: 381

echo: Temperature stabilised at: 186.04 (CO: 85)

.

.

.

echo: Highest temp: 416

echo: Temperature stabilised at: 202.64 (CO: 95)

echo: Attempting to establish ambient temperature

.

.

.

echo: Lowest temp: 66

echo: Room temperature: 32.23C, raw: 66

echo: Determining base tuning constants.

echo: Heating printer. Heater pin set to 95

echo: Process dead time: 16.00s

echo: startMillis: 4359966

.

.

.

echo: Highest temp: 412

echo: Final temperature: 201.17

echo: 63% PV: 259.56

echo: PV: 412 5301439ms

.

.

.

echo: PV: 255 4540238ms

echo: Process time: 4547.25s

echo: echo: Process gain: 3.00 (deltaPV: 346)

echo: Computed values:

echo: Kp: 3.000000000

echo: Tc: 4547.253417968

echo: Ti: 4555.253417968

echo: Td: 7.985950469

echo: Calculated P:332.748962402 ,I: 0.073047294, D:2657.316650390 A:998.25

echo:

echo: WARNING! PID settings were merely computed. To use them, please enter the following command:

echo: M301 P332.748962402 I0.073047294 D2657.316650390 A998.246826171

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

Terms of Use Privacy Policy