This page provides details about the control logic used with Brewno Controller.  There are four independent controllers in V2 of the Brewno Controller. Each of the four controllers (or control loops) can be configured as required by the user.  Each control loop has a corresponding temperature input and SSR output.

To configure the controllers, the Brewno PC Program is required.  Each controller has it’s own settings that the user can access via the tabs at the top of the Brewno PC Program.  Once saved, these settings are recalled automatically on power-up by the Brewno Controller hardware.

  1. First open and connect the Brewno PC Program to the Brewno Controller
  2. Go to the controller tab you want to configure; the setting options are the same for each one and will appear as per the screen shot below
  3. Per the note at the top of each controller tab, make sure to load the current settings from the Brewno Controller before you make any changes or click Save to avoid loosing settings.  The program interprets any blank cells as Zero or Null and will write that to the Brewno Controller and therefore overwrite any existing settings.
  4. When you do save settings, it’s a good idea to click Load again to ensure everything was saved as expected.  The odd time a value is lost in translation between the PC and the Brewno Controller.  Doing a quick check will help you avoid unexpected behaviour.

Controller Parameters

Controller Name

Allows up to 7 characters.  This name will be displayed on the Brewno Controller LCD screen.

Controller Type

There are two automatic controllers, a temperature reading only option and an option to disable the control loop.

  1. Not Required – This option disables the control loop and will not display any information for the control loop on the Brewno LCD.
  2. PID – Automatic controller using Proportional, Integral, Derivative control.  Common controller type capable of ±0.1F accuracy in this implementation (pending system and tuning).  Best used for devices that can be switched on/off frequently (eg. electric element).  For more details on the implementation of the PID controller used with the Brewno controller, see the PID section below.
  3. Hysteresis – Automatic controller that operates with a dead band.  This is an on/off type of controller similar to most home furnaces.  When the temperature drops by a set amount (the dead band) below the set temperature, the controller will turn on.  It’s not as accurate as a PID controller but better suited for devices that don’t like frequent switching (eg. a pump).  For more details on the implementation of the Hysteresis controller used with the Brewno controller, see the Hysteresis section below.
  4. Temperature Reading – This sets the control loop to readings only and does not perform any type of control.  Use this setting for a loop

Manual Mode

There are two options for manual mode:

  1. Percentage – Typically selected when using a PID controller.  When the Brewno controller senses the control loop switch to manual mode, it will switch output to the user set percentage.  A common example would be entering manual mode to set a percentage output and maintain a boil in your boil kettle.
  2. None – Typically selected when using a Hysteresis controller.  When the Brewno controller senses the control loop switch to manual mode, it will disable automatic and will not provide any output.  A possible implementation is on a pump where the manual mode likely involves a hardwired switch on the electric panel that allows the user to turn the pump on/off.

RTD Offset

RTD Offset allows the user to calibrate each RTD.  This should be done for all RTDs as they are often out by a couple degrees due to the instrument itself and associated wiring.  One calibration method is to insert your RTD into an ice bath.  The ice bath should be mostly made up of ice, but should still have enough water to keep everything fluid.  Your RTD should read about 32F, if it doesn’t, add the required offset to the controller so that it does.

A good recommendation is to match up an RTD and cable with a control loop once calibrated.  Moving RTDs, or even cables, around may void your calibration efforts.

Re-Initialize RTD Shield

This is a left over feature from version one of my controller.  I do not recommend that you use this feature.  If your temperature readings look wonky you can try and use it to restart the shield; however, it often results in inaccurate readings.  The Arduino and Brenwo shield are designed to be powered on together; when the shield resets post power up, it doesn’t always boot properly.  If required, the recommended option is to power off the whole unit and turn it back on.  Remember to unplug any USB cable to ensure the unit does power off.

Time Period

The frequency that the controller compares the actual temperature against the set temperature and adjusts the output.  You might think the shorter the period the better, and in theory that is correct.

For the Hysteresis controller you should choose a shorter Time Period.  Something around 1000ms (1s) will work well.

For the PID controller it’s a different story.  For a typical electric element controlled via an SSR, you should set the Time Period to about 4000 milliseconds (4s).  This is long enough to mitigate the affect of noise on the controller and avoid unnecessarily quick on/off cycles.  4000ms is still short enough though to achieve accurate control.  You can experiment with different cycles though to see what works best for your setup.  For more details, please read the PID section below.

Minimum Cycle

This is the minimum time that the output will turn on for when using the PID controller.  The controller will not output anything if it calculates an output smaller than the defined Min Cycle.  This value has limited value in most cases, but provides the option if needed.  For electric heaters the suggested value is 50ms.  If you are trying to control a pump with a PID, you could set this at a higher value but hysteresis is likely a better control method for pumps.

PID Settings

The Kp, Ki, and Kd parameters are used for the PID automatic mode and can be tweaked for your specific brew setup.  The default settings are configured for a 10 gallon electric brew system.  If you have a smaller system, decreasing the value of Kp may help increase accuracy.  If you have a larger system, increasing the value of Kp may help.  For more details on the specifics of the PID implementation and the PID parameters, see the detailed PID section below.

Hysteresis

This is the dead band for the Hysteresis Automatic controller and by default is set at 0.5°F.  The dead band is the range in which the Hysteresis controller will remain off.  Take your home furnace as an example, it will turn on until it reaches the setpoint and then shut off and remain off until it drops a certain amount below the set point; this is the dead band.  The smaller the dead band the more frequent your controller will cycle (and likely overshoot); the larger the dead band the less cycling but too large and it will not maintain your temperature very well.  For more details see the detailed Hysteresis section below.

Brewno PID

Anybody looking into an electric brewing setup has at least heard the term PID.  PID controllers are found everywhere.  They’re the most common controller in industry.  You may even have a few in your home (eg. that espresso machine on your counter).  If you want to read up on PID controllers and how they work there are many resources on the web.  I’ll keep most of this section to the specific implementation in Brewno.  In short though, a PID controller takes the error between the Set Point and the Process value and calculates controller output based on this error using 3 terms.  A Proportional Term (acts proportional to the current error instance), Integral Term (acts on the sum of the error that has accumulated over time) and finally the Derivative Term (acts on the rate of change of the process value).

The Brewno PID uses the Arduino library created by Brett Beauregard.  Adaptive tuning specific to brewing applications has been implemented (more on this below) and it has been tuned with parameters that should work for most setups.  The Brewno PID sets output based on a user defined time period.  This is the same method as the PID units many people already employ for their electric brew setup.  The upsides are that this method minimizes the affect of “noise” on the control loop, and it minimizes component switching frequency.  Typical brew setups are relatively slow acting so that we can use this method with time periods of around 4 – 5 seconds and still get good control.

A quick example on how this works.  Let’s say you set the Time Period for the HLT controller to 4000ms (4s).  At the start of the Time period the PID controller performs it’s calculation and comes up with an output of 40%.  The controller will then turn on the output (ie. an electric element) for 1600ms (1.6s) and turn it off for the remaining 2400ms (2.4s) of the Time Period.  When the next Time Period begins, the PID will perform another calculation to determine the new output.  I would recommend that for the PID controller you don’t go lower than 4000ms for a time period. In theory a smaller time period should improve control, but we start running into limitations of the controller and hardware speed.

The program takes about 50ms – 100ms to cycle through depending on what logic is being run; therefore we can’t get reactions quicker than that.  Let’s say you choose a Time Period of 1000ms (1s).  Let’s say your controller calculated an output of 4%; 4% of 1000ms is 40ms.  Since the program may take 100ms to cycle, your 40ms of run time may turn into 100ms which corresponds to 10% output.  In brief, you’re limiting your practical output to 10% – 100% and this can cause accuracy issues.  The minimum cycle time by default is set to 50ms to minimize this problem as the current logic can’t run any faster than 50ms per cycle; any output smaller than 50ms will not be acted on.  This will help minimize overshoots but not undershoots.

With a 4000ms Time period, your lower output limit is between 1.25% to 2.5% and I’ve found it to control very well.  In my testing with my current Tuning and Time Periods I can control my HLT to ±0.1°F.

Control Accuracy Depends on PID AND Your System

With any controller, the system properties will have an affect on the quality of control.  For some factors you can address using tuning, but factors that impact reading qualities will decrease accuracy of control.  Garbage in, garbage out. One that really hit home while I was performing PID tuning was the difference between Flowing vs Stagnant Control in the HLT.

Water is conductive and convective currents are created during heating; therefore I should get good mixing and accurate readings in my 16 gallon HLT without forced circulation.  WRONG!  After having troubles tuning my PID and noticing a lot of variation in the temperature readings, I tried circulating the HLT water.  A picture (or graph in this case) is worth a thousand words.  Circulating the water ensures much better / quicker mixing, which provides more accurate readings and allows tighter control.  Others have noted this before including Kal at The Electric Brewery.  What I haven’t seen yet is anyone providing data to show what a difference it makes.  It makes a BIG difference. This is just one of many reasons I like data logging.

I should note that I do have my RTD inside the vessel and not on the outlet piping.  I find this location beneficial for sparging when I don’t have a 3rd pump to be able to circulate the HLT.  Even with the RTD in the vessel, I get very stable readings when I circulate the water.  During sparging I accept the extra bit of variation in the HLT.

 PID Control Stagnant vs Flowing

Brewno Adaptive Tuning

Having a digital PID controller has some very useful benefits.  The biggest benefit in my opinion is the ability to use adaptive tuning.  With most PID controllers you just input one set of parameters and that’s what the PID controller uses all the time.   I should point out that just because other PIDs out there may be digital, it doesn’t mean they use adaptive tuning; it depends on the implementation.

For systems that are being controlled at a steady state, a traditional implementation with one set of tuning parameters works just fine.  For systems where the user is frequently putting the system into a transient state and causing large error values (eg. Initial system startup, changing Set Points) we can run into some problems with the traditional PID implementation.  What kind of problems?  Here are two key ones:

  1. Excessive Initial Overshoot and Sustained Overshoot caused by:
    • Large Proportional Value – Increasing the Proportional term is great for speeding up system response, but it also increases your initial overshoot and increases the time to settle into a steady state due to larger oscillations around your set point.
    • Integral Windup – The bigger problem is mitigated with the Brett’s PID library; however, we still get negatives effects of Integral windup when we cause large gaps between the process value and the set point (ie. at system startup or change in set point). This causes higher initial overshoot AND sustained overshoot above your set point
  2. Slow System Response – Derivative fights the P and I terms (more on this below).  While that derivative term helps prevent overshoot, it’s painful to sit there and watch your output fire at 50% when you’re still 50°F under your set point.  Another way to fix this would be to lower or get rid of your Derivative term, but then you will have to live with more temperature overshoot above your set point.

If you’re sitting there thinking “What’s the big deal with a couple degrees of overshoot or sustained error of a degree or two?” then let me ask you this: “Why are you looking at using a PID controller?”  If you’re not concerned about a few degrees of overshoot or error, don’t bother with a PID controller.  Go to a Hysteresis controller, or go with a straight P controller (PID without the I and D terms).  These are much simpler implementations that do a pretty good job of control for many systems and they will outperform a PID controller with bad tuning.

So how do we address these concerns?  In very simplistic terms, we setup the controller programming to operate more like we would if we were sitting there controlling the output by looking at where the process value is in relation to the set point.  We know that when we increase the set point by 40°F, we can run the output at 100% to close at least 35°F of the gap and probably more before we start backing off.  If we increased the set point by 40°F, we also know it’s not an error we should be accumulating for the Integral term as we introduced the large error by changing the set point.

Take a look at the chart for more details.  Basically the Brewno PID is very aggressive and uses a very High Proportional Value only when the Process Value and Set Point are > 2°F apart.  When the difference is less than 2°F, the controller switches over to more conservative tuning using the full PID terms to reduce overshoot and maintain an accurate steady state.  There are a few more details to the implementation, but this hits on the major points.pid_control_adaptive

I’m sure there are still more improvements that could be made, but I am very satisfied with how well the PID controls currently when compared to my previous Electric Brew setup that used the packaged PID controllers.  The Brewno controller bring me to my set temperature much quicker and controls more accurately.  The best of both worlds.

Holy Derivative Batman!

If you’ve taken a look at my tuning parameters, and you have some experience tuning PIDs, you probably think I’m nuts with how high my derivative term is.  I was taught in University that D = Dangerous and too much Derivative can make a control loop unstable.  If you do some searching on google, you’ll find the same warnings.  When doing my tuning, I started out with a very minimal D term, but as I got experimenting I found the system responded great to the higher D term.  There are two reasons why the higher derivative term works well in the Brewno controller:

  • Adaptive Tuning – Without adaptive tuning it wouldn’t work well as it would be fighting the PI terms constantly and you would have a very very slow responding system (ie. heating from 150°F to 170°F would take a long time).  With Adaptive tuning, the high D term is only applicable when the process value is within 2°F of the set point which is when it’s useful.
  • Frequency of Computations – Too much derivative term can cause a system to become unstable in part due to noise in the readings used for the PID calculation.  With the PID using a time period that is a couple of seconds this mitigates the affect of noise as the PID is taking the current reading – the previous reading from a few seconds ago and the noise is very very small relative to the rate of change we’re looking for in a couple second time period.

To get a better idea of how the different parameters affect the the PID output, go to the Download section and get the excel work sheet.  This is very rudimentary as it looks at one point in time and any of the time based readings are assuming no change to the process value but it gives you an idea of how much each tuning parameter will impact the output and is helpful if you’re trying to come up with different tuning parameters.

Where’s the Auto Tune?

I’m not a fan of Auto Tune; especially for these types of systems that are very slow acting.  I believe it often gives people a false sense of security and many people don’t realize the tuning parameters are bad as long as it’s controlling within a couple degrees.  When I was using the PID modules in my previous setup, I could perform Auto Tune 3 different times and wind up with 3 vastly different sets of tuning parameters.  Having said that, there are factors that can ruin Auto Tune just like with control.  If I wasn’t circulating previously, this could have been part of my problem as the noise from readings could have thrown the Auto Tune off.

If there is enough interest, I can look into this further.  Brett Beauregard has built an Auto Tune Library for the Arduino already; if this works for a typical brew setup it shouldn’t be very hard to incorporate and should only be a software update.  For now, the default settings should work well for most setups and I’d highly recommend trying them first.  If you want to manually tune yourself, go to the resource section and go to the National Instruments link for tuning guidelines.  They provide some straight forward rules to follow.  One exception is that you can use a much higher Derivative parameter with this controller.  Go to the Download section and get the Tuning excel sheet.  This will help you figure out some decent values to start with.

A PID is a great controller for many applications but it’s not always needed, and not always the best fit.  Hysteresis Control is basically On-Off control with a dead band.  It works like your basic home thermostat.  If your home’s temperature falls X amount below your set temperature, your home furnace turns on and stays on until the temperature rises to your set temperature.  X is typically called the dead band; you’ll see me refer to it sometimes as the Hysteresis Offset or simply Hysteresis here.

For devices such as your home furnace, Hysteresis control makes a lot of sense.  It’s simple and easy to implement; your house can vary by 1°C without really being noticeable and it prevents your furnace from frequent stop/starts.  You can imagine that having a PID controller, or even a Hysteresis controller with a small dead band (say 0.1°C), would cause frequent stop/starts and wear out your furnace very quickly.  As a general rule of thumb, mechanical devices are often better controlled with Hysteresis as they do not typically like frequent switching.

In the Brewno Hysteresis controller, X is set by the user.  As most brew setups are relatively slow acting, you can typically get away with using a fairly small Hysteresis.  The downside of using too small of a dead band is you will see more overshoots.  More overshoots may cause your average temperature to be higher than your set point.  If this is not what you want, increase the dead band amount to lower your average temperature.

See the plot below that shows typically Hysteresis control.  Here the dead band is set at 0.25°C and results in more overshoots.  You’d likely want to increase the dead band to 0.5°C or 1°C to get an average closer to your set point.  For the keen observer that has read my PID section below, you’ll notice the temperature readings are a bit erratic.  I forgot to circulate my HLT when doing this plot and therefore the erratic temperature readings.  For more information on this, read the PID detailed section above.

When using the Hysteresis controller I highly recommend that you change the Time Period somewhere around 500ms (0.5s) to 1000ms (1s). With the Hysteresis controller there’s no real benefit to having a longer time period (ie. 4 seconds); it will actually cause more overshoot as the controller will only check if it’s at the set point every 4 seconds.  That’s potentially 4 seconds of output that’s not desired if it happens to check when the process value is just under your set point.  The same logic applies when the controller is off and waiting to fall to your Set Point – dead band.

Hysteresis ControlHysteresis Control Details

Leave a Reply