AHB Wiki: PID Tuning

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,

This Wiki captures PID tuning, which is a follow-on from the basics on On/Off and PID control, found here:
http://aussiehomebrewer.com/topic/93924-ahb-wiki-pid-and-onoff-control-basics/?p=1431568

The tuning Wiki is below, which captures the following:
  • Specifics about the P, I and D terms
  • Why a home brewery is a little different to most common processes
  • Example P and PI responses
  • Tuning the controller
  • Notes on fridge/freezer control
View attachment PIDTuningWiki_rev0.pdf

Hopefully you find the Wiki is helpful.

Cheers,

Adrian
 
That's an excellent resource you've created. I do not think I've ever read a description of PID that is as accessible and as thorough.
 
Excellent.
Answered a lot of questions I'd had for a long time.
Thanks Adr_0
 
If anyone has any questions or experience they would like to share, it's probably a good spot to do so.
 
I have a question then!

For my HLTs (and HX) the PID parameters are K=500, I=0, D=0.45. (Arduino PID library)

It gets to within a few degrees of target in a reasonable time, and it never goes over.
The problem I have is that it bloody crawls those last few degrees.
In a small vessel it's pretty much OK, but in my big kettle (120L / 4500watt element) those last few degrees can take ages (an hour?). If I'm waiting around for it I can just fudge the set-point up a bit, and it gets the job done. But the whole point of the PID control is to not have to stuff around with it.

Adding any sort of Integral parameter produced overshoot, so we agree on that.

Is there some approach I can use to tune this?
It takes about an hour to heat ~120L water to say 75C, that's a long test-cycle time.
The arduino auto-tune library returned a useless result after about 20 minutes.

thanks,
-kt
 
Mr Wibble said:
I have a question then!

For my HLTs (and HX) the PID parameters are K=500, I=0, D=0.45. (Arduino PID library)

It gets to within a few degrees of target in a reasonable time, and it never goes over.
The problem I have is that it bloody crawls those last few degrees.
In a small vessel it's pretty much OK, but in my big kettle (120L / 4500watt element) those last few degrees can take ages (an hour?). If I'm waiting around for it I can just fudge the set-point up a bit, and it gets the job done. But the whole point of the PID control is to not have to stuff around with it.

Adding any sort of Integral parameter produced overshoot, so we agree on that.

Is there some approach I can use to tune this?
It takes about an hour to heat ~120L water to say 75C, that's a long test-cycle time.
The arduino auto-tune library returned a useless result after about 20 minutes.

thanks,
-kt
How long is your coil, and what's your element size and mash tun size?

I'm pretty sure Auber has P in units /100, so 300 is actually a gain of 3 - is Arduino the same? And do you know if the D term is in per second or per minute?
 
In my HLT, it's a big 185 litre pot with a 4500 watt heater element. Obviously the amount of water varies on brew-size.
Generally the more water, the slower it crawls over the finish line. With 120 litres, I guess it takes about an hour to cover the last 2 oC. This is my real problem, that lousy 2oC. It's quite frustrating, you can watch it and see the algorithm only flashes the heater on for a split-second, yet it still significantly below the correct temp. It's been suggested to not start using PID until it's within a degree of set-temp, but this removes the whole point of using PID.

BTW, and FWIW: The pot is insulated (yoga mats!).


But the HX ~ Ah, ahem, geeze.
735HERMIT_COIL_KIT_LG.png


Ok, so it's Nev's s.steel "HERM-IT" coil. - https://onlinebrewingsupplies.com/herm-it-r-coil/herm-itr-coil-kit
It doesn't say exactly how long it is, but 9x coils, with 12mm tube, ~90mm OD. So that's: 9 x Pi x 90 => 2544.7 -> so say 2.5 metres[1].
It's in a about a 6-litre pot, with a 2500 watt element. With the coil submerged, there's just about exactly 5 litres of water around it.
It doesn't really have a whole lot of trouble getting to the target temperature.


The way Arduino PID library[2] is used is that the PID-control governs the amount of a 5 second window used for heating each iteration.
So for "full power" that whole 5000ms is used, but for "half power" only 2500ms of it used, etc. The output of the PID computation is how much of that 5000ms should be used for heating in the upcoming 5000ms. It has to be like this, because a heating element can only be on or off.

I think this 5 second time amount is a bit arbitrary, if it's shorter or longer, the PID algorithm would still turn the heater on for a calculated percentage of the time.
With a smaller time, it would evaluate the should-I-apply-heat-now question more often, but I expect it would heat much the same (probably).

I'm not at all familiar with any PID stuff other than this Arduino Library (I did not do any control systems courses at uni), so I can't really say what the units represent - if anything.

I have, for example, used the same PID library to hover a quad-copter test-balance-arm by changing the motor speed on feed-back from a gyro' (here P=2, I=0.95, D=0.011) - so the library works well, and is pretty flexible. But I don't think it has the concept of the units meaning anything in the non-mathematical sense. I guess that's not much help but.

thanks,
-kt

[1] circumference of a circle is (Pi x diameter), a coil is roughly /N/ diameters, thus length is (/N-coils/ x Pi x diameter).
[2] http://playground.arduino.cc/Code/PIDLibrary and an intro to it http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
 
So where are the probes that are controlling your temperature? If you're using 2.5m if coil in 5L that's pretty good, though your temp control should be on the wort return to the mash tun.

I say good because you should also be able to get a fair bit of pump flow - what is your limitation there? Do you have a KK fully open or choked?

And the other temperature problem is on the HLT, where you have a PID controller and it struggles to get that last degree or two? This isn't a problem in your mash?
 
Probe on the HX is on the top of the coil right at exit.

Probe on the HLT is near the bottom, on the same level as the element.
The HLT probably does need a mixer, or recirculating pump.

Using KK pumps, fully open. Silicon hose inter-connects.
 
Sweet.

Yeah, regarding the HLT you've hit the nail on the head. Mixing - even by stirring - will help that a lot. For the PID on the HLT I would drop the D term completely - make it 0 - and keep the Gain at 500. Technically the element is a touch under-sized to get a good ramp rate - 7200W is probably ideal - but if this isn't an option you might consider gas assist as well (with an alarm from your Arduino at 80-90°C to turn it off). Mixing of the HLT means you should hit your setpoint with P control only and it should be bang on.

Regarding your MLT, if I were you I would actually consider putting control in your mash tun, in the middle and maybe 2-3" below the surface, and plugging the existing probe takeoff on the HERMIT. Your P and D values should probably be 100 and 2... I'm guessing that by some other applications your integral and derivate units are minutes, not seconds. In your wort return temperature you'll get an overshoot of 1-3°C for a period of 5-10 minutes but should hit your mash temp quite well. For 80L-120L mash volume this should be ok. For 80L you can hopefully do a 10°C ramp in 30-35min and 120L in 40-45min.
 
Just for interest as well, here is a bit of sensitivity with HEX water volume over your HERMIT, assuming a 65 to 77°C ramp - I was curious how hot the water would get and how much capacitance the extra water would give (worsening overshoot). I kept the same P 1, D 3min values for all four. Interesting anyway. The RED is 5L of water over the coil, with BLUE being 3L, orange 7.5L and green 10L.
MrWibble-HEXvol-3-5-7.5-10.png

All of my modelling has been using the 240V KK pump with 1/2" SS tube. This ends up sitting around 8lpm (assuming 2.5m + 1m of extra plumbing) - theoretically - which I think is fine. You can possibly achieve more but I'm not sure about your mash geometry and drawoff, and if you'd get stuck mashes at higher flows.

I think the KK pumps are fine with the HERMIT coils or RIMS, but I think a slightly bigger pump is needed in systems where there's 10-15m of coil, just to overcome the pressure loss and keep flow up - to keep turning over the mash volume. On the KK by the time you have 50ft/16m of coil you're only at 4lpm which doesn't do you a lot of favours for bringing the mash temperature up.
 
Problems made worse by the ~3m of silicon tubing used for inter-connects (Mash->Pump->HX->Mash).

I've read that s.steel pipe (even with bends) gives much less pressure loss (over silicon).
But I'd need a more permanent setup for my system before these could even be thought-about.
Time to get to work on that brew-stand.
 
I'm trying to use Mr Wibble's controller and am having a lot of trouble with the PID control. 14.5l in mash tun, HERMS + Kaixin pump. Here are the two scenerios I've trialled -

P = 500, D = 0.45 - full heating when far from setpoint, but very very slow to get to target temp (over an hour and still didn't quite get there).

P = 100, D = 2 - cycling heating even when 35°C off target temp. Got there relatively quickly and overshot by 7°C still going higher. Stopped.

This seems to counter the advice in the manual in post #1. Any ideas?
 
TheWiggman said:
I'm trying to use Mr Wibble's controller and am having a lot of trouble with the PID control. 14.5l in mash tun, HERMS + Kaixin pump. Here are the two scenerios I've trialled -

P = 500, D = 0.45 - full heating when far from setpoint, but very very slow to get to target temp (over an hour and still didn't quite get there).

P = 100, D = 2 - cycling heating even when 35°C off target temp. Got there relatively quickly and overshot by 7°C still going higher. Stopped.

This seems to counter the advice in the manual in post #1. Any ideas?
My first point would be to try and get definite answers on the units used. I understand there is a library - is there any documentation accompanying this? I ask this because even professional controls engineers make the common mistake of simulating response, and don't know whether units in the control system are in minutes, seconds, repeats person minute, gain, etc.

Secondly, you should keep gain the same when you are changing D as they are directly related to a certain point. A setting if 500 for P is probably fine.

So talking about the behaviour, it's possible that you were closer with the first settings and needed a shorter derivative window, so a changed from 0.45 to 2 is not totally unreasonable (factor of 4), but with the gain change you are potentially changing the compensation by a factor of 20. You likely have a system with inherent overshoot, so it needs controller action to keep to setpoint - believe it or not P is part of this too.

It does really come back to documentation and understanding the units or at least expected behaviour of the D and (if anyone it interested for their work) particularly the units for I.

I can run some examples if you give me some more info on your setup, but hopefully that's a bit of useful information.
 
One more quick one...

If you found that the initial response didn't overshoot and took a while to get to setpoint, I would call this a little doughy. Shouldn't you then reduce the D term?

You should try P 500, D 0... And then perhaps D of 0.2 if you get find you got overshoot with D of 0.

The D term coukd be Gain, but it could be time or number of evaluations as well. Thinking about your response, it's quite possible that the D was gain and was overreacting to changes in PV or error, with lag exacerbating the issue. So D should be reduced and gain increased.

So should still get to the same answer of P 500, D of 0 or 0.2.
 
P 500 and D 2.0 resulted in slow to get there and slowly overshot by about a degree over 10 mins. Trying D 400 and D 1 to see how it goes.
 
TheWiggman said:
P 500 and D 2.0 resulted in slow to get there and slowly overshot by about a degree over 10 mins. Trying D 400 and D 1 to see how it goes.
Why are you changing the gain? The overshoot is not resulting from excessive gain like self-regulating systems, it's from lag in your system. Leave the P at 500 and change the D.
 
Back
Top