Sunday, December 8, 2013

A homebrew fermentation controller system

Fermentation is a tricky process. Not only must yeast have proper conditions in which to flourish (fermentable sugars, high oxygen levels, etc) but also must be kept within a specified temperature range. The last requirement, as well as an interest to learn more about programming, led me to develop this fermentation controller. There are commercial temperature controllers available (namely the excellent Johnson Controls A419, which I use to control the temperature of my keggerator as well as a converted chest freezer). The cost of these controllers, however, is too high to justify buying several of them. Also, building things yourself gives you a greater understanding of the principals involved. It's also more fun.

The first step in this adventure was designing the fermentation vessel itself. Homebrewers often use use 5-6 gallon glass carboys to ferment in, for their ability to provide an oxygen barrier as well as their durability and low cost compared to stainless conical fermenters. The most common method to control homebrew fermentation is to stick the carboy in a converted chest freezer and set the temperature to somewhere close to the desired range. This has several shortcomings:
  • No direct measurement of the fermenting beer temperature
  • Reliance on on air conduction through a thick glass barrier to remove heat
  • Wide temperature swings, which can slow fermentation and also produce off flavors from the yeast being stressed.

I needed to figure out a different method, so I decided to make use of  liquid conduction of heat, which is much quicker than air conduction and can also provide a heat sink to limit quick temperature swings. In essence I developed a temperature controlled bath. The carboy sits in an igloo cooler with a copper coil wrapped around it that is submersed in the bath.

Water is added until the carboy is just beginning to float. The copper pipe carries coolant that chills the water bath surrounding the carboy, which in turn chills the beer fermentating inside the carboy. Cold coolant is pumped into the top and removed from the bottom of the coil to reduce any temperature stratification that may occur. My next step was to devise a way of cooling the coolant.
Being familiar with glycol systems, I decided to build a similar system. Not having the cash to buy one, I built one using a small dorm room style fridge and a rectangular beverage cooler. The chill plate was very carefully lowed into the cooler which was filled with coolant and a small pond pump to constantly circulate the coolant, again to reduce stratification. Great care was taken in manipulating the chill plate, as a kink in the lines providing freon would reduce efficiency and a break would destroy the system's ability to cool. Even with an antifreeze mixture the system can only chill coolant to ~40 deg F, owing to it's small size and the inefficient method of heat extraction provided by the submersed chill plate. This is fine for most primary and some secondary fermentations. Lagers would most likely need a more efficient, and probably more powerful, system. Coolant is sent to the fermentation vessels (I decided on two of them, though an additional one might be possible) via submersible pond pumps.









Temperatures are monitored using the DS18b20 temperature probes, which are accurate to within 0.5 deg C (~0.9 deg F). These probes are in stainless thermowells which are inserted into the fermenting beer and the coolant.

A small relay board is used to supply power to the pumps as well as to the temperature module of the fridge.

The controller itself is an Arduino Due microcontroller. It is ARM based, and has a generous amount of RAM (96k)and flash storage space (512k). Also, there were preexisting libraries for the temperature probes, lcd screen, and ethernet/SD shield. This shield allows the controller to be connected to the internet and communicate with the computer based application. This connectivity is not required for functionality. The Ethernet shield can either be added to an existing Ethernet connection or, as was required for this project, a wireless bridge supplied by a Linksys wrt54g with DD-WRT firmware. Setting this bridge up is outside the range of this writeup, but can be read about here.
The lcd shield is a 16x2 (16 characters by 2 lines) with an array of 5 buttons as well as one reset button. The 5 directional buttons are connected via resistors to form a voltage divider. This voltage is read on an analog pin (A0 in this case), and its value identifies which button is pressed. The reset button is connected directly to the reset pin of the microprocessor.


Software


The code for the arduino controller is written in C, with some C++ libraries.
This code monitors the temperature probes every 2 seconds, stores the most recent values, activates the fridge cooling circuit and the pumps as needed, forwards the set points and relay statuses upon command to a user connected to the Ethernet shield, as well as displays those values on the lcd screen. The lcd screen has a menu system from which the user can view the current temperatures, change the desired temperatures (the set points), and change the differential for each probe (the maximum allowed temperature swing). The LCD graphics library is m2tk, and is excellent.




This code also serves up temperature values to a connected instance of the computer application, as well as receive and implement commands to set new set point values.
This code, in its entirety, is available on github at https://github.com/chchchchia


The computer application is written in java. This program connects to the fermentation controller using tcp packets, acquires the latest temperature values, issues commands to set new set points, and logs the recorded values. The most recent (up to 5 minutes worth) are graphed on the main screen using the JfreeChart library. It uses swing for the gui, and SQLite (with excellent JDBC drivers available from xerial) to log the received values. These values are logged for up to a week and graphed on demand from the main application. The application retrieves new values every 5 seconds.










Problem:
Eventual overflow of the counting system due to use of millis (which in this case is the number of milliseconds since the last reset) and limited memory. (Approx 50 days). This eventual overflow is accounted for in the code. Unfortunatly, there is no soft reset option for this microprocessor...

Future plans:
Android application
Built in calibration menu
Ability to add an arbitrary number of fermenters to the controller, as well as controllers to the entire system.
Ability to change the ip address of the controller from the menu system
Logic system that takes into account the size of the fermenter, reaction time of the system for controlling coolant flow. This will require thermodynamic calculations and some testing.
Heating option

1 comment:

  1. Hi. Glad I found your post as I'm thinking of building a similar system. Just one question, is there a great advantage to using the copper coil? Why not sink a hot return to the bottom of the chamber and let the cold supply pour in at the top?

    ReplyDelete