Hotend overshoots June 14, 2014 01:08PM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots June 14, 2014 02:19PM |
Registered: 11 years ago Posts: 1,381 |
Re: Hotend overshoots June 14, 2014 02:35PM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots June 14, 2014 04:05PM |
Registered: 11 years ago Posts: 1,381 |
Re: Hotend overshoots June 16, 2014 03:11AM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots June 16, 2014 10:22PM |
Registered: 12 years ago Posts: 258 |
Re: Hotend overshoots June 17, 2014 07:35AM |
Registered: 10 years ago Posts: 330 |
Quote
DaveX
You using Marlin? And a heater cartridge?
If you are using a cartridge and you are heating by 3-5C/sec near the operating point, which might be too much for the autotune. You also could reduce the maximum power by
I think this overshoot could be because of a too-small PID_FUNCTIONAL_RANGE in Configuration.h The default is +/-10C per [github.com] -- If you are overshooting by 35C, then I'd think the range should be at least 35C, and your kP term should be a maximum of 255/35=7 or so.
If it is set too tight, then it is BANG-BANG until it hits setpoint-PID_FUNCTIONAL_RANGE, then resets and tries to start the up the PID from zero, and you get odd PID behavior.
If you are heating fast compared to the range, the PID doesn't have time to work, and when you could overshoot SETPOINT+ID_FUNCTIONAL_RANGE and switch into BANG_BANG off mode until it cools off back into range, where it resets the PID internal variables to zero, and then cools further to below setpoint where it the PID starts accumulating some I-term errors. It probably settles from above because cooling is slower than heating and the PID has enough time to begin to work.
I'd suggest using less aggressive PID values (guessing Kp<7, Ki < 4, Kd<0.5 ) values and make sure PID_FUNCTIONAL_RANGE is set to at least 255/kP so that the PID can transition smoothly from BANG_BANG into PID controllable operation.
On the other hand, if your PID_FUNCTIONAL_RANGE is too wide, overshoot could be cause by integral windup, which could be reduced by reducing the Ki term.
Re: Hotend overshoots June 17, 2014 01:20PM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots June 17, 2014 02:58PM |
Registered: 12 years ago Posts: 258 |
Quote
drmaestro
Here's an update on what I did:
I've checked PID_FUNCTIONAL_RANGE and it was set at 10 as DaveX mentioned. I've set it at 35. Tried to run the autotune which failed again (overshot by 35 degrees). So, I've tried to lower PID_MAX and BANG_MAX values to half of their original settings (original=255, set value=128). This helped a lot, as I have been able to run the autotune. It only overshot by 4-5 degrees while autotuning and gave me PID values.I wrote these values to EPROM and gave a command to set the hotend at 220 degrees to be sure that it was working as intended. I was quite surprised to see that it was still going past the desired temperature point by 20 degrees. At that point I was quite disappointed, as in theory I couldn't understand why it didn't work. I decided to use lower PID_MAX and BANG_MAX values (65). Autotune was sucessful (2-3 degrees overshot). I've inserted the suggested PID values and gave the command to set the hotend at 220. This time, it overshot by only 3-4 degrees and stabilized. So, I am happy to announce that it is working as intended right now.However these very low PID_MAX and BANG_MAX values suggest that I might have a wrong type of heater cartridge. Is it overpowered?
Re: Hotend overshoots June 17, 2014 03:45PM |
Registered: 10 years ago Posts: 330 |
Quote
DaveX
I edited my text above to add: "You also could reduce the maximum power by (ETA reducing BANG_MAX or PID_MAX from 255 (see around [github.com] ) depending on whether you want to limit the behavior on the way up into PID_FUNCTIONAL_RANGE or within the PID controller."
Quote
drmaestro
Here's an update on what I did:
I've checked PID_FUNCTIONAL_RANGE and it was set at 10 as DaveX mentioned. I've set it at 35. Tried to run the autotune which failed again (overshot by 35 degrees). So, I've tried to lower PID_MAX and BANG_MAX values to half of their original settings (original=255, set value=128). This helped a lot, as I have been able to run the autotune. It only overshot by 4-5 degrees while autotuning and gave me PID values.I wrote these values to EPROM and gave a command to set the hotend at 220 degrees to be sure that it was working as intended. I was quite surprised to see that it was still going past the desired temperature point by 20 degrees. At that point I was quite disappointed, as in theory I couldn't understand why it didn't work. I decided to use lower PID_MAX and BANG_MAX values (65). Autotune was sucessful (2-3 degrees overshot). I've inserted the suggested PID values and gave the command to set the hotend at 220. This time, it overshot by only 3-4 degrees and stabilized. So, I am happy to announce that it is working as intended right now.However these very low PID_MAX and BANG_MAX values suggest that I might have a wrong type of heater cartridge. Is it overpowered?
Autotune bypasses PID_FUNCTIONAL_RANGE so changing it won't fix Autotune overshooting, but the lowering of PID_MAX slowed the heating enough for autotune to notice it. (See around [github.com] for the code)
The remaining overshoot is likely due to some level of "integral windup", which could be reduced by lowering your kI term some.
There is [reprap.org] , but for simple I think the PID parameters are easiest to understand if you can think about them with proper units: they just convert the proportional, integral and derivative error measurements into output units, and the output units are in n/255 fractional units of full scale output.
Practically, if you have a 40W cartridge heater, each 'count' of output is worth 1/255*40W, or 0.15W of power. With a PID_MAX==65, this limits your cartridge to about 10W maximum.
The Kp term is in units of counts/degreesC of error, so the at setpoint-35C, the error is 32C, so with Ki==7counts/C , then 35C*7counts/C=245 counts, or 245/255*40W=38W, but the sum of the various terms is limited to your PID_MAX=65. Maybe you should limit the PID_FUNCTIONAL_RANGE to PID_MAX/Kp instead of the 255/Kp I told you above, because having a too-wide range can cause "integral windup" form the Ki term....
The Ki term is in units of counts/(C*s) and converts the area under the temperature curve from when the PID initializes, into counts. If you were rising by about 4C/s at 40W, then you might be rising by about 1C/s with 10W, and the area of the triangle from SP-35 to SP might be an integrated error of 35seconds * 35C / 2 = or 612.5 degreeC-seconds, which is then converted into counts by Ki (I assumed Ki=4 above) so 4*612=2450 counts (or 384Watts), which gets clamped to INTEGRAL_DRIVE_MAX/Ki = 255/4=63C*s or 63Cs/255*4counts/Cs*40W=40W within the PID routine (see [github.com]) and further by PID_MAX in the summing part of the routine. The integral cannot start reducing itself until you overshoot, so this contribution is maxxing out against the 10W limit until the process overshoots.
The Kd term is in units of counts/(C/s) which projects the slope of the curve into the future and converts it into a penalty in counts to take away from the output, anticipating future rise. With the low Kd=0.5 I guessed, times the 1C/s rise I am also guessing, 0.5*1=0.5 counts, which is effectively a zero watt penalty. if Kd were bigger than 0.5, it could project the slope further in the future and reduce the output accordingly. Kd=63counts/(C/s) would be too much-- a 1C/s slope would reduce the output by 63 counts or 63/255*40W=10W, completely offsetting the proportional term and shutting down the power at the beginning.
With my guessed numbers, the system seems destined to produce overshoot like you see. I think I'd advise resetting your PID_FUNCTIONAL_RANGE to your chosen PID_MAX/Kp, so you get a smooth transition at SetPoint-PID_FUNCTIONAL_RANGE, and the integrator can start from zero at the time the proportional term begins to taper off from full power. You could try adjusting INTEGRAL_DRIVE_MAX down some, but that could make the system 'droop' if if you actually need more than INTEGRAL_DRIVE_MAX/255*40W to maintain temperature. I think it is better to use something like [github.com] but I haven't tested it much.
Balancing the Config file parameters against the Kp, Ki, and Kd parameters to get textbook behavior is overly confusing.
As for overpowered? A properly-tuned PID should be able to handle a 40W heater just fine, but it needs a wide enough range and small enough parameters to do it properly. Maybe the autotune would work fine with a fast heater by using a higher upper temperature limit at [github.com] but a 35C+ or more overshoot during the autotune process could be dangerous.
What values did the autotune end up giving you?
Re: Hotend overshoots June 17, 2014 04:53PM |
Registered: 12 years ago Posts: 258 |
Re: Hotend overshoots July 05, 2014 04:17AM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots July 07, 2014 02:14AM |
Registered: 12 years ago Posts: 258 |
Re: Hotend overshoots July 08, 2014 01:14PM |
Registered: 10 years ago Posts: 330 |
Quote
DaveX
Does it get back up to temperature with the current PID_MAX, or does running the fans max out the heater at PID_MAX and then then temp fades to some lower than setpoint steady-state? If the former, maybe try coming to temperature with the fans on. If the latter, rather than the PID not reacting fast enough, it may be more that the power in is less than the power required to hold temperature and you would need to up your PID_MAX.
I think you could record your working PID values and re-use them with a larger PID-MAX. The PID values are not scaled by PID_MAX, but are in counts/C, counts/(C*s) and counts/(C/s), with the PID_MAX constraint imposed afterwards.
If you are still using a PID_MAX=65, your 40W heater is limited to 10W max, so changing to a 30W with the same PID_MAX 65 would do a 3/4scaling and deliver only 7.6 W and be even slower, or you could scale up PID_MAX bu 4/3 to 86 to get the same 10.6W with a 30W (and you have to multiply your PID values by 40/30) to get the same behavior. It would also give you 4/3 more resolution: (0 to 85/255) >>2=43 settings rather than to 65/255)>>2=32 settings currently, but that isn't a big deal.
If you are doing PLA at 185, and are only going to safely autotune far from the temperature limits of your hotend, you could increase the 20C guard value at [github.com]
You could also try tuning with the fans on, since they have such a big effect on the heat transfer away from the system,
Re: Hotend overshoots July 08, 2014 01:19PM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots July 08, 2014 05:11PM |
Registered: 12 years ago Posts: 258 |
Re: Hotend overshoots July 08, 2014 11:01PM |
Registered: 10 years ago Posts: 466 |
Re: Hotend overshoots July 15, 2014 02:29PM |
Registered: 10 years ago Posts: 330 |
Re: Hotend overshoots July 19, 2014 11:22AM |
Registered: 10 years ago Posts: 3 |