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.
krausenhaus said:
Hey Adr_0, I haven't had a chance for a good read of this but can't you model dead time with a transport delay block?
Sort of... The transport delay is discrete though. There is no way to incorporate it continuously in a transfer function with gain and time constant (or for integrating processes like tank heating). The transport delay works but it doesn't look as pretty and probably isn't functionally correct either. I thought it was strange but that's how it seems to be.
 
krausenhaus said:
Hey Adr_0, I haven't had a chance for a good read of this but can't you model dead time with a transport delay block?
Sort of... The transport delay is discrete though. There is no way to incorporate it continuously in a transfer function with gain and time constant (or for integrating processes like tank heating). The transport delay works but it doesn't look as pretty and probably isn't functionally correct either. I thought it was strange but that's how it seems to be.
 
Are you sure you're not thinking of unit delay? Transport delay is a continuous function and is equivalent to e^(-d.s) in a transfer function numerator as far as I remember.
 
Great work by the way!

One thing that's confusing me though, don't you need to include mass flow rate through the coil to get power? It looks to me like that quantity is just heat per unit mass. Sure I'm missing something though.
 
The mass flow rate and heat capacity are included in a transfer function within the Coil subsystem.

Power / (mass flow x heat capacity) = dT which is essentially the gain, ie change in temp for a given power input.

Its ends up being a gain of 0.00305 or so for 5lpm. The time constant is included in the transfer function as well.

This spits out a coil differential temperature (temperature gain) which is added to the mash tun out/coil in temp.
 
Cool, but what's bugging me is it looks like the power parameter going into the TF isn't in units of W.
 
Ah, you're right!

The heat capacity is multiplied by the effectiveness, 0.025, which says how much of the potential power actually gets through but this should include a mass/flow rate to correctly represent power.

These pretty well balance out though, as although the 3950kJ/kg.K is now 3950 x 0.05kg/s, the effectiveness goes from 0.025 to 0.467 or so, because the effectiveness factors this in as well.

Although the units were not correct in the model, the numbers were the same coming out. I will fix it though as it will be more accurate when varying flows.
 
Adr_0 said:
Ah, you're right!

The heat capacity is multiplied by the effectiveness, 0.025, which says how much of the potential power actually gets through.

These pretty well balance out though, as although the 3950kJ/kg.K is now 3950 x 0.05kg/s, the effectiveness goes from 0.025 to 0.467 or so, because the effectiveness factors this in as well.

Although the units were not correct in the model, the numbers were the same coming out. I will fix it though as it will be more accurate when varying flows.
I was getting confused because the results all looked good even though it seemed one parameter was out by a factor of 100! Strangely I was never taught to use/calculate effectiveness so I wasn't sure how that would be affected.

How did you choose the time constant values?
 
If you know all the temperatures coming in and out of a heat exchanger, you can use the log mean temperature difference method... But because we don't know two of the temperatures we can't use that method.

Because two temps are unknown, you needs to use the Effectiveness/NTU method, which is essentially how effective the heat exchanger is based on UA, heat capacities and maximum theoretical power. You can then work out the temperature change on each side as you get a power output from this.

The time constants were just volume/flow. It might nor be absolutely correct, but they should be close enough in lieu of measurements.
 
Ok, graph time.

In each of these, I had the same 2400W element, 30L mash tun, and modelled 3L, 10L and 30L HEX volumes.

First one is with a 5m copper coil, 5lpm pump flow, Proportional control only:
HEX Comparison - 5m coil, 5lpm, P only.jpg

Second is a 10m coil, 5lpm pump flow, P control only:
HEX Comparison - 10m coil, 5lpm, P only.jpg

Third is a 10m coil, 5lpm but using some Integral control - 10min in this case, which I wouldn't call aggressive:
HEX Comparison - 10m coil, 5lpm, P3-I10min.jpg

Even with 1000s Integral (normally the most that they go up to, at least the Aubers) it's pretty horrible:
HEX Comparison - 10m coil, 5lpm, P3-I1000second.jpg

And finally with a 15m copper coil, 5lpm, back to P only control:
HEX Comparison - 15m coil, 5lpm, P only.jpg


I did a comparison of time constants as well, using 11s vs 120s. Bugger-all difference. 120s is not realistic for a coil as it would need to be about 150m long. So that's sweet.

More good news is that as much coil as you can fit will help get more power from the element to the mash. It will help 'buffer' the HEX temperature and will have a direct impact on ramp time because it means more power is getting through. Just try to keep the HEX volume below 10L by the look of it.

There may be tuning parameters - e.g. with Derivative control - that don't have any overshoot and I might give the Simulink tuning a go again, but it is evident that a large volume HEX is best avoided if possible - assuming you are controlling on the coil outlet that is.

Cool. :)
 
I will repost with time scales in better ranges than 0.278 hrs...

A few things look pretty clear if you have HERMS and control element power using coil outlet temp:
- stick to P control only, definitely do not use I (set to 0) and D is not needed
- for a 30L mash volume, HEX volume should not be bigger than 10L, and aim for about 10m of copper tube or 12-14m stainless. More than this has diminishing returns, as your ramp time only really improves by a tiny bit but it costs a lot and is more to fit in
- 3L HEX volume is ok, but I think you will struggle to get more than a few metres of tube in, and definitely won't get 10-12m. I would say a more powerful element will help, but you will need to be conscious of boiling the water, which could overpressure a sealed HEX or run an element dry.

I will have a look an larger volumes and flow effects as well.
 
Adr_0 said:
I will repost with time scales in better ranges than 0.278 hrs...

A few things look pretty clear if you have HERMS and control element power using coil outlet temp:
- stick to P control only, definitely do not use I (set to 0) and D is not needed
- for a 30L mash volume, HEX volume should not be bigger than 10L, and aim for about 10m of copper tube or 12-14m stainless. More than this has diminishing returns, as your ramp time only really improves by a tiny bit but it costs a lot and is more to fit in
- 3L HEX volume is ok, but I think you will struggle to get more than a few metres of tube in, and definitely won't get 10-12m. I would say a more powerful element will help, but you will need to be conscious of boiling the water, which could overpressure a sealed HEX or run an element dry.

I will have a look an larger volumes and flow effects as well.
Thanks for the undertaking the analysis and providing the results. It has led me to have a play around with the PID settings on my 4V HERMS system.

I had previously just auto tuned it, I wasn't bad but I did get some overshoot on the HEX output temp which would buildup and result in higher than desired MLT temps. Anyway I have just been playing around with setting I=0 and d=0 and using P only. Anyway with a bit of playing around I have ended up with just using P and a small d, this seems to have provided the best results with ramp time and minimising overshoot.

I have only been testing with water today, I'll see how it performs next brew.
 
Awesome, good to hear!

You have a 2L HEX and 2m coil, right? What is your element size and mash volume?

Interestingly with those specs, a 2400W element and 25L mash volume (assumes volume of fluid, not esky size) something like P of 0.2 seems to work best, while more than that gives overshoot and some steady state error. Still can do it without D, apparently.
 
Correct on the HEX volume and coil length. I have a 3000W element and my mash volume is typically around 27.5L of water to 11kg of grain. I am using an Auber PID which I don't think use the typical Kp Ki Kd values. I ended using a P of 300 and a D of 25. Adding the D value seemed to hold the temperature a little better. Auber claim that their PID controllers have fuzzy logic, I'm not sure if this is true or has any effect.

In addition to the 27.5L of water I added about the same amount of water as the grain I would normally have. I figured the increase in malt density would be approximately offset by the difference in specific heat capacity.
 
trevgale said:
Correct on the HEX volume and coil length. I have a 3000W element and my mash volume is typically around 27.5L of water to 11kg of grain. I am using an Auber PID which I don't think use the typical Kp Ki Kd values. I ended using a P of 300 and a D of 25. Adding the D value seemed to hold the temperature a little better. Auber claim that their PID controllers have fuzzy logic, I'm not sure if this is true or has any effect.

In addition to the 27.5L of water I added about the same amount of water as the grain I would normally have. I figured the increase in malt density would be approximately offset by the difference in specific heat capacity.
Hey mate,

With the Aubers, P of 300 is a traditional P of 3. D of 25 is nothing to be afraid of, but it won't do anything to 'hold' your temperatures - this is purely done by the gain. I would steer away from Integral control as it will only cause you headaches. The disturbances are probably from cold pockets, stirring, or something like that.
 
So, below should be some hopefully good starting points:

1V:
Just use P control, e.g. P of 1 to 5, or on the Aubers use P of 100 to 500. Keep the pump circulation up, or stir as much as you dare during the step changes. 1V will give you the value out of your element.

RIMS with T in the tube:
This is a pretty bulletproof setup and will give the second best ramp rates for a given element size. You should be able to set the P to 1 to 5 (100 to 500 on Auber) and that should be fine. Keep the pump circulation as high as you dare with your mash tun geometry. You can use a bit of Integral control with RIMS where you measure temperature in the tube, but don't make it less than 60s - e.g. 120 or 180s. This will cause you to overshoot a touch in your tube (a couple of degrees) and you need to decide if you're comfortable with that. KISS is probably best here.

RIMS with T in the mash:
This can be a dangerous setup. High circulation is your friend here and low circulation (e.g. 1-3lpm) will cause some serious dramas. Use P control only if you want to keep it simple (P of 0.2 to 0.5, 20 to 50 on Auber).
If you want to keep your wort safer, use P of 0.5 and some D control as well, e.g. 25 to 100. If you are losing too much ramp rate, check your in-tube temperature and drop this back a bit.

HERMS:
This is a graceful and handy setup but the ramp rates are inherently compromised unless you have a super-long coil and small HEX volume, and can open yourself to overshoot and very slow ramp rates if you have the opposite. You generally need PD control with HERMS, but if you have a relatively small HEX and/or a lot of coil you should be able to to just use P.
High flow, as with all setups, is best. 10-15lpm as long as you can stop your bed compacting is great.
Coil length, try to have it at least 3-5m of copper for a start. Check out page 73 of the HERMS guide for a bit on coils.
HEX volume... if you can have 5-10m of copper you should be ok up to 30-40% of your mash kg (e.g. up to 10L for a 25kg mash) but it can be dangerous (inherent overshoot, slow ramp rates) if you only have a couple of metres of coil. If you have 2-10L HEX this is probably ideal for a 25kg mash, and fit as much coil in as you can.
Big HEX, short coil: start with P of 1 (100 for Auber) and D of 100-200. If you are still getting overshoot, don't touch the P but increase the D, maybe 300 or 400. If it's too doughy, drop the D down to 50-100.
If you have a decent coil and a fairly small HEX you can probably try something like P of 5 (500), I of 0, D 0, 50 or 100 - see how you go and adjust as above: if it's doughy, reduce the D; if it overshoots increase the D.

Feel free to msg me if you want any pointers.
 
Forgot to say...

If you have HERMS and measure temp in the HEX, just use P. It's pretty well impossible to get overshoot, but your ramp rates can be pretty bad. To compensate, you should stuff as much coil in as possible, and have the highest circulation rate possible. A bigger element can help, but you are potentially better off - if keeping 10A is important - measuring T in your wort return. You should generally get better ramp rates as you approach your set point, vs measuring T in your HEX.
 
I've spent many years tuning PID loops and it can be a PITA!!! Makes me wonder if I could use adaptive loop tuning software on a HERMS......
 
The biggest issues tuning PID loops - other than the hours and hours staring at control panels - is when you have a second-order process and don't know it - or somebody doesn't know it - and don't have the appropriate control structure for that (i.e. feedforward + feedback) and you're trying to control it with a single PID controller.

Luckily in the brewing world we don't have distillation columns, or sensitive multi-pass heat exchangers between multiple distillation columns....

Most auto-tune functions in PID controllers have an algorithm that will set P, I and D. Unfortunately, if you are trying to control tank temperature, where a given heat input/step will cause a continuous rise in temp (rather than the temp now settling out and staying steady), Integral control is the last thing you want. It's sort of like having a bucket of red hot coals next to your HLT, then just as you are approaching your setpoint, throwing them in. So you only need P or PD control for any BIAB, HERMS or RIMS setup.

If you have a big HEX in comparison to your mash volume (30% up to 100% of your mash volume) and a lot of coil length to back that up you can probably get away with just P control. If you don't have any overshoot you should be able to tick this up a fair bit until you don't get anything more out of it. If you have a relatively short coil (e.g. less than 6-8m in a 1:1 HEX:mash, e.g. 100L HEX, 100L mash; or less than 2m with a 1:3, e.g. 10L HEX, 30L mash or 30L HEX, 100L mash) you will need some D in there.

Simple is good. If you need to tune the crap out of a PID controller and/or need a massive element on a small system, check your system before blaming the element or PID controller.
 
Adr_0 said:
...when you have a second-order process...
A second-order process...

...second order process...

Oh god. Now I'm remembering my control systems lectures... and now laplace transforms. Dammit. I thought I killed that with beer.
 
Back
Top