How to autotune a pid

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

timcadieux

Well-Known Member
Joined
May 1, 2011
Messages
344
Reaction score
16
Location
Ottawa
Im an electrical newb so I had one of our LHC members who is some kind of an engineer build me a very simple sinhle vessel biab setup.

The setup uses an SYL-2342 PID, a Liquid Tight RTD Sensor, 2” Probe, Weldless Fitting, and 2x 1500w elements, all from Auberins.

My problem is that I dont seem to be able to run an Autotune properly.

I fill the 10g kettle to about 5g of 160f water. I set the target temp to 170f and set the pid to autotune by changing the AT setting to 1.

The screen starts flashing and heats up, howeever it never stops once it reaches the target temp. Shoukd the autotune stop more or less around the target temp? Ive seen it as high as 180f.

Are there not any propers walkthroughs? The documentation that is available on the auberins site is just too complicated, for me anyways.
 
Most autotune programs work by hitting the load with continuous 100% power and, when the set point is exceeded by some amount, going to 0%. As this does not represent a tuned setup the PV is going to overshoot the SP by a fair amount. I don't know this controller but 10 °F doesn't seem like much. The controller derives the tuning parameters from temperature vs time measurements it is making during the full on and full off periods. Someone with more knowledge of this particular controller can probably give a more detailed idea as to what should happen.

Note that water and mash are not identical loads. The tuneset you get for water will be only approximately appropriate for mash but you don't want to waste a mash tuning with grain in the system. Thus you can expect overshoot/undershoot using a water derived tuneset for actual brewing. With experience you may be able to tweak the parameters to get better performance. Again, someone with this device in a similar system may be able to advise.
 
Kal, i used the numbers from your site. The only one i had to change was FLT. I set my Target to 154, the water was at 144. I set AT to 2 and about 15min later the water is now at 176, i can hear that the element is still on..
 
Even with the Auber directions AND Kal's directions, I still haven't been able to "autotune". I think it's a myth.

Instead, I simply keep a close eye on the temps, specifically my mash temps. When I see the mash temp dip below some arbitrary point (152F, for example), I hit the "ELEMENT ON" button and heat up the mash, continuously stirring to avoid stratification, until it reaches 154F or so, then I switch off the element.

I need to add some insulation to my kettle, but even now, I'm only switching on the element maybe 3 or 4 times during a 90 minute mash.
 
Even with the Auber directions AND Kal's directions, I still haven't been able to "autotune". I think it's a myth.

Instead, I simply keep a close eye on the temps, specifically my mash temps. When I see the mash temp dip below some arbitrary point (152F, for example), I hit the "ELEMENT ON" button and heat up the mash, continuously stirring to avoid stratification, until it reaches 154F or so, then I switch off the element.
WHy not just set the PID to whatever temp you want? If you want it to be 152F, set it to 152.

Autotune just makes sure that the PID understands your system so that it doesn't greatly overshoot or undershoot your target. The PID can still work just fine without auto-tuning but it may go slightly above/below your temp as it tries to hold the specific temp you set.

Kal
 
WHy not just set the PID to whatever temp you want? If you want it to be 152F, set it to 152.

Autotune just makes sure that the PID understands your system so that it doesn't greatly overshoot or undershoot your target. The PID can still work just fine without auto-tuning but it may go slightly above/below your temp as it tries to hold the specific temp you set.

Kal

Kal.. thanks for the response..

If I set the PID to 152, the element remains on until, oh, boiling or so. Sometimes. Sometimes it'll switch off in the 170s or 180s.

It's a temperamental little thing.
 
The PID can still work just fine without auto-tuning but it may go slightly above/below your temp as it tries to hold the specific temp you set.

Not so. A PID must be tuned for the load. If you expect reasonable damping it must be tuned for the particular load i.e. if you are mashing 20 lbs of grain with a 1.5 water to grist ratio you need a different tuneset from the one you would use to mash 25 lbs of grain with a 1.4 water to grist ratio. More sophisticated controllers than the ones used here allow storage of multiple tune sets for that reason.

If I set the PID to 152, the element remains on until, oh, boiling or so. Sometimes. Sometimes it'll switch off in the 170s or 180s.

This would tend to emphasize my point but I rather think that something else is wrong here too. PID isn't all its advertised to be (in fact these Auber controllers use fuzzy logic I believe). The usual problems in home brewing are that the RTDs (temperature sensors) aren't sensing the load and that the load is not uniformly and consistently stirred. Thus the load does not behave like a thermal analogue to an RLC circuit and the PID algorithm can't control it (fuzzy logic should do better). Sometimes PID is just not the right algorithm and you actually do better with on/off/deadband control.

Before going any further I would suggest checking out the action of the controller with a well mixed water load. If you can't tune it to that you won't be able to tune it to a mash load. You may have a bad controller.
 
What ajdelange said above makes sense.

So instead of screwing around with fuzzy PIDs, I'm basically using it as an expensive temperature gauge and manually controlling the heat.

It's either that, or start screwing up batches of beer.
 
Not too fast. First determine whether the controller is working in the PID mode by testing with recirculating water. If it doesn't then it is defective and should be returned for replacement. If it does work, tune it for water. It won't perform as well with mash but you should get some control. It definitely shouldn't be erratic as in what you have seen. You would basically have to sacrifice a mash to tune it for mash but that may be something you may want to consider. Another approach is to understand what each of the three tuneset parameters does and fiddle with them to get better performance. If you conclude that you cannot use PID control with your setup you may still be able to control by using the deaband/on/off control mode. Here you tell it to turn on whenever the mash temperature drops below the setpoint and stay on until the temperature rises to the setpoint plus ajdustable dead band. For example, if you set for 150 and adjust the deadband to 1 ° the controller will turn on power and the temperature will rise. When the temperature passes 151 the controller will turn the power off. It will over and unsershoot more than a properly tuned PID but you still have some measure of control.
 
I would think one could brew a batch, then mash the spent grains for an autotune. Better than sacrificing the grains, lol.
 
Kal.. thanks for the response..

If I set the PID to 152, the element remains on until, oh, boiling or so. Sometimes. Sometimes it'll switch off in the 170s or 180s.

It's a temperamental little thing.
Something is not working correctly then. This is not something that auto-tuning will fix.

If the PID is set to 152F and keeps going to 170-180F and sometimes goes all the way to boiling, I would suspect a bad (intermittent) connection somewhere, possibly a short, that's telling the SSR to fire continuously. I'm assuming your PID has a light that says when it's telling the SSR to fire (On Auber PIDs this is the green "OUT" light). When it turns off, does the element continue to fire? If yes, look at the SSR. Is the SSR light on? If yes, the SSR is problematic/defective. Otherwise it's likely the PID.

Not so. A PID must be tuned for the load.
I would add "... If you expect precise temp control with zero over/under shoot."

In many cases brewers use PIDs that have never been auto-tuned and don't have wild swings.

My first few batches were done without ever having done any sort of auto-tuning on my Auber SYL-2352 PID used to hold mash temp. It would sometimes go a degree above or below (or so). Once auto-tuned it held closer to the right temp.

If you expect reasonable damping it must be tuned for the particular load i.e. if you are mashing 20 lbs of grain with a 1.5 water to grist ratio you need a different tuneset from the one you would use to mash 25 lbs of grain with a 1.4 water to grist ratio.
I guess it's the definition of the word "reasonable" that has me say that I find that even without auto-tuning, many brewers will find the results reasonable. I know that a large % of brewers using PIDs to maintain mash temp have never done auto-tuning and are happy with the results. (Just based on email feedback).

I brew beers with between 10 to 40 lbs of grain depending on what I'm making (a 3.5% light lager to a 12%+ barley wine). I don't re-autotune between batches nor do I have issues holding mash temp correctly. If I set my HLT to be 150F (I have a HERMS setup), the HLT holds at 150F and my mash then also reaches and holds at 150F:

IMG_2160.jpg


Later I increase the HLT to 168F and it does the same:

IMG_2182.jpg


(The mash is at 162F, on its way up to 168F).

Most of my 3-4% light lagers that only have ~10 lbs of grain are 3+ hours multistep mashes and they hit temps perfectly without any over/undershoot. My 12% beers with 40lb of grain simply take longer to step/reach temp.

I don't get inaccurate mash temps based on the amount of grain/water. Sometimes it's 4 times the amount of grain even!

I think brewing setups are all fairly heavily dampened and take (relatively speaking) a long time for temps to change such that you don't need to have multiple sets of P/I/D values based on amount of grain/water/etc. I don't know anyone who does this.

I'm not saying that auto-tuning isn't required (I recommend it in my instructions and do not say it's optional) but I think for many it won't make as big a difference as some people think. In brewmcq's case something is definitely wrong as you mentioned. It's not because the PID doesn't understand the damping behaviour of the system.

The usual problems in home brewing are that the RTDs (temperature sensors) aren't sensing the load and that the load is not uniformly and consistently stirred.
But that's only if the load (mash) is not actually at the temp that the RTD says it thinks it's at. If the RTD connected to the PID measures 170F (the PID displays 170) and the PID is set to 152F and the PID is still firing, the RTD is not the issue. It's the PID/SSR/wiring.

Kal
 
I would add "... If you expect precise temp control with zero over/under shoot."

In my (non brewing) experience that's exactly what you go to PID for and that's why I elected to use PID in brewing.

In many cases brewers use PIDs that have never been auto-tuned and don't have wild swings.

'Wild' is, of course, a subjective term. A controller ships with a nominal tune set. If it closely matches the load then performance can be quite good. If it doesn't, then things get wild - no poles in the right half plane or anything like that but overshoot can be substantial and it can take a long time for things to damp out. Simply tuning the system will improve that performance dramatically if the system is one amenable to PID control. I'll get specific in a minute.



I guess it's the definition of the word "reasonable" that has me say that I find that even without auto-tuning, many brewers will find the results reasonable. I know that a large % of brewers using PIDs to maintain mash temp have never done auto-tuning and are happy with the results. (Just based on email feedback).
If they are happy, I am happy.

I brew beers with between 10 to 40 lbs of grain depending on what I'm making (a 3.5% light lager to a 12%+ barley wine). I don't re-autotune between batches nor do I have issues holding mash temp correctly. If I set my HLT to be 150F (I have a HERMS setup), the HLT holds at 150F and my mash then also reaches and holds at 150F
I'll have to ask you to forgive my total ignorance of HERMS beyond what I could find from a quick web search. I understand from that that the liquid from the mash tun is recirculated through a heat exchanger in the HLT and that the reading of an RTD usually at the output of the heat exchanger is the PV and that the output of the controller turns on the recirculation pump or the HLT heater. In either case you are asking the system to control the temperature of the output of the HLT. This is an example of not regulating the load but some other point in the system. If PV reads 150 °F, what is the temperature of the mash at the point where the hot wort enters the mash tun? At the point where it leaves? In the middle?

These may not be pertinent questions as in your system the RTD might be located in the middle of the mashtun or the PV might be the average of the readings of RTD's dispersed throughout it.

In any case, if you increase the mass of the grain and water, for example, the thermal time constant of the system will increase and for good PID performance the tune set should be changed. If your response to that is that the size of the load changes you make doesn't degrade performance enough to be of concern I can certainly accept that.



Most of my 3-4% light lagers that only have ~10 lbs of grain are 3+ hours multistep mashes and they hit temps perfectly without any over/undershoot. My 12% beers with 40lb of grain simply take longer to step/reach temp.

I don't get inaccurate mash temps based on the amount of grain/water. Sometimes it's 4 times the amount of grain even!
That says you are way over damped.

I think brewing setups are all fairly heavily dampened and take (relatively speaking) a long time for temps to change such that you don't need to have multiple sets of P/I/D values based on amount of grain/water/etc. I don't know anyone who does this.
So they aren't really PID then but rather over damped first order loops. In a commercial operation where they want to get to temp quickly I expect they would shoot for critical damping or at least an operation that had a knowledgeable engineer in the loop would. It never occurred to me to ask a pro brewer about his tuning. Probably set up by the consultant and never touched again in many cases.

In brewmcq's case something is definitely wrong as you mentioned.
That's probably the case.

The usual problems in home brewing are that the RTDs (temperature sensors) aren't sensing the load and that the load is not uniformly and consistently stirred.

But that's only if the load (mash) is not actually at the temp that the RTD says it thinks it's at.

The location of the temperature sensor at a place other than where the load is located, e.g. the HERMS example I cited above or at the output or input of a RIMS heater chamber are examples of the RTD not controlling the load. Note that this can be workable if the offset between the sense temperature and the load temperature is constant (and known). Another example, and more what I was thinking of, would be my HLT which is a 55 gal SS drum with a steam coil in the bottom. The RTD is located adjacent to the steam coil. If I fire this puppy off it regulates the temperature of the water near the steam coil but that's not the temperature of the load (which is the whole mass of the water). A small recirculating pump fixes the problem and, when tuned for about 30 gal, the controller works very well. Steam stays on until within a few degrees of SP (band is small), only overshoots by a couple of tenths of a degree, settles out quickly, responds quickly to opening the cold water fill valve (D is properly set) and performance doesn't degrade noticeably if the tank is filled to 80% as opposed to 66%. That's what I want PID to do.

Now if we move to the mash tun, built the same way, there is no means that I have found, by which I can mix the mash uniformly enough to actually control the load from the single RTD reading so I turn the steam on and off manually (or pedally, actually,i.e. with a foot pedal). PID becomes PED.

Interesting discussion. I've gained some insights from it.
 
In my (non brewing) experience that's exactly what you go to PID for and that's why I elected to use PID in brewing.
Sure - most of us do. That's one of the reasons I went with PID too. Set and forget, and temp will always be exactly where I expect it.

I'll have to ask you to forgive my total ignorance of HERMS beyond what I could find from a quick web search. I understand from that that the liquid from the mash tun is recirculated through a heat exchanger in the HLT and that the reading of an RTD usually at the output of the heat exchanger is the PV and that the output of the controller turns on the recirculation pump or the HLT heater. In either case you are asking the system to control the temperature of the output of the HLT. This is an example of not regulating the load but some other point in the system. If PV reads 150 °F, what is the temperature of the mash at the point where the hot wort enters the mash tun? At the point where it leaves? In the middle?
HERMS is a closed loop system where the wort in the MLT is recirculated through a heat exchanger in the HLT to maintain heat. You heat the water in the HLT with a PID/RTD to whatever temp you want the mash to be at and the mash follows as the wort is continuously recirculated.

I don't have my probes where you mention. In my case the RTD that controls the temp of the HLT (and indirectly the MLT) is placed on the HLT output and the HLT water is constantly recirculated too to avoid stratification effects.

BrewDay-STEP4-Mash.jpg


A second PID that controls nothing shows the temp of the mash with the temp probe shown at the output of the MLT. By placing the temp probe at the output, and because mash temp always goes up, never down, we know when the mash has reached the set temp (the HLT temp) as it always lags behind slightly. Anywhere else you don't know if you whole mash is at temp yet, so you wouldn't know when the mash has all reached target temp.

Placing a temp probe at the HERMS output is redundant as it always matches the HLT temp.

These may not be pertinent questions as in your system the RTD might be located in the middle of the mashtun or the PV might be the average of the readings of RTD's dispersed throughout it.
No - the temp probe's in the plumbing, not in the vessel, as is usually done with closed loop control systems.

Complete details available in my brew day step by step with pictures/videos: http://www.theelectricbrewery.com/brew-day-step-by-step

In any case, if you increase the mass of the grain and water, for example, the thermal time constant of the system will increase and for good PID performance the tune set should be changed. If your response to that is that the size of the load changes you make doesn't degrade performance enough to be of concern I can certainly accept that.
Yup - definitely the P/I/D settings should change as load changes. With brewing setups however the response time is so slow with a typical 5500W element heating (say) 5-15 gallons of water that I don't ever overshoot with (say) a very small mass of grain. IIRC, I did tune with an 'average' grain bill - probably a ~6% ABV beer or so as I tend to brew a lot of higher gravity american beers.

If anything, we should probably tune with a smaller grain bill so that the system cuts the heat early to avoid overshooting. With a larger grain bill it'll realize shortly after that it's not going to get there and re-apply heat.

Kal
 
You might want to try starting autotune when you are 20+ degrees below your setpoint. From your initial post, it looked like you were 10 degrees below... this created problems for me with my initial setup.
 
My problem is that I dont seem to be able to run an Autotune properly.

I fill the 10g kettle to about 5g of 160f water. I set the target temp to 170f and set the pid to autotune by changing the AT setting to 1.

The screen starts flashing and heats up, howeever it never stops once it reaches the target temp. Shoukd the autotune stop more or less around the target temp? Ive seen it as high as 180f.

Are there not any propers walkthroughs? The documentation that is available on the auberins site is just too complicated, for me anyways.

During the auto tune process you should expect wild temp swings. If the process works then the PID values that it sets should give fast heating rates with no overshoot or oscillation. Someone suggested using spent grain during tuning, which is smart.
The quick-n-dirty method for tuning by hand:
Set the I and D gain for zero then jack up the P until the system oscillates. Reduce P until the oscillation stops. Choose a P value that is well below the oscillation point, say 40% lower. Let the system stabilize and look for an offset between the process temp and set point. Increase I until the offset is eliminated - this is your minimum I. Jack up I until the system oscillates - this is your maximum I. Test out various combinations of P and I within the limits. Higher gains will give faster but less stable response. Try to go for the minimum gain that will give you fast enough response. Avoid oscillation and overshoot, which are signs of gains that are too high. The D gain can stay at zero. It only helps a sluggish system respond to sudden changes. Keep D very low if you try it.

Let us know how it behaves when it is roughly tuned and we will help you figure out where to go from there.
 
I use my pin pids that I have never auto tuned.... I Did set my "I" in the p-i-d menu to 1 as suggested by brumetuer? (Might have butchered his screen name) prior to changing this setting my pics would in fact overshoot my more than a couple degrees... now they might overshoot by a degree or two until they adjust and settle the temp back to the desired set point...
 
HERMS is a closed loop system where the wort in the MLT is recirculated through a heat exchanger in the HLT to maintain heat. You heat the water in the HLT with a PID/RTD to whatever temp you want the mash to be at and the mash follows as the wort is continuously recirculated...

Thus you don't have a PID control system. In fact you don't have a control loop at all in the sense that you aren't taking feedback from the load. You are relying on Zeroeth Law to get mash to the temperature of a reservoir. It is the temperature of the reservoir that is being controlled. It like bringing a beer home from the store and putting it in the refrigerator. Eventually it will come to refrigerator temperature. Please note that this is not intended as a criticism of this way of doing things. Putting a beer in the refrig gets it close to refrig temperature if you wait long enough. But also note that it never actually gets to refrig temp though it will certainly get close enough for practical purposes.

Many brewers do not have the luxury of being able to wait. When I do a lager I must bring it from cold (dough-in) to beta glucan rest temp and then, via decoctions, to protein rest, sachharification rest and mashout temperatures. Each of those steps (the decoctions have steps within them) needs to happen as fast as possible (or at least as close to the recommended 1 °C/min recommended ramp rate). The day is long enough as is. I need what PID promises but is, in my system, unable to deliver because I cannot mix the mash uniformly enough to allow the controller to obtain a reasonable tuneset. The exceptions are in the HLT (mixed with a pump) and the kettle (mixed by convection) and I do use PID for both of those. In the HLT it really shines. When I need more hot water I just open the valve and the differential part of the algorithm immediately turns the steam on full blast.

So most brewers (even some that use HERMS from what little I've read) are like the guy that notes that the guests are arriving in 10 minutes and realizes he forgot to put the beer in the fridge. What does he do? He puts it in the freezer. He knows it will get cold faster but he also knows that if the guests are caught in traffic, don't arrive for two hours and he forgets to take the beer out of the freezer then he will have frozen beer. He overshoots. Systems that do this (by setting the HLT to a temperature higher than the target and controlling on the load, using mash temp to control a wort pump), for example, are using true PID and those people will need to tune for the size of their load or come up with a tuning that is close or slightly overdamped whatever the load. Aside: I do understand why one might not want to do this as there will be a bigger temperature gradient across the mash mass.

... By placing the temp probe at the output, and because mash temp always goes up, never down, we know when the mash has reached the set temp (the HLT temp) as it always lags behind slightly.

It's going to lag dependent on the thermal time constant of the system which is determined by the thermal impedance between the water in the HLT and the mash. I would expect the time constant to be several minutes - at least as long as it takes to recirculate the entire volume of liquid once.


Placing a temp probe at the HERMS output is redundant as it always matches the HLT temp.
Given that you have circulation, thermal impedance and some heat loss in the mash vessel there is going to be a drop. Perhaps by 'match' you mean 'close' or 'very close'.


No - the temp probe's in the plumbing, not in the vessel, as is usually done with closed loop control systems.

With a closed loop control system the sensor is put on the load where possible unless not doing so results in an offset that is so small that it doesn't matter or that is constant so that it can be compensated for by adding an offset to the SP. Even the little Auber controllers that everyone here likes allow this as I recall. Now some systems, like a glycol chiller, for example, will be shipped with a controller in the reservoir but when that is put into a system the feedback comes from an RTD in the fermenter (which turns a pump on and off or opens and closes a valve). This is true PID and requires tuning for critically damped performance.


Yup - definitely the P/I/D settings should change as load changes. With brewing setups however the response time is so slow with a typical 5500W element heating (say) 5-15 gallons of water that I don't ever overshoot with (say) a very small mass of grain.


IIRC, I did tune with an 'average' grain bill - probably a ~6% ABV beer or so as I tend to brew a lot of higher gravity american beers.


If anything, we should probably tune with a smaller grain bill so that the system cuts the heat early to avoid overshooting. With a larger grain bill it'll realize shortly after that it's not going to get there and re-apply heat.

It probably doesn't much matter what you put into the mash tun when you tune. What you want to do is get the reservoir to SP as quickly as possible. Of course what is in the mash tun will have some effect but assuming it to be of about the same size as the HLT presumably it has about the same losses so that total heat loss might vary from 1.5 units to 1.25 to 1.75 as the mass in the mash tun changes from normal to half to double. There would be an effect from time constant too but I'd say just fill the mash tun with water equal in volume to the usual mash volume and tune for that. It would be an interesting experiment to write down P, I and D and then repeat the experiment with a changed volume of water and compare the parameters. I'm guessing there won't be much change.
 
Be careful about swapping PID values between controllers. Not all manufacturers use the same units. Some even use P as the proportional band rather than the proportional gain. Its very confusing because increasing the prop band is the equivalent of decreasing the prop gain.
 
Back
Top