PID Tuning help


 
The bias is something I added that you rarely see in PID designs. It is a raw value that is added to the calculated percentage fan speed. Let's say you're right at your setpoint (current - set = 0) and there's no change in temperature so the calculated fan speed of 0 * P + 0 * I + 0 * D = 0%. The B term (let's say 4) is added on so the fan would be on at 4%.

The reason I added this is because the I sum can only decay (get smaller) if the calculated speed is above 0%. What I was seeing was that the I sum would grow when the temperature was below the setpoint and the temperature would go past the setpoint. Then, because everything else was 0, it would stay above the setpoint for a really long time because the "I" had basically overshot the temperature and there was no way to reduce its value. I added the B term so the "I sum" can actually start decaying at ~1.33F (PidB divided by PidP) above the setpoint.

It is safe to set it to 0, most likely without any negative effects.
 
I'm not sure what you're asking, duration? The max limit is just if the calculated fan speed value is greater than max, then use max instead.
 
Marlin,

Let me make an analogy for the PID and maybe it can help. This isn't meant to be demeaning, but maybe it is easier to understand so please understand my intent is pure. :)

You - PID alogrithm
your buddy - fan

Imagine you and your buddy want to get the smoker to 200F. You start the fire and your buddy doesn't fan at all. You look at the temp and say I"m not at 200, start fanning. You buddy starts fanning and you see the temperature increase. You say fan harder, he says "can't I'm fanning as fast as you will allow", he hit your max fan limit. So you just have him keep fanning at that speed until the temp starts getting close to 200. Knowing that the smoker will continue increasing in temp even after he stops fanning you tell him to stop fanning. Temp rises, but slower. It crosses 200 and you think "durn overshot 200, next time I'll stop fanning sooner". When it goes under 200 you'll say start fanning again, the temp drop stops and starts rising, this time though you remember to tell him to fan less hard and your overshoot (temp over 200) is less. You learn this as well. . . . repeat until you and your buddy get it down to a science. Now you can tell him to fan less hard, less frequently and keep the temp at 200.

Basically that is what the PID algorithm does. The "remembering" is the error portion of the PID, the error is all it calculates. It looks at your set point, previous readings/error and calculates a new error. It then changes its output (fan speed) to try and reduce that error. That is exactly what you are doing in the example above. So that shows how max fan speed applies to the equation. Basically with a higher fan speed you could have increased the temperature faster, though you would also experience a larger overshoot.

Now let's talk about the frequency with which you do the PID calculations. In the example above you were there watching constantly and making corrections "immediately". In the next example we will reduce frequency with which you calculate new outputs, thereby increasing the duration of the output between changes. If you take a look at the temp tell you buddy keep fanning, then go inside for a drink and 30 minutes later come back to see your buddy (still fanning like crazy) you'll be way over 200F and you tell him stop fanning. Then you go away for another 30 minutes and come back to see him just sitting there not fanning and it is way under 200F so you tell him to start fanning. You can imagine that you may never get close to the 200F target you have set because your not paying close enough attention.

This is an example of what happens if we don't have the PID algorithm update frequently enough, the smoker is just uncontrollable. I think Bryan has the update around the 1 per sec range, though I'm not positive. This is what I understand you question as to the "duration" of the PID controller output. The time between updates. So the max fan speed is related to the reaction of the smoker, but not directly related to the PID algorithm, nor how often it updates. A max speed < 100 will make the system a little slower to respond to temp increase, but at the same time will make it a little easier to control.

One thing to remember about a PID algorithm. It assumes that the smoker will rise in temp at the same rate that it will decrease in temp. Most smokers are not symmetric and so this can cause error with PIDs. That is why I tend to reduce my max fan speed. It is an attempt to even out the temperature rise time verses its fall time.

Hopefully this helps someone out there,
dave
 
I wrote a sketch that used the osPid Autotune library and their PID library to see how it held. It would be possible to somehow build a sketch that does it and have the Pi flash it, but I'm not sure how useful it would be for all the work.

One could also write one in userspace, like a script that runs by just listening to the output of the linkmeterd and sending manual fan speeds.
 
For version 8 what are the default PID parameters? I've been playing around with my settings trying to get rid of some oscillation (without much luck), and would like to go back to the default settings (which I don't have written down). Thanks.
 
Thanks. Started the cooked last night and finished up this afternoon after around 15 hours (brisket). There's still some oscillation, but the stock PID values seem to work just about as well as anything. Actually I cut the P from 3 to 2 so that the derivative wasn't overpowered by the proportional, but besides that they were the default values.

Edit: I should have mentioned that this was on a Char Grill Kamado and was using lump for fuel.


Brisket6-30-13_zps5ea2085d.jpg
 
Last edited:
I did a long test run (16 hours) on my Heatermeter (thanks again Bryan) with a case (thanks again Tom) with a Rotodamper (thanks again Ralph - does anyone see a trend here?). I have a large BGE. I was using the PID Debug screen to try and dial in my PID settings and I think I made progress, but just wanted to confirm a few things and ask a few questions. The questions are a little disjointed, so bear with me.

1. First, I figured out that on the debug screen, adding up the three numbers equals the fan percentage. I was having overshoot problems followed by undershoot problems followed by overshoot problems, etc. I raised my D because I understand it tries to predict the future and I did see some preemptive correcting going on after that but I was not getting the really tight control like some o the graphs Ralph has posted. I think my primary problem is that the BGE is slow to respond (maybe because of the mass of the ceramics) but once it responds, it is very sensitive to airflow so a little goes a long way. The cycle I was experiencing is the temp would drop, the fan would crank up, the response was slow so the fan would crank up more and then the temp would start rising slowly. Then finally the fan would stop a couple degrees from target but by that point it had already pumped enough oxygen in to overshoot by sometimes 25 degrees for a good 15-20 minutes. When the temp would start dropping, I would get the reverse - the drop would accelerate and the fan wouldn't really kick in until the temp went under the setpoint and by that time it would take a while to correct and the cycle would start over again. I felt like the algorithm wasn't good at looking back in time far enough for the "cause" of its current status. I finally dialed in my settings at B=0, P=2, I=0.002, and D=7. These look substantially different than a lot of the successful PID settings people have posted.

2. The above settings were pretty stable, but I noticed 2 things and have 2 questions. First it was way more stable at 250* than at 225*. Is it possible that my egg might just have a hard time with 225*? I think I have it pretty tightly sealed, but maybe not, and the rotodamper should help with this.

3. The other thing I noticed is that it was pretty stable with these settings but at all setpoints, it would stabilize around 2 degrees below the setpoint. That baffled me, so if anyone has any ideas, I would appreciate hearing them.

4. Here is a question I have been wondering about. Is the PID algorithm a "learning" algorithm? In other words does it dial itself in over time as it learns from its overshoots and undershoots and then "remember" that the next time you use it? I ask this, because I thought I saw the amplitude of the overshoots and undershoots getting smaller before I was changing settings. If it does learn, maybe I should reset back closer to the defaults, fire up the egg and just let it go for a while without fiddling with the settings so it can learn without me switching the variables/inputs all the time.

5. Ralph and Bryan have talked about damper only mode. All my testing was with the fan. For 225*, should I try damper only? If so, how do I do that? Just check the box that says "on at max only" for fan speed? If I do this, will I need to adjust the PID settings since the ones I have are based on the fan blowing AND the damper being opened instead of just the damper being opened? I would think so since to achieve the same result as the fan achieved, the damper will need to be opened more since nothing is pushing the air through the hole. Also, do I remove the fan or can I leave it attached since convection can suck in through the opening?

Sorry for all the questions, but hopefully some answers can help others too. I would love to dial this baby in for some tight, responsive control. Thanks again guys. This is fun.
 
Last edited:
Did you try the default PID setting with "on at max only"? The reason I ask is that Bryan has a BGE and this entire project has been around him getting excellent results on his BGE. He posted his PID settings in the thread prior to yours. I'd give them a shot if you haven't already done so.

dave


I did a long test run (16 hours) on my Heatermeter (thanks again Bryan) with a case (thanks again Tom) with a Rotodamper (thanks again Ralph - does anyone see a trend here?). I have a large BGE. I was using the PID Debug screen to try and dial in my PID settings and I think I made progress, but just wanted to confirm a few things and ask a few questions. The questions are a little disjointed, so bear with me.

1. First, I figured out that on the debug screen, adding up the three numbers equals the fan percentage. I was having overshoot problems followed by undershoot problems followed by overshoot problems, etc. I raised my D because I understand it tries to predict the future and I did see some preemptive correcting going on after that but I was not getting the really tight control like some o the graphs Ralph has posted. I think my primary problem is that the BGE is slow to respond (maybe because of the mass of the ceramics) but once it responds, it is very sensitive to airflow so a little goes a long way. The cycle I was experiencing is the temp would drop, the fan would crank up, the response was slow so the fan would crank up more and then the temp would start rising slowly. Then finally the fan would stop a couple degrees from target but by that point it had already pumped enough oxygen in to overshoot by sometimes 25 degrees for a good 15-20 minutes. When the temp would start dropping, I would get the reverse - the drop would accelerate and the fan wouldn't really kick in until the temp went under the setpoint and by that time it would take a while to correct and the cycle would start over again. I felt like the algorithm wasn't good at looking back in time far enough for the "cause" of its current status. I finally dialed in my settings at B=0, P=2, I=0.002, and D=7. These look substantially different than a lot of the successful PID settings people have posted.

2. The above settings were pretty stable, but I noticed 2 things and have 2 questions. First it was way more stable at 250* than at 225*. Is it possible that my egg might just have a hard time with 225*? I think I have it pretty tightly sealed, but maybe not, and the rotodamper should help with this.

3. The other thing I noticed is that it was pretty stable with these settings but at all setpoints, it would stabilize around 2 degrees below the setpoint. That baffled me, so if anyone has any ideas, I would appreciate hearing them.

4. Here is a question I have been wondering about. Is the PID algorithm a "learning" algorithm? In other words does it dial itself in over time as it learns from its overshoots and undershoots and then "remember" that the next time you use it? I ask this, because I thought I saw the amplitude of the overshoots and undershoots getting smaller before I was changing settings. If it does learn, maybe I should reset back closer to the defaults, fire up the egg and just let it go for a while without fiddling with the settings so it can learn without me switching the variables/inputs all the time.

5. Ralph and Bryan have talked about damper only mode. All my testing was with the fan. For 225*, should I try damper only? If so, how do I do that? Just check the box that says "on at max only" for fan speed? If I do this, will I need to adjust the PID settings since the ones I have are based on the fan blowing AND the damper being opened instead of just the damper being opened? I would think so since to achieve the same result as the fan achieved, the damper will need to be opened more since nothing is pushing the air through the hole. Also, do I remove the fan or can I leave it attached since convection can suck in through the opening?

Sorry for all the questions, but hopefully some answers can help others too. I would love to dial this baby in for some tight, responsive control. Thanks again guys. This is fun.
 
No, I didn't really read enough about "on at max only" until after I had spent some time tweaking the PID settings. In other words, I figured out that people were using that checkbox a little too late for this test. I will definitely do so -- probably next weekend, but I would still like to know if anyone has any answers to my questions. I realize I fired off a million at once, but question #4 is probably the one I am curious about the most. Regardless, this whole project has unified my 2 hobbies - computers/gadgets and the Egg, so I can't complain! Thanks.
 
No, I didn't really read enough about "on at max only" until after I had spent some time tweaking the PID settings. In other words, I figured out that people were using that checkbox a little too late for this test. I will definitely do so -- probably next weekend, but I would still like to know if anyone has any answers to my questions. I realize I fired off a million at once, but question #4 is probably the one I am curious about the most. Regardless, this whole project has unified my 2 hobbies - computers/gadgets and the Egg, so I can't complain! Thanks.

Byran has toyed with a learning PID, but I think he said something that it was not worth the effort as it was not really making better. There is to much lag in the temp change, or something like that, I believe.
 
All PIDs are "learning" in marketing talk, so when you see a product that claims it is "intelligent" or "adapts to changing conditions" that just means it is a PID. The integral term is really what allows them to make that claim, as it accumulates the proper amount of output required to maintain the right temperature/speed/etc. You could say it is learning how much output it needs but it is just a simple sum over time that grows or decays based on the amount of error.

Some PIDs also have "auto tuning" which attempts to adjust the PID coefficients to your particular setup. I've run the algorithms several times manually and several different variations, but never gotten very good results. Tuning works very well with some things like heating a bucket of water with a stick heater, or how fast a motor needs to run to get the right RPMs, but with a fire I think there are too many other variables for it to be reliable.

Most tuning systems work with something called "impulse response" where they turn the output on, see how long it takes to pass a certain point, then turn it off and see how long it takes to go back down. Do this over a number of cycles with a large enough separation from your crossing point and bam you've got your numbers. On the grill this takes 30-60 minutes and what pieces of charcoal are burning at the end are different than at the beginning, which creates a different heat profile and alters the results. At least in my mind this is what it never seems to work.

I sort of got off on a tangent here but in my mind HeaterMeter's PID does not "learn", but it is just as learning as any other "learning controller".
 
Thanks Bryan. I have a LBGE too, and what I found tough about tuning was the fact that the response of all the ceramic mass lags significantly behind the action taken with the fan - sometimes by 5-10 minutes. Out of the 3 numbers that I can tweak, which would you say will affect this more? For example, when my fan kicks in, I basically want it to throttle way back several minutes before it comes near the target temp or else it will over shoot. I was adjusting D for this but is that not right?
 
2. The above settings were pretty stable, but I noticed 2 things and have 2 questions. First it was way more stable at 250* than at 225*. Is it possible that my egg might just have a hard time with 225*? I think I have it pretty tightly sealed, but maybe not, and the rotodamper should help with this.

I wanted to pick this particular point to respond to because it brings to mind one thing that is not under the HM control... The size of your fire. If you want a high pit temp build a big fire, if you want a low pit temp build a small fire. How many coals you have burning is the major factor in what temp your grill "likes" to hit. If you build too big a fire for a low setpont you will get overshoot, the HM will start to tamp the fire down (if you have some sort of damper) but it will take some time before it can reduce the fire down enough to hit your target temp reliably. If you start out with just the right size fire for your target temp it wont take long at all to hit your target reliably.

This is where technique comes in. If you are not familiar with the "minion method", it is a way of arranging your coals for low and slow cooking so you never get too many coals burning at one time, but have plenty of coals for a long cook. There are various ways to go about setting up the minion method, some use cages that separate the coals into a zig-zag pattern like a little maze. The coals burn from one end to the other as the cook progresses never having the opportunity to ignite too many coals due to the small layer of coals, each leg of the "maze" is separated enough so the previous section cannot ignite the next.

Personally I prefer what I call the "ring of fire" method in my "FauxMado". I made a round cage of steel mesh that is just smaller than the bottom grate on my burn pan. I line coals around the outside of this cage which form a circular pattern with a thin layer of coals around the outer edge of my burn pan. I ignite one end of the coals and they burn around the circle as the cook progresses. This method works great for hitting a low and slow target temp right out of the gate and maintaining it throughout a long cook. Often times I am too lazy and just pile coals in the back side of my FauxMado and light it up for an offset cooking type of setup. When I do this I usually get a little overshoot initially but eventually the HM chokes the fire down small enough to land reliably on the target temp. This is not the desired method cause I don't like to cook on a fire that is constantly being choked down, I prefer to cook on a fire that has a slow trickle of air over it to prevent stale smoke from hanging around my food. (When using the minion method you can generally set the top vent open wider than when you use a pile of coals) When I use the lazy method I try to allow more time for my pit to stabilize to the point where it starts to open the damper before I put my food on. In general for low and slow cooking I do not use the blower during the cook, I set it "on at max only" because kamado's have excellent convection air flow due to their design so it doesn't need forced air to achieve the desired flow. (and the forced air may induce overshoot)

Another factor in low and slow cooking is a heat deflector. Kamado's generally have some sort of "smoking stone" (which may be an accessory) that sits between the fire and the food grate. This heat deflector makes it easier to achieve a stable low and slow cook temp without using the minion method on your coals. I tend not to use a deflector because I prefer to have access to the coals to add wood chunks and just see what is going on down in the pit in general, cause once the stone is in place its hot so it's there for the duration.... but a smoking stone does make a kamado more forgiving of your technique with the coals.

Bottom line, you need to remember you are working with FIRE here, so get in touch with your inner cave man! LOL If your fire ends up too big you can always use some tongs to pull out a few of the hottest coals if you are impatient and don't want to wait for the Heater Meter to choke them out. If you light up a big old pile of coals and let them burn with the lid open until you have a rip roaring fire don't expect to hit a low and slow cooking temp when you close the lid. Conversely, if you want to cook a pizza a 500+ degrees make sure you have a big old pile of coals burning otherwise you will never recover that high temp after you lift the lid to throw in the pizza...

Here is a pic I shot last summer of my FauxMado setup for the "ring of fire" minion method low and slow cook. Keep in mind, in a tightly sealed and well insulated grill like a Kamado it only takes a tiny fire to hit 225 degrees, this "ring of fire" will burn for many hours...
RingOfFire.jpg


PS you can see in this pic the trail of ash from my previous cook, it only goes about 1/3 the way around the circle. I can't recall exactly what I cooked, but I know it was on there for hours...
 
Last edited:

 

Back
Top