PID tuning

Juho A

TVWBB Member
Finally had some time again to do some BBQ'ing, did a small piece of brisket today. Here's how it went:
20200913_183529.png

So, I started the heatermeter as soon as the coals were lit, and it got up to the set temp pretty nicely. When it was up to temp, I put in the ~1kg of brisket along with about 1m5 litres of boling water in the heat deflector pan. It took almost half an hour to get back up to temp. Then it started dying slowly to the point where heatermeter thought the lid was open (around 14:15 in the pic) and I had to manually put the fan to the max to keep it from dying completely. Then I started adjusting the fan parameters. Still it would be either below or above the setpoint, so I started adjusting the PID parameters.

These were what I started the cook with:
P=1.25, I=0.00175, D=3
FAN on above 10%, min 10% max 40%

And I already had adjusted the FAN to Max 100%. Following the "experimental tuning" instructions here: https://github.com/CapnBry/HeaterMeter/wiki/PID-Tuning I calculated that the P value for me should be 20 (100/5, as if my kamander's temp goes 5C below setpoint, the fire is dying, so I want it to be "all in" at that point). I also increased the I to 0.00575, but felt that it was a bit too "nervous", constantly adjusting quite drastically on all values, so I put it to 0.00375 which seemed to help a bit. The temp didn't seem to lower to the setpoint, with the output always rising a bit too high bit too fast for it to be able to settle, so I increased the D to 10. The instructions say that "it's proportional to P", but not exactly how, I mean should it be exactly the same as the P or proportional how?

Anyway, at this point my brisket's temp was at 90C so I took it out. I think my PID adjustments moved to the right direction, but I am not sure if they are perfect yet. Besides the D value, I am wondering about what I can see from the "debug window"; the I value seemed to remain around 29% pretty constantly, so does that mean that it is OK, or where should it be?

The brisket is still resting, I will have a taste a bit later. :)
20200913_180036.jpg
 

GSpinelli

TVWBB Member
A P value of 20 is almost surely too high (which is probably why it seemed too twitchy). The P value is multiplied by temperature error. Fun to experiment with tunings, but hard to dial in because most smokers respond slowly, take a while to stabilize, and are not consistent due to variable amount of lit coals.
I find it easier to tune with D set to zero initially until you get a response you are happy with. And then tweak it with D.
 

Bryan Mayland

TVWBB Hall of Fame
PID Tuning, giving us all something to claim we're doing when we sit all day and watch the graph!
P=1.25, I=0.00175, D=3
FAN on above 10%, min 10% max 40%
I wouldn't change Fan Min unless your blower has a hard time reliably staying running at 1% power. When under 10% output, it will turn on and off which usually creates a little change in temperature as it forces hot air up, then turns off and runs too cool again until that heat builds back up. "Fan on above 10%" is ok, assuming you have a damper, but it is pretty low to have the fan come on if you're staging the damper then the blower.

The instructions say that "it's proportional to P", but not exactly how, I mean should it be exactly the same as the P or proportional how?
That means that once you have a ratio of P to D that you don't get overshoot and you don't get undershoot (where the peak occurs without passing the setpoint) then that ratio will also be effective if you lower or raise the gains. Let's say you have a P of 1.5 and a D of 3.0 and it works great but takes too long to react. You'd just up the two values proportionally, maintaining the same ratio, so like P of 3.0 and D of 6.0, or 4.5/9.0 or 2.25/4.5 etc. If you just up the P to 3 and leave the D 3, your ratio is now different and you'll likely have overshoot because the D is the D that gives you no overshoot for a P of 1.5. The P and D terms have this sort of interaction with each other.

I am wondering about what I can see from the "debug window"; the I value seemed to remain around 29% pretty constantly, so does that mean that it is OK, or where should it be?
Yeah the I term is what marketing refers to as "learning" when a temperature controller makes this claim. It "learned" that your grill in that setup, for that setpoint, required about 29% output to remain at temperature. The P and D are just there to adjust to disturbances and changes in setpoint and the I is what really keeps any oscillations around the setpoint. The Isum value is sort of an indicator of what load your smoker is under. Close to 0 HeaterMeter isn't doing much control, the smoker is running too hot on its own. Close to 100 means you're overloaded which means you're probably running out of fuel. If it is consistently very low (<5%) across cooks, then you might consider lowering the amount of fuel you use, or closing any vents a bit more. If it is always very high (>75%) then do the opposite, use more fuel or open the exhaust vent a bit more.
 

Juho A

TVWBB Member
A P value of 20 is almost surely too high (which is probably why it seemed too twitchy). The P value is multiplied by temperature error. Fun to experiment with tunings, but hard to dial in because most smokers respond slowly, take a while to stabilize, and are not consistent due to variable amount of lit coals.
I find it easier to tune with D set to zero initially until you get a response you are happy with. And then tweak it with D.

Thanks. I actually don't really have any desire to tweak the PID settings, but it seems like I still haven't really gotten it dialed in to a working setting. I tried with some el cheapo thermocouples first, but decided just to go with the thermoworks thermistors as they seem to work reliably and I bought two of them. I ended up with 20 for the P value from this instruction here: https://github.com/CapnBry/HeaterMeter/wiki/PID-Tuning
P Here's the easiest place to start. Think about what the acceptable temperature range is for operation. At what point of the pit temperature dropping do you want BWOOP BWOOP giver 'er all she's got, Captain! Divide 100 by that number. That's going to set the lower limit on the P value. For a setpoint 225F with a lower temperature limit of 215, P = 100/(225-215) = 10. That's your ballpark. The faster your grill can change temperatures by changing the output value, the smaller this number should be. In my graph the P was 3 because the blower can really turn things around quickly in there. With just the servo, if I opened it fully it would still take a long time before anything actually happened. Fast response, low P. Slow response, high P.

But I guess I could live with 10 too, I just figured that with Celsius, 5C drop means that the fire is on its way out, so that's why I reasoned it needs to be "all in" at that point, thus I put 20. I am afraid if I accept a 10C drop in temperature, the fire will surely be dead by then, and cannot be resurrected with a blower, whereas from -5C drop it could.
 

Juho A

TVWBB Member
PID Tuning, giving us all something to claim we're doing when we sit all day and watch the graph!

I wouldn't change Fan Min unless your blower has a hard time reliably staying running at 1% power. When under 10% output, it will turn on and off which usually creates a little change in temperature as it forces hot air up, then turns off and runs too cool again until that heat builds back up. "Fan on above 10%" is ok, assuming you have a damper, but it is pretty low to have the fan come on if you're staging the damper then the blower.

Thanks. I actually ended up with these settings in the last 2 hours of the cook, but I see that I didn't express these as clearly as my initial settings. So this is where I am currently at:
P=20, I=0.00375, D=10
FAN on above 20%, min 10% max 100%

I am not completely sure about the fan, but I think I set it like that in an effort to reduce the twitchiness. I do have the fan as well as the servo, it's the microdamper with my custom adapter to the Char-Broil Kamander.

That means that once you have a ratio of P to D that you don't get overshoot and you don't get undershoot (where the peak occurs without passing the setpoint) then that ratio will also be effective if you lower or raise the gains. Let's say you have a P of 1.5 and a D of 3.0 and it works great but takes too long to react. You'd just up the two values proportionally, maintaining the same ratio, so like P of 3.0 and D of 6.0, or 4.5/9.0 or 2.25/4.5 etc. If you just up the P to 3 and leave the D 3, your ratio is now different and you'll likely have overshoot because the D is the D that gives you no overshoot for a P of 1.5. The P and D terms have this sort of interaction with each other.

Ok, so I wonder if my P of 20 would be completely off then... I mean, this is celsius, so that was what the formula gave me. But if D is supposed to be double from P, then I guess P of 20 would be too much, as that would mean a D of 40. Perhaps next time I should try P=10 and D=20?
 

Bryan Mayland

TVWBB Hall of Fame
Yeah you're right about the P term, the default is 5 therefore the default for Celsius would be around 9, so 20 isn't as far out as one might think. You can tell if it is too high by getting close to temperature then setting the I and D to 0 and just run with the P for an hour. If the P is too high it will oscillate where each peak's amplitude gets larger and larger. If P is too small they'll get smaller.

D isn't supposed to be double what P is, unless that's what it is supposed to be. I'd start with both of them equal. Discard the initial heatup bit and look at any oscillation while maintaining temps. If the temperature is going back and across the setpoint by a lot, then you probably need more D. If it reverses direction before it crosses the setpoint, you need less D.

This assumes your I is in the right ballpark too. If you see a lot of change in the Isum in the PID debug panel, it probably isn't right. That's a tougher one to figure out because your P and D have to be right first-- the I will soak up a lot of mistakes there but it is very slow to react so any error it absorbs will take a long time to unwind. A wrong I looks a lot like D being too low, but happens more slowly.
 

Juho A

TVWBB Member
PID-settings.png

Ok, now I did another cook yesterday (ribs) and I decided to input new values a bit closer to the defaults. This seemed to work fine, the only problem I had was that I didn't start with enough fuel, so it died midway. Anyway, today I decided to reheat the ribs, and then heat the kamado up a bit more to clean the grate.

I started with a thermoworks thermistor probe as pit probe, no thermocouple at all. This worked well, it was fully stable at 150C the whole time I re-glazed and heated the ribs:
20200927_175406.png
When I took out the ribs, I decided to put in the thermocouple probe and use that as a pit probe, to get a bit of data on the difference between the thermoworks thermistor and the el-cheapo amazon-thermocouple. As you can see from 16:25 onwards, the thermistor reacts way faster and shoots over a bit, but then stabilises pretty much to what the thermocouple was at 150C. I then adjusted to 250C, and honestly got a bit worried when the temperature difference of the two probes was more than 20C - the Thermoworks probe is max.300C, and I don't want to destroy it. Thus I adjusted the temp to 235C. The pit seemed to stabilize to this temperature, and eventually the thermoworks thermistor got closer to the thermocouple's reading, but perhaps a 10C still between them.

So, I guess the question is; which one to trust? I am inclined towards trusting the thermoworks' readings, and as it's faster to react, I would imagine using it would prevent overshoot. But then again, I did spend the money on a thermocouple-heatermeter, so I would like to be able to use that, and as I only have two of the thermoworks probes, I would like to put both of those in meat at some point. So, should I just toss this thermocouple and get another? Any suggestions on a good thermocouple available on amazon in Europe?
 

Top