PID tuning method for electric breweries

Proper specification of PID controller settings ensure that target temperatures are met quickly but not overshot, and cycling of temperature, or more formally, the process variable, is minimized. In an electric brewery, PID settings will be system specific, and will be especially determined by element wattage, liquid volumes, recirculation speed, and other environmental variables.

I have gathered that most homebrewers utilize a trial and error method of setting their PIDs, and this works mostly fine because we utilize PIDs for low lag processes. In a typical HERMS system for instance, the hot liquor tank will be controlled to a specific temperature, which represents a calibrated difference to a target mash temperature, as detailed in a previous post. In this situation, the delay between turning on an electric element and seeing the temperature change, as well as the delay between turning off an element and seeing the temperature stop changing, is on the scale of seconds.

It’s also possible to use your PID to control your mash temperature directly without making any assumptions on the required temperature difference between your hot liquor tank and mash lauter tun. The lag in this set up is much greater, and trial and error will likely be an ineffective method of specifying PID settings.

In either case, a basic tuning procedure can be utilized to properly specify your PID settings. The procedure I am going to detail does take some time to carry out, but is not necessarily time consuming. It’s lengthy-ness is due to the fact that it involves reaching an equilibrium temperature, twice actually, for manually specified element duties.

The procedure is as follows, which has been adapted from Control Guru’s Practical Process Control ebook:

  1. If you are utilizing StrangeBrew Elsinore, ensure data recording is enabled. If you are not, grab a stop watch, a pad of paper, and a pencil.
  2. Under normal vessel usage conditions (volumes, recirculation, etc), enter manual mode and specify an element duty cycle of 8%. Allow for your vessel to reach an equilibrium temperature for this duty cycle. We’ll denote this first equilibrium temperature as temp1
  3. Now, enter a new duty cycle of 10%, and allow for the vessel to reach a second equilibrium temperature, which we’ll denote as temp2. For StrangeBrew Elsinore users, you have now collected all of the data you need, which can analyzed through temperature graphs. For brewers without data logging capabilities, you will have to pay closer attention during this process of moving from temp1 to temp2, recording some data by hand (read the entire post, and you’ll know what things to look out for).
  4. You must now calculate the following:
    1. Process gain, Kp, as (temp2-temp1)/(duty2-duty1), which in this case is (temp2-temp1)/2%
    2. Dead time, Θp, as the seconds elapsed before a visible impact of changing duty cycle could be detected (longer in this case is more conservative)
    3. Process time constant, Tp, as the seconds elapsed from duty cycle change, to when 63% of the change in temperature has been reached (that is, seconds until temp1+0.63*(temp2-temp1) is reached), subtracting the dead time, Θp.
    4. Closed loop time constant, Tc, as the larger of 0.01*Tp and 0.08*Θp for moderate action.
  5. From the previous calculations, you can now find your PID settings as:
    1. Proportional, Kc = 1/Kp * (Tp+0.5*Θp)/(Tc+0.5*Θp)
    2. Integral, Ti = Tp + 0.5*Θp
    3. Derivative, Td = Tp*Θp/(2*Tp+Θp)



23 responses for PID tuning method for electric breweries

  1. John says:

    When you say Temp 1 and Temp 2; could they be any temps? meaning temp1 153f and temp2 158f

    • jangevaare says:

      Hi John. Temp 1 and Temp 2 are the equilibrium temperatures resulting from a specific manual duty cycle. You are not setting the temps, you are setting the duty cycle. If these end up being 153 and 158 that works perfectly fine. Does that make sense?

  2. John says:

    makes perfect sense now that I’m actually doing it. I initially raised my temp to 150 and then set it to manual 15% and realized the temps were dropping… brain fart :) So now I’m starting with tap water and slowly watching the temp raise up till it levels out (in the process right now). Is there any way you could put together an example with each step just so know my numbers are in the right ballpark. Thanks for this terrific site! Has helped explain a ton!

    • Justin says:

      You could have actually just left it and had the temperatures drop to the first equilibrium temperature. Either way (approaching the first equlibrium temperature from above or below) is going to take some time. There are other tuning procedures that don’t take as long, but are not as simple to explain. I do plan on seeing about adapting one of those for homebrewers as well. Anyways, let me know how it goes. The temperatures will be different for every system, depending on volume and wattage mostly.

  3. John says:

    It’s been a while since I’ve been in school :) Here is what I came up with for my numbers: Tmp1 148; Tmp2 151; KP 1; OP 150; Tp 1404; Tc 2604 which with my calculations puts P=75.5 I=1479 D=71.196. Before I test this I was wondering if you wouldn’t mind taking a look at this and see if it looks right.

  4. John says:

    Works perfectly.. My numbers match right up! Should be a big help for guys like myself that had to ask his 6th grade daughter to help with the math :(

  5. John says:

    Alright so I plugged my numbers into strange brew. With the Target temp set at 152 and my duty cycle set at 4 seconds with the P=1, I=1479, D=71.2 It only rose the output to 33% I would imagine it would have gone to 100% until it got closer to the 152 mark. I then adjusted the P up to 4 and it’s reading 100% and the temps are climbing towards 152 mark. I’m guessing there was an error somewhere in my math although I double check everything and ran it against your app with the same results. I’ll report back how well it hits it’s mark with the P set at 4. I don’t want to spam your blog so if you are willing to help we could move this via email? If not I’m sure I can figure it out. Thanks again

    • Justin says:

      No problem about the posting messages to the blog, they might be useful to somebody.

      I will double check the equations… could you tell me more about your system? HERMS? RIMS? where is the temperature probe and where is the element?

    • Justin says:

      If you try the application again, I have added action level – aggressive, moderate, or conservative. I think aggressive is what you’re looking for :) I will update the post such that is the suggest level of control.

  6. John says:

    Typical Keg HERMS Setup with 15 gallons in the HLT and 8 Gallons in the MLT (my typical setup when doing a 10 gallon batch) . using a 50′ 1/2″ coil. I switched the “P” to 39 and it ramped up quickly and only overshot by .30 but quickly dropped back down to target temp. I also tested this by putting cold tap water into the HLT and it corrected the temp perfectly.

    • Justin says:

      Good to know. The “moderate” and “aggressive” action are clearly for expensive, slow, industrial control. Most homebrewers would rather slightly overshoot, than to very slowly and precisely hit their target temperatures. You’ve been a lot of help. I’m going to change the calculation for the closed loop constant such that it gives even more aggressive control. I originally had my P set in the 30s as well, which worked well for me. I’ve been meaning to use this process for recalibrating my set up once I move some temperature probes around in the near future, but haven’t done so yet… so everything you’ve read here has been ‘textbook’.

  7. John says:

    It seems like P is the big factor when ramping up. With your aggressive level it only goes to 1.86 which doesn’t really make a difference. IE if my target was 150 it would start dropping from 100%duty to 98%duty at 120f and continue to drop off which would take forever to raise to target. I’m guessing it has something to do with the way My calculations or process was done or maybe my duty cycle of 4? not sure

    • Justin says:

      Oh just saw this. Wouldn’t be due to your duty cycle length. The main reason the calculations gave you such a low P value is because of how long your deadtime was, this is the killer. I changed the procedure in the article such that people calibrate with a 5% change in duty rather than a 3% difference. I may even increase this further. This should make the initial change more noticeable and reduce deadtime overestimation. I’m going to give this procedure a shot tomorrow evening.

  8. […] on my previous post about specification of PID parameters, I developed a basic shiny web app to do all of the calculations for you. You can choose different […]

  9. BrunDog says:

    Do you think this would work for a RIMS tube? The response times are very fast, making measurement accuracy a bit difficult. Any thoughts appreciated!

  10. I tried my system out tonight to see what values I would get, and found that I either started my temp 1 way to soon or that 2400 secs isn’t a long enough cycle for a 5% rise. Im still slowly rising temp (started at 142) over an hour later, is strangebrew just too sensitive? I entered my temp 2400 secs later and got p=45, i=1501, and i=39.

    • jangevaare says:

      Yes, I need to update the web app to allow for longer times. I also suggest running it with only a 2% difference in duty… maybe 8% and 10%. With the values I specified here some people found that they got all the way to boiling almost.

  11. Jeromey says:

    Hey Justin, I am interested in your PID calibration calculator but when I tried to click one the link I’m the comments, seemed like the link went bad. Any chance it is located somewhere else?

  12. Timothy says:

    Can’t see any of the comments. Bummer.

  13. Leave a Reply

    Your email address will not be published. Required fields are marked *