New fridge, temperature swings, struggling with Kp, Ti & Td

#1

I have modded a new fridge and just can’t get BrewPi to come to a stable temperature. I’ve read the wikipedia article on PIDs and most postings here that I could find but I still have difficulties coming to terms with the different values in the settings, especially the scale and impact of Ti and Td.

Ti and Td are seconds, as far as I understood. This confuses me, because a higher value then means a longer time, but for Ti should also lead to quicker changes and for Td lead to more damping, right?

And then again there are some postings in here where values for Ti and Td around 1-3 are discussed, which is probably for a different version of BrewPi.

Here’s a screenshot of my current brew:


The first third are standard brewpi settings. Also, my heater was sitting under the beer and having a lot of lag on fridge temp. I moved the heater nearer to the fan and twiddled with the Kp, Ti & Td settings. (Mostly setting Ti & Td to zero and seeing what happens).

When the fridge temp drops you can see the main fermentation kicking in. I then increased Ti and Td to get rid of the oscillations, which worked fine until the beer temp dropped.

Current settings are:
Kp 3
Ti 7200
Td 600

I also don’t quite get what the input filtering accomplishes and what values I should set it to.

If would very much appreciate if someone could go to the effort to explain sensible magnitudes of values to me and what those do, and also what decreasing and increasing these values actually means. Or point me to a good article or posting. :slight_smile:

Thanks in advance!

#2

Update:
By reading a good article on PIDs and fiddling with the settings (and looking at the actual algorithm), I found out as much:
Kp is straightforward. :slight_smile:
Increasing Ti decreases the influence of the integral, with values in the thousands (= hours) seeming to work.
Increasing Td increases the influence of the differential, again with values in the thousands looking good (but lower than Ti).

And this is only looking at the fridge setpoint…
I now have the following settings:
Kp 3
Ti 10800
Td 3600

I’ll see what that does.

#3

(just to check) this fully answered your own question?

#4

Kp is proportional gain, the temperature error is multiplied by Kp to get the output.

Ti is the integral time constant. The time it will take (in seconds here) for the integral part to grow to the
same value as the proportional part if the error doesn’t change. See 8:00 to 20:00 in your chart.

Ti should be larger than how long it takes for the process to respond to a step. The purpose of the integral is only to correct steady state errors: when the fermentation is generating heat, there should be constant cooling even if the error is zero. By accumulating small errors, the integral will do this.
If Ti is too low, the integral will rise too quickly and correct errors that should be correct by the proportional part. Because the integral is slow to respond by design, you can get this oscillating behavior.

The derivative part is in the opposite direction to reduce the output when the error is already declining quickly. You should set it to roughly how long it takes to reach peak after the output turns off, the duration of the overshoot.

Based on what I wrote above:

  • Increase Kp, to leave less to the integrator
  • Increasing Ti was a good idea
  • Increasing Td probably too, but be careful not to set it too high and get a jumpy fridge setpoint.
  • Increase the minimum time between heating and cooling, the dead time, to prevent alternating quickly.

If you upgrade to BrewBlox, you can see graphs of many internal values of the PID, which will help understanding how it operates.

#5

Thanks a lot Elco, this makes it clear. I’ll keep tweaking. :slight_smile:

I plan to upgrade to Brewblox in the future.

#6

Temperature control works much better now with the tweaked settings, even though there’s a lot of noise in the setpoint. I guess the Td is set too high.
The fridge temperature swings quite a bit as well, but with very little impact on beer temp and a lot less heating and cooling going on than before.

#7

I agree, setting Td to zero is probably better.