Temperature Overshoot, PID Control and Filtering Help - Release 02/07/2019

Hello Bob and Elco,
I’m starting a dedicated thread for this (yesterday we were discussing this on the Release Notes thread).
I’d like to start off with full disclosure that I’m not using Brewpi for brewing beer. I’m actually using it to control the temperature of our bread starter in my small bakery. Its an almost identical process, but the duration is shorter so typically I would require a batch of bread starter to be cooled from 85C and maintained at a temperature of 35-40C for a total period of 14h-16h. Not more than that, unlike beer. I hope this does not upset anyone, I love beer but I don’t brew it but I love making bread and experimenting with improving our starter quality which is super temperature dependent. So I hope I could still continue to get support :slight_smile:

With that out of the way, here’s where I’m at. I ran a 16h test yesterday to test if my fridge can hold constant temperature at 30C. Attaching the settings and graphs. My concerns are that the temperature overshoots are quite drastic and the filtering of the sensor seems a bit delayed too. Keen on hearing how to fix this to get a more stable temperature behaviour. Let me know if you need more info.

Graph: Temperature Only

Graph: All Relevant Metrics

Fridge Setting

Cool PID

Heat PID

BrewBlox is explicitly designed as more generic control software. We enjoy hearing about creative ways to use it.

It does mean some additional info may be useful. What are you using to heat/cool? (Wattage, model, and pictures are all helpful) Could you please post screenshots of the PID graph? (Spark page, select PIDs, select “show graph” in the dropdown button).

1 Like

That’s so great to hear. It’s a very cool community that I’ve come across thanks to you guys. Thank you so much!

Had to reboot my pi so I think I lost yesterday’s graph data. Will do another test today and post back here tomorrow with the other info as well.


A reboot doesn’t delete data. The data is stored on the SD card.

What do you have as a cooler, a fan?

Your heating and cooling is almost always at 100%. You should start by reducing Kp for both PIDs. Perhaps just 20% of what they are now .

Think of it like this: at 1 degree error, what percentage should the heater/cooler be on?

I have a horizontal cooler/freezer set to cooling only mode. It’s lowest temperature on this setting goes to about 8C.
For heat I have a small fan based heater meant for tiny rooms. It is 900w but I have set the PWM max to 10% duty.
Will post pics later today.

If 10% is the max duty you want, you probably want it to be 10% for a 10 degree error. That’s a Kp of 1. You currently have 20.

Okay I will try that out tonight.
Also is the value of Ti default 2h fine for my case? Since my process is of shorter duration I was wondering if that value needs to change.

The integrator should correct for steady state errors, when your lines run parallel again after a step but are not on top of each other. So it should be larger than the time it takes to respond to a step, about 4 times as large is a good ballpark figure. If the integrator grows too fast, it is doing the work of the proportional part and will cause overshoot after the step.

You can try reducing it after dialing in Kp.

Okay got it. I’ll try Kp first. Thank you Elco.

Good morning,

So last evening I ran another test with the following settngs: Cool PID Kp=2 and Heat PID Kp=1.
The result still needs tweaking. I think the cooling Kp setting is close but the Heat Kp setting seems to not be low enough. I had setup a Maximum constraint on the Heat PWM block and set that value to 10. But it seems that it is not working as expected. The graphs show that Heat PWM went as high as in the 30% range. How does the max constrain work exactly?
Another observation is that the filtered temperature remains low for a long duration, keeping the heat PWM pulsing for enough time to overheat the fridge by as much as 20-30C more than setting.
Also noting that the Fridge Cool PWM duration is at default 30m.
Please advice how to tame this down. Maybe reduce the Heat Kp even further below 1?

Here are temperature graphs at various zoom levels and my PID graphs as well.

Edit: Added a snapshot of a portion of the graph with one heat/cool cycle along with actuator pin metrics.

18h Duration

1h Duration

6h Duration

With Actuator Pin on/off, zoomed into one heat/cool cycle

PID Graphs

PID Settings

Sorry I realized my screenshot happened before the PID kicked off.

Some of this behaviour puzzles me. I’d like to have live access during a test. Would that be possible?

Right now the internet connection is not setup where the Pi setup is located. As soon as that’s fixed it’s definitely cool with me.

Meanwhile I’ve been posting from my phone and using my phone as a WiFi access point. I don’t think that would work for you?


I’m running a test right now with Heat PID Kp at 0.5 and that seems to be better. The issue still looks to me like something to do with filtering. The filter doesn’t update as quickly as the temperature changes often making it overshoot.

Also noteworthy is that there is a fan in the heater. Could this be throwing off the sensor? I have pointed the fan away from the sensor towards the corner edge of the fridge walls to hopefully dampen and baffle the fan air but maybe I should completely disconnect the fan? But then there would be an issue with non uniform distribution of heat. Just wondering.

I doubt the heater is allowed to run without a fan. Looks like it would overheat. I noticed that your filters don’t respond fast enough, then the bypass threshold is triggered and this is repeated over and over. That is what causes the blocky PID input. So you should increase the threshold and probably choose a faster filter.

1 Like

Yes I had mentioned this behavior in the previous post. Right now the filter setting is at 2degC threshold and 3minute duration. What would you recommend I set it to?

Start with 30s and 5deg. Do you see the unfiltered value disconnecting sometimes? It seems to take much longer than 3 minutes.

Is the heater toggled with an SSR so it switched on an AC zero crossing?

Okay I will give that a shot today. Thank you Elco

Also just curious, what’s the expected response time between the spark service and web interface? It usually takes about 1minute for some changes to apply and some changes need repeated clicks to go through.

Also curious if the max and min constraints on a PWM actually work? It seems like it is being ignored in my case.

I’ll test that. It’s supposed to respond instantly. Did you update to yesterday’s hotfix release?