PID Tuning - Hitting the 0.18 def f (0.1c) Precision Mark

Hello guys, wanted to get your recommendations on fine tuning the Cool PID. Fermentation just kicked in on a high gravity DoppelBock, been very pleased with the temperature control when compared to my previous system. However, I’ve noticed a variance of about 0.7 deg f and would like to see if I could get this tighter.

Control mode: Beer
Cool PID: Kp = -27.78, Ti: 6h, Td: 30m
Cool Actuator has 3 constraints: Min Off = 5m, Min On = 2m, Extra lock time 10m

Here is a link describing my build. Let me know if there is something else I need to clarify about my system. It may be worth mentioning that I have the thermostat set at the minimum cooling level on the freezer. In other words, I can crank it up if I need to cool faster.

Here is an export of the fermentation data with a timespan of 1 day. Let me know what you think.
graph-Left Ferm Graph-spark-left-downsample_1m.csv (174.7 KB)

Can you share a screenshot or image export of the PID graph?
Preferable after a step down in temperature.

From the PID chart, we can see whether the actuator action is mainly due to P, I or D, which will give an idea of where to start tuning.

Here you go. I removed the beer set point trend from the graph. For reference, it is still set at 55.

1 Day

Past three hours.

Zommed in.

I think the derivative gain is too high at 30 minutes.
The filter selected depends on the chosen derivative time constant, but perhaps it is also causing too much lag for a counter effective result.

I think it is worth changing the code to be able to set the filtering on the derivative separately from the time constant (gain).

For now, try reducing Td to 5 minutes.

Update. Elco, think your first assumption was spot on! Temp is staying very close to the target set point. Thanks for the suggestion. What do you think the next step would be to have it actually hit the target temp? I do realize I am talking about a few tenths of a degree which wont have a real impact on the beer. However, for the sake of my learning and others reading the post it could be helpful.

(In these graphs there was a 30 min power outage around 11am)


So I had an opportunity to sit down, eat lunch and talk with a process control engineer. He is highly revered and often sought after when dealing with Oil and Gas process control. He is also a fellow home brewer. Being a tech guy, I was able to pull up my system on my phone and show him what I was doing with BrewPi. I will say he was highly impressed with what the BrewPi team has put together. After telling him what it cost his jaw hit the floor. You guys might get another customer out of the deal. :+1: :wink:

While geeking out over all this he brought up the point that, in his experience, he recommends setting the derivative as small as possible. In the Oil and Gas industry for example, he will always set D to 0.0001 and work up from there as needed. I will mention that this application is quite a bit different than what he normally deals with. At any rate, his first recommendation was to lower my derivative value even further. He had also pointed out a flaw in my initial assumption. Initially I had thought the thermostat on my freezer would adjust the intensity of my cooling process as well as lower the temperature. This was not true. It is merely a temperature control. With that he recommended that I lower the proportional value by another 10 degrees and see where that takes my system. As he gets more familiar with BrewPi and understand the control philosophy he might have more recommendations. But I was impressed with his quick analysis and recommendations, even more so without him having knowledge of the control matrix.

In summary, here are my new settings and results. We will see how it works throughout tomorrow. Elco, please let me know if you have a different perspective. With your knowledge I would trust your judgement over his with this setup.

Kp: -37.78. Ti: 6h. Td: 1m.


Looks like things went very well overnight. Still running with these settings: Kp: -37.78. Ti: 6h. Td: 1m. Kp was adjusted around 4 pm and Td at 6 pm. May be a bit early to call it a success, but as it stands now it looks like I was able to achieve the desired 0.18 deg f precision levels. :+1: Was actually pleased to see the small overshoot.

Past 18 Hours:


Past 3 Days:


2 Likes

I think his recommendations are correct. You could even consider disabling the derivative entirely by setting it to zero.

Perhaps your Kp could be even lower. Another option might be to increase the filtering a bit in the beer setpoint.

1 Like

Thanks for the reply. Which setting would control the filtering?

You can find the “Filter period” setting in the Setpoint block. You can access the Setpoint block either through the spark service page, or from the PID settings.

Found it. Thanks Bob.

1 Like

Gentlemen, I appreciate the help and feedback. Elco, I took your advise and lowered Kp once more. Looks like we’ve been able to hit it on the nose! Currently controlling at temp with an 0.11 deg f swing. :beers:

  • Final cool settings: Kp: -47.78. Ti: 6h. Td: 1m.
  • Cool actuator: Min off: 5m. Min on: 2m. Extra Lock Time: 45m.
  • Heat settings: Kp: 55.56. Ti: 6h. Td: 30m.
  • Heat actuator: Min on: 1m. Extra Lock Time: 5m
  • No filtering changes needed.

Past 3 Hours:


2 Likes

Great! You might want to reduce that heat Td too. I don’t think you’ll have any overshoot when heating, let alone 30 min.

If it’s working great for you, that’s all that matters.
I think you’ve been going the wrong way with Kp.
I believe both Elco and your PE buddy meant closer to 0 when they said lower Kp.