Getting the most out of PID Control - Modelling HLT/1V, RIMS and HERMS

Australia & New Zealand Homebrewing Forum

Help Support Australia & New Zealand Homebrewing Forum:

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

Adr_0

Gear Bod
Joined
4/4/13
Messages
1,776
Reaction score
684
Hi all,

A lot of people add a PID controller to their rig as they offer awesome potential for controlling your temperatures. There are a lot of configurations and applications: 1V BIAB (internal) and HLT only; RIMS with temp control in mash or in tube (becomes the same whether 1V or 2V); HERMS with HLT, controlling HLT vs mash return; and HERMS with a small (e.g. 2L) vessel.

I'm a chemical engineer by trade and have been lucky enough over the last 10 or so years to work in some cool places, including LNG plants, gas compression/treatment facilities and gas pipelines and facilities. I have been brewing through most of the time as well, but my process control experience has mostly been on distillation columns, gas supply skids for gas turbines and general level/pressure/flow applications. Sometimes you see very complex (and elegant) solutions to problems, sometimes you see complex and poorly applied solutions, sometimes you need very aggressive control because of very fast changes in process conditions but you generally end up recognising that simple controls with some philosophy adjustments can end up being extremely effective, and often the wrong application of technology and/or lack of understanding of the process can cause some issues.

So, a segway to brewing...

This topic is not meant to be about which configuration (BIAB, HERMS, RIMS, etc) makes the best beer as we all know the answer is two cans of lager extract, 3kg of sugar and ferment at 30°C. We should (myself included) recognise that while industrial process control is great and all, some principles do apply to beer but some do not.

I hope some people (myself included) get something out of it and can go away and try things, can learn a few things (myself included), take some of this with a grain of salt (i.e. a sweet-controlling rig does not, believe it or not, guarantee shit-hot beer; and likewise I do understand that a couple of degrees overshoot will too, not ruin beer) and hopefully it's at least interesting reading.

I did these models in Matlab/Simulink and applied principles of how volumes of water/wort behave but I didn't include things like heat loss and dead time. I can easily model heat loss, but I can't actually model dead time which is a bit weird. Anyway.

At this point I've modelled a HLT on its own which will hopefully be useful to people, RIMS with temperature measured on the tube, and RIMS with temperature measured in the mash. I will of course get to HERMS but it might take a couple of weeks. :)
 
In each case I am just using a 30L HLT/mash tun with a 2400W element, which is hopefully pretty normal. In all cases I have modelled a step from 55°C to 65°C, which is nice and neat at 10°C change but is also hopefully something that people do.

HLT Setup:
View attachment HLT Only Model.pdf

HLT:
HLT - PI-10min, Response.jpg
This is the response you get with integral set to 10min and P set to anywhere from 0.5-5 gain. Because temperature tends to climb when you apply power, any integral control tends to accumulate error which just results in overshoot and doesn't actually help you. Integral over 15 seconds will be horrible but even 10min (as above) gives you really bad overshoot.

Similar setup with just P only, same gain:
HLT - P Only, Response.jpg
This is the response with a gain of 1 and no integral or derivative control at all. It is basically just what you'd see with the element on full but controlled pretty well.

HLT - P Only, Power.jpg
This is the element response with just Proportional control.

So hopefully from this you can see that generally P is only required, PD will also work (not really necessary) and PI is going to give you a world of hurt when the probe is in the HLT - still TBA how it goes with HERMS.
 
This is gold. I like it when a bit of rigour is applied to things. I too have an engineering background (not process though), and I'm always tempted to run off and buy gadgets to go high tech, but have to restrain myself and remind myself that the outcomes won't necessarily change. Especially when gadgets cost MY money (as opposed to CLIENT'S money :D)

KISS rule applies as ever.
 
Let's try this again. Few cosmetic changes required.

For the element sizing, it's probably not a bad idea to try an equation like this:

[Water mass x heat capacity x 1°] / 60 which should give you the power you need in W to get 1°C/min

30 kg x 4180J/kg.K x 1K / 60s = 2090W so a 2200W or 2400W would be a good choice for this setup.

Some cosmetic changes:
HLT - PI only, power,response,model.jpg
So this is PI control on the HLT. As I was saying, the way the integral control works is that it keeps on building up error and adding this to the output (a % of 2400W) but then it's suddenly at the setpoint, but has all this extra output it thinks it needs to get the setpoint. An integral time of 600s (10min) is not particularly aggressive, but there is still a pretty bad overshoot.

This is the same gain used with the above, but with the Integral term not included in the PID:
HLT - P only, power,response,model.jpg

Better. :)

Realistically, the temperature of the PI controller would stay a lot higher as there is no negative power coming out of the element, but the power response goes negative. I should put heat loss into these models so that it will at least eventually settle, but that's one reason overshoot is annoying - not so much that the enzymes might be slightly different from what you wanted, but the fact that it can take 30min to settle down to the planned temperature.
 
pcqypcqy said:
This is gold. I like it when a bit of rigour is applied to things. I too have an engineering background (not process though), and I'm always tempted to run off and buy gadgets to go high tech, but have to restrain myself and remind myself that the outcomes won't necessarily change. Especially when gadgets cost MY money (as opposed to CLIENT'S money :D)

KISS rule applies as ever.
Yeah, you're spot on. My existing setup is a 2V which works well for me, but I would appreciate some autonomy (walking away without concern for temperature) and flexibility doing step mashes. I too just went straight for the PID, but in a lot of stuff an on-off controller will work - not sure what the cycle life is on STC relays, but it's probably comfortably within a few years of brewing.

It's good to be able to model some ideas, for e.g. different pump rates back into the mash tun. A higher pump rate will have a lower gain from the element, because it has less time to get temperature. It should however be able to cycle over volume in the mash tun faster. 7.2L/min vs 5L min knocked 3min off the ramp time, with exactly the same heating element. That's pretty cool.
 
Way out of my league......................... :unsure:

Are you saying that and STC1000 would do a better job of controlling mash temperature than a PID?
 
So, here we have a RIMS setup.

Specs:
2400W element
Tube is 0.6L volume, RTD right on the tube
PID is controlled in the middle of the mash tun
LBP at 5L/min
RIMS-TinMT-SimulinkTuned.jpg

So you can see that the mash tun response again hits what you would expect from a 2400W element, with about 75W of heat loss from the mash tun.

The only catch is that the tube (shown by the purple trace) gets quite a bit hotter, 72°C in this case, or 7°C hotter than the setpoint. Is that bad? I don't think so, but it might give you dramas if you went to a 71°C step for example.

So this is the same example as above, with 7.2lpm vs 5lpm. I figure this is probably the most you actually get out of an LBP:
RIMS-TinMT-SimulinkTuned-7.2lpm.jpg

And here is the same example above, but with only 2L/min:
RIMS-TinTube-MashResponse-2lpm.jpg
So up around 83°C, or 18°C above the setpoint. Enzymes being deactivated there I'm sure - there's 7.5min where the temp in the tube is above 76°C. Probably not good.

So what did we learn? High pump flows are very good for RIMS systems, and likely for HERMS as well. Go as high as you can without compressing your bed.

The PI values that came out of the Simulink tuning were:
Gain 0.9
Integral seconds - 3600s (1hr), so to be honest you might as well set to zero. Interesting. So here, with RIMS and PID measuring in the mash, high pump flowrate and just proportional control does the trick.
 
Cervantes said:
Way out of my league......................... :unsure:

Are you saying that and STC1000 would do a better job of controlling mash temperature than a PID?
I hope it's not out of your league, I will try and put a few summary points after each bit and maybe a table at the end.

An STC1000 would control better than a badly tuned PID. I don't want people to spend hours with autotune, or putting in integral times that are way off and get massive overshoot as a result.
 
The rims tube getting hotter than setpoint IS bad. The enzymes you are trying to affect are in the wort not just the grain, the grain bed will catch up in a short time. So in the example above your wort over shot 7c for the period of the ramp, this is why for herms and rims the thermo is located at exit of the heat exchange. Otherwise liking the data.


MB
 
So, here are a couple of RIMS with PID measuring from tube:

RIMS-TinTube-SimulinkTuned5lpm.jpg
So this is Simulink tuned to be quite gentle (very low gain, long integral action) and gives a fairly good response. There is about 2°C of overshoot in the tube, the mash gets to within 1°C in 10min or less and there's less than a degree overshoot in the MT. Looks very graceful.

This is my rough tuning with 5lpm. Good that there's no overshoot in the tube, but the mash response says it needs more flow:
RIMS-TinTube-AdroTuned5lpm.jpg

So at 7.2lpm there is 0.8°C overshoot in the tube, is within 1°C in under 10min but still takes 13-14min to get within 0.1°C of the setpoint.
RIMS-TinTube-AdroTuned7.2lpm.jpg
 
MastersBrewery said:
The rims tube getting hotter than setpoint IS bad. The enzymes you are trying to affect are in the wort not just the grain, the grain bed will catch up in a short time. So in the example above your wort over shot 7c for the period of the ramp, this is why for herms and rims the thermo is located at exit of the heat exchange. Otherwise liking the data.


MB
Yeah, spot on... while I would say it's risky to get too aggressive on the tuning (keep the gain fairly low, e.g. 0.8-1.2) you can get away with it with a very high flowrate. Essentially you can do anything, but you need to understand the implications. Measuring in the MT is possible, but you need to not get too aggressive on the gain and keep your flowrate as high as possible.

Summarising...
- If you have RIMS with measurement in the mash tun, you need high flowrate to protect your wort from overheating. Great, I really needed to do Matlab models to figure that one out.
- If you have RIMS with measurement in the tube, you have much greater control over your wort temperature (better protected) but you need high flow to not lose too much time getting to your setpoint. You can fiddle a bit more with tuning, see what you have on your display and look at when your power drops to a couple of percent to know that your mash is at temperature, unless you use another probe.
- If you are just controlling a HLT, stick to P only control (set I and D to zero), something like 0.8 to 3 would be fine. Stir it well. If you have BIAB, keep the pump flow high and you should be laughing with just P control. Any feedback from people who have done this?
- If you have HERMS, I'm going to take a gamble and suggest that P only would be the best here too... we'll see in a week or two.
 
Here are the HLT response graphs:
30L water in the HLT
75W of loss to atmosphere (probably not unrealistic)
2400W element
Step change from 55-65°C
Assumed stirred vigorously

Response with P set to 2, I for 10min (sensible numbers):
HLT - PI-10min, power and response.jpg
Overshoot is 2°C, element switches off completely and takes however long to get back down to the setpoint. Stirring would help this.

And Proportional control only, P set to 2:
HLT - P only, power and response.jpg

Interestingly, you can see the power flatlining after it hits setpoint - at 75W I'm guessing. If you work out the % your controllers sits at maintaining a temperature (e.g. 1-5%), I guess that would be your loss to surroundings, i.e. 2% of a 2400W element would be 48W.

For 50Hz power it's probably best to set your SSR duration on the PID controller to 3s to get as in phase as possible - most have a minimum 'on' time of 30ms and PID's probably only have a 1% output resolution, so 100 x 30ms = 3s.

Anybody want to try P-only control on a HLT and give me some feedback?
 
Hmmm..... think I need to work on some of the factors:
HERMS-3Lvessel-CoilControl.jpg

I will see how I go through the week. I think the model is ok but some of the heat transfer factors are likely wrong. Ah well, a work in progress...
 
Didn't you just have a kid Adr_0? Is your wife off at the inlaws?
Love your work. When I have a tunable PID one day I'll refer back to this thread.
 
TheWiggman said:
Didn't you just have a kid Adr_0? Is your wife off at the inlaws?
Love your work. When I have a tunable PID one day I'll refer back to this thread.
Managed to get a few windows through the day, and I travel on a bus for three hours a day so plenty of time for drawing function blocks and transfer functions. :)

I'm impressed you went with on-off control for your HERMS,as proportional is shaping to be the best for controlling HLTs, and with a n element the on-off can be close to proportional anyway.

I'm really curious to look at sensitivity to flow, coil length, HLT volume and controlling tube temp vs HLT. hopefully some of these cases ring a bell for someone "Hey, that's exactly what my system does..." and they get something out of it.
 
Note the operative word - 'programmable'. My controllers are Jap made Shinko units from an old printing machine built in '87. They're quality, robust and simple PID units with only SV and alarm adjustable. K-type only unfortunately but at this stage I can't justify the cash for new controllers when these units are very effective. The trade off is sloooow settling; they will ramp fairly quickly and not overshoot, but take about 30% of the ramp time in steps for the last 2°C. Increasing flow rates has worked in my favour, once the grain bed is well settled it's full throttle from then on.
The most interesting point you've made here I think is the P only control for a HLT. Hopefully that will change some minds.
 
Awesome, this is right up my alley! I play with control loops at work all the time, usually flow and level but also heating from time to time. I have recently taken to trying to tune the control loops during commissioning before the automation engineer gets involved(im process). I can tell you that when tuning these loops in real world applications I use P and I and have only once had the need to use D. I can't answer any of your questions yet however I am part way through building a new 1V brewery with PLC control where I will be playing around with these exact parameters during commissioning.
I have always found that with my 1V RIMS I needed a high flow rate to get good performance(as you have indicated) however grain bed compacting has been an issue. My new system will have a return to the top of the grain bed and also a return to beneath. I'm also fitting a VSD to the pump so I can play around with flow rate more predictably and test what effect all these same parameters have.
I'll check back when the new brewery and PLC are up and running and I can run some loop tuning(my PID does not have autotune so it will be trial and error tuning to start with).
Generally speaking I think you always want your temperature transmitter close to your heater as overshoot is not ideal.
 
That's cool to hear Husky. Another point a long with high flowrates and keeping the sensor close to the element, is insulating lines. If there is a long uninsulated length of line between your sensor and mash tun, it will result in a drop/gap in temperature.

I'm keen to hear from HERMS brewers, a few questions:
-what is the size of your mash tun (mash volume actually) and element?
-does your HEX water boil, assuming you control your outlet temp?
-what is the volume of water in your HEX?
-how long does it take to make a 10°C step, and do you get any overshoot?
 
Oh man, I spent countless hours on Simulink for my thesis. I haven't used it since. Would you be willing to share your models?

This is great stuff, I'm going to have to come back and read through this in detail.
 
Adr_0 said:
I'm keen to hear from HERMS brewers, a few questions:
-what is the size of your mash tun (mash volume actually) and element?
-does your HEX water boil, assuming you control your outlet temp?
-what is the volume of water in your HEX?
-how long does it take to make a 10°C step, and do you get any overshoot?
1. 36l, typically 3l/kg liquor:grist. 2kW element. For a 4.5kg about 15l including losses.
2. Not during normal operation. Accidentally close a valve however...
3. 2 l I think. Can double check.
4. I haven't actually timed but this will vary depending on controller settings obviously. No to overshoot. Will get back to you on next brew day provided my wife hasn't arranged other activities during mash time.
 
Back
Top