Need help with tweaking Kp, Td, Ti

I am testing my new FC with 10L of water, and while it looks like the BrewPi is doing its job nicely at Beer Constant of 23C, I am not so sure when I set the Beer Constant to 19C. It looks like the fridge would need to heat somewhere in between to get the temp to 19C set point, but instead it cools. The room ambient is 16C


Settings are at the default values. How and what should I tweak to correct the behaviour of cooler/heater a bit.

Beer-to-Fridge
Kp=2
Ti=7200
Td=1200

Cooler
Kp=10
Ti=1800
Td=200
PWM=1200
Off time=180
On time=120

Heater
Kp=10
Ti=600
Td=60
PWM=4

I started again, this time I was heating 10L of water from 11.2C to 19C, but now it is overheating despite the set temperature was reached and is over it at 19.6C.
I am using 60W tube heater.

little update, its still hovering 1.2C above target temp… I think I need to have more aggressive cooling&heating, but I don’t know what to change in advance settings…

This looks like integrator windup, and indeed the difference between and fridge and beer temp could be higher.

Next update will have better integrator anti-windup, so that should help.

I would:

  • Set the dead time between heating and cooling to 3600 instead of 1800 to prevent cycling
  • Increase Kp for beer to fridge from 2 to 5, for a bigger difference between beer and fridge setpoint. If this causes it to clip to the maximum temperature diff, this will also prevent integrator windup.
  • Decrease the integrator time constant to 3600 so it adjusts quicker to steady state errors.

Thank you Elco, this indeed looks much better now, what do you think? I changed to your suggested settings around 20.00 on bellow graph and the Beer temp started falling to desired temp.

What about this, when I have raised Beer constant to 20C and it overshoot a little bit (0.45C). Can this be tweeked a bit more or is that as best as it can be?

I think that overshoot will be gone in the next update.

Thanks for the info. Till then is there anything else to adjust or I leave it and plan a brew day in the coming days? This is the updated graph, it looks like it needs aprox 3h to level to the target temp.

Elco, my second FC is acting differently, I can’t get it inline with target temps. I have raised kP for beer to fridge from 2 to 5 and decreased integrator time constant to 3600. Please advise.

Hmm, why it can not keep up with target temp, its cooling all the time when beer temp hits 19.8C so it drops back to 19.6C? At the moment its idling for too long instead it would heat up to 20C.

I am a bit puzzled why the integrator is not increasing your fridge setpoint. I’ll have to think about it. I am pretty sure it has something to do with anti-windup and your jumpy fridge setpoint.

2 quick wins:

  • Given that your air temperature is above the beer temperature, but your beer temperature is not increasing, your cooler is probably cooling the beer directly, instead of through the air. The solution would be to move the fridge sensor a bit closer to where the cooling happens, the back of the fridge. You could also move your beer away from the back a bit, for gentler correction.
  • Increase the filtering on the input of the beer to fridge PID, especially the derivative filtering. The derivative is what is making your fridge setting so jumpy.

Update, increasing filtering did the trick and now temps are where I want them to be. Only thing bothering me a bit is that is overshooting for 0.5C and it takes roughly 3 hours to settle at target temp, but you said this will be “fixed” in next update (do you have ETA on it?) Other than that, I am really satisfied with everything, great product!

I am running into the same issue with the overshoot taking a long time to settle to target temp. That is tough when I am trying to step mash or really trying to maintain a specific temp for the mash. Any insight into how to resolve this or when this might be fixed in the next release would be greatly appreciated.

Thanks again, so excited to be able to start mashing with BrewPi!

This is my graph now, with the script doing too much, too late, resulting in oscillation. What would you guys think I should change? I agree with another post that the settings GUI could be made more easy to understand. Especially for less techincal guys like me.

Thanks, Rodge.

Are you running 0.4.3? Overshoot should be less with the latest version.

Please post the content of the control algorithm tab.
Post like this:

content here

The 3 backticks will make the block formatted as code.

Yes it is on 0.4.3.


{
  "kind": "Control",
  "pids": [
    {
      "kind": "Pid",
      "name": "heater1",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 23.5156
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.9375,
            "connected": true,
            "address": "289C5636070000E0",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -2.2734,
      "Kp": 5,
      "Ti": 600,
      "Td": 60,
      "p": 11.3672,
      "i": 0.043,
      "d": 0.0195,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 11.4297,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 1798955
          },
          "target": {
            "kind": "ActuatorPin",
            "state": false,
            "pin": 17,
            "invert": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "heater2",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer2set",
        "value": null
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer2",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 10.5,
          "connected": true,
          "address": "28FF01877115036F",
          "calibrationOffset": 0
        }
      },
      "inputError": null,
      "Kp": 10,
      "Ti": 600,
      "Td": 60,
      "p": 0,
      "i": 0,
      "d": 0,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 4,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 1798885
          },
          "target": {
            "kind": "ActuatorNop",
            "state": false
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "cooler",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "fridgeset",
        "value": 23.5156
      },
      "inputSensor": {
        "kind": "TempSensorFallback",
        "onBackupSensor": false,
        "sensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.9375,
            "connected": true,
            "address": "289C5636070000E0",
            "calibrationOffset": 0
          }
        }
      },
      "inputError": -2.2734,
      "Kp": 10,
      "Ti": 1800,
      "Td": 200,
      "p": 22.7344,
      "i": -0.4453,
      "d": 0.0391,
      "actuatorIsNegative": true,
      "outputActuator": {
        "kind": "ActuatorPwm",
        "value": 0,
        "period": 1200,
        "minVal": 0,
        "maxVal": 100,
        "target": {
          "kind": "ActuatorMutexDriver",
          "mutexGroup": {
            "kind": "ActuatorMutexGroup",
            "deadTime": 1800000,
            "waitTime": 1798809
          },
          "target": {
            "kind": "ActuatorTimeLimited",
            "minOnTime": 120,
            "minOffTime": 180,
            "maxOnTime": 65535,
            "state": false,
            "target": {
              "kind": "ActuatorPin",
              "state": false,
              "pin": 16,
              "invert": false
            }
          }
        }
      }
    },
    {
      "kind": "Pid",
      "name": "beer2fridge",
      "enabled": true,
      "setPoint": {
        "kind": "SetPointSimple",
        "name": "beer1set",
        "value": 20
      },
      "inputSensor": {
        "kind": "TempSensor",
        "name": "beer1",
        "sensor": {
          "kind": "OneWireTempSensor",
          "value": 19.75,
          "connected": true,
          "address": "28EF9C36070000BE",
          "calibrationOffset": 0
        }
      },
      "inputError": -0.168,
      "Kp": 2,
      "Ti": 7200,
      "Td": 1200,
      "p": 0.3359,
      "i": 0,
      "d": 3.1797,
      "actuatorIsNegative": false,
      "outputActuator": {
        "kind": "ActuatorSetPoint",
        "targetSetPoint": {
          "kind": "SetPointSimple",
          "name": "fridgeset",
          "value": 23.5156
        },
        "targetSensor": {
          "kind": "TempSensor",
          "name": "fridge",
          "sensor": {
            "kind": "OneWireTempSensor",
            "value": 20.9375,
            "connected": true,
            "address": "289C5636070000E0",
            "calibrationOffset": 0
          }
        },
        "referenceSetPoint": {
          "kind": "SetPointSimple",
          "name": "beer1set",
          "value": 20
        },
        "output": 3.5156,
        "achieved": 0.9375,
        "minimum": -10,
        "maximum": 10
      }
    }
  ]
}

Ok,

I think your settings for beer-to-fridge are better changed and are what is causing the overshoot.
Fridge setting = beer setting + P + I + D = beer setting + Kp * (beer error + integral of beer error / Ti - derivative of beer error * Td)

Kp is only 2, which means that if the beer temp is 1 degree to low, the fridge setting is 2 degrees above the beer setting.
This seems to be too low to make your beer temp do anything, it is pretty slow to respond.
This is compensated by the integrator: it slowly builds up to get the beer temp moving. But it is also slow to unwind.

If you increase Kp, the proportional part will do more, and the integral will not wind up.

So try setting Kp to 10 for example.

OK will try as you say. Gets confusing with also the heater and cooler having separate controls as well. Thanks.

Hello there! Brewpi with arduino build here, I’m having a bit of beer temp fluctuation, don’t know if this is normal acting for the system.

Your beer temp rises and falls quickly, are you using a thermowell in a large volume of beer?

The Arduino version of BrewPi is really designed to work with a slow changing beer temp and a faster changing fridge temp that it can regulate to gently adjust the beer temp.

Your Ki seems way too large though, klipped to the max even. The integrator should grow slowly to correct long term errors. It should take hours before it is higher than Kp and it should not be higher than Kp if you have a degree difference.

Try setting Ki to 1.5.

For others reading this, please note that the PID algorithm in BrewBlox has changed a lot and we use Ti, a time constant, instead of Ki, a gain. The values given here do not apply to BrewBlox.

Ya I’m just testing with a large fermenter with 25l of water and a thermowell, but I’ll use 15l fermenter then.
Should I update to brewblox?