Need simple reliable algorithm for controlling a refrigerator

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

eimar

Brasserie Montfort No NEIPA brewed here
Joined
Oct 11, 2009
Messages
160
Reaction score
128
Location
Montreal, Canada Eh
The sensor is a onewire DS18B20 , in a thermowell , connected to an ESP32
1) what is a good sampling rate: every 10 seconds ?
2) How long should the compressor stay off before being turned on again ?
3) Should I average several temperatures readings so the system won't turn on-off constantly ?
4) The temperature will vary between a setpoint and setpoint-delta . What is an acceptable value for delta ? 2 degrees celsius ?
My plan for the next step will be to use a PID algorithm ( right now I'm learning about the subject )
Jacques
 
All my answers somewhat depend on your batch size. The larger the batch the slower the temp swings due to thermal mass.
  1. Sampling every 10 seconds would be way too small an interval for controlling fermentors.
    Not quite sure on the power an ESP32 provides, but generally you don't want to tax these small micro-controllers too much.
    I would think once a minute would be sufficient, and is what I use.
    Your wort temp is not going to change that much.

  2. My default delay is 9 minutes and I haven't blown up any fridges.

  3. (and 4)
    You'd want some swing temperatures either side of the actual target temp.
    +/- 0.5 degrees or perhaps 1 degree depending on how pedantic you want to be. :D
    I'm not sure if you have been monitoring temps in wort (inside thermowell) but they really don't change too much
I suppose you could implement PID for your fermentor control, but unless your cooling system way overpowers your fermentor volumes and you end up with massive under-temperatures, I wouldn't bother with the complexity personally.

A simple system with target temperature, delta's to turn fridge on/off and a compressor delay to avoid turning on too much. Job done, relax and have a beer.

Have a look at my latest ferment. Plastic fermentor inside a fridge. It run's fine with 0.25 degree delta, and fridge doesn't turn on much.
It is winter here in Brisbane so not much ambient temp swing. That will be a much different story in summer in January.

upload_2019-9-4_1-10-5.png
 
Seems the point is the OP desires to write his own control program rather than adopt someone else's and wants to start off on solid ground.
I'm good with that.

As for the questions:

1 - sure, 10 second sampling is fine, the question really is how the system reacts.
2 - I like 10 minute short-cycle delays. It's probably more than necessary but unless it impacts control loops, why not?
3 - I'm not sure averaging is the way to go, but I would be aware of what to expect when a ds18b20 read fails and dump the typically resulting 85°C/185°F reading.
4 - My keezer runs on a 2°F differential and only cycles 4 to 6 times in 24 hours. My three ferm chambers are all running BrewPi which uses a might tighter differential (quasi-PID optimization) and cycle much more often when fermentations are rocking...

Cheers!
 
Last edited:
read fails and dump the typically resulting 85°C/185°F reading.

i'd say something like, if(x >= 5 && y == 65 && t == 10)sensorfd(bluetoothalertomega(hurryhome));

my programming skills are getting slugish though....

edit:
 
Last edited:
Nice, I'm wondering whether I dive into C programming and ESP32 to develop a stand-alone fermentation control device which integrates with my website Brewers Chronicle.

Or just go with Raspberry Pi and Windows IOT Core to stay nice and comfortable in my MS sandbox. :)
 
I didn<t know about Windows IOT. Interesting. Microsoft too want a piece of the IOT pie.
 
Given their half-hearted efforts to date I really don't think MS is all that interested in Iot stuff.

Besides, when it comes to device control - and hardiness in the face of standard end user environmental stuff - the lighter the OS the better, imo - to the point of getting rid of it entirely and going straight state machine, like an UNO or ESP...

Cheers!
 
Umm, yep, they certainly give the impression of not fully committing to IoT.

There's a whole bunch of Windows UWA classes missing from the Windows IoT implementation .

And Raspberry Pi 3 B+ is still "unsupported" for Windows IoT (it works though), and still no release date for Raspberry Pi 4 support.

But given that I have a whole bunch of experience in Windows .Net programming, Visual Studio tying in so nicely for debugging purposes, and my complete lack of time to learn a new language to programme arduino's, ESP32, etc, it is still an attractive choice for me.
 
I use a red lion HMI with relay modules on the back...no need to learn any programming if you don’t have time. It’s straight forward tag manipulation from your sensor inputs. They’re pricey but super easy to use.
 
My plan for the next step will be to use a PID algorithm ( right now I'm learning about the subject )

A PID algorithm is useles for driving a fridge that cannot be rapidly cycled on and off without frying the compressor. If you were to switch to a glycol chiller than you could conceivably drive the glycol pump with a relatively short cycle without risking the premature demise of any component but personally I've always found an on/off control with a very small delta (0.1°C) to be more than adequate and never felt the need to switch to PID mode.
 
A PID algorithm is useles for driving a fridge that cannot be rapidly cycled on and off without frying the compressor. If you were to switch to a glycol chiller than you could conceivably drive the glycol pump with a relatively short cycle without risking the premature demise of any component but personally I've always found an on/off control with a very small delta (0.1°C) to be more than adequate and never felt the need to switch to PID mode.

IMG_0515.JPG
Like I said above, I use an HMI to control my fridge...anyways, I use an insulated 5gal carboy, and my cycle times are about 40 to 50 minutes with a 1°F hysteresis. I suppose those times aren’t terrible...the referenced picture is just a test program running. Not a batch. But when it wasn’t insulated, I believe the cycles were down to 5 minutes. Definitely able to burn a compressor up at that rate. At least I have before.
 
Back
Top