KEGBOT! O.M.F.G.
KEGBOT! O.M.F.G.
I built a Kegbot
Sunday, November 1, 2009
Inspired by kegbot.org’s RFID web-enabled kegerator, I built my own version based on the arduino.
First I built a three tap kegerator using a Sanyo SR-4912M (4.9 ft3), and a three-tap draft tower. In case you’re wondering how I fit three kegs into a 4.9 cubic foot fridge, the third keg is a 2-gallon taylor ice-cream keg which has been adapted (1/8 37º flare to 1/4 MPT) to use standard beer fittings.



The kegerator also accepts a standard CO2 fitting, which makes removing the CO2 line for charging quite easy.



•display remaining beer in each keg
•measure CO2 tank level
•check temperature of refrigerator & draft-tower
•measure temperature of the draft tower
•turn on & off refrigerator compressor
•display status on a graphic LCD
•wirelessly communicate to a PC (my mac) via XBEE radio
•wirelessly reprogrammable firmware
HOW IT WORKS
I. KEG-SENSE PAD VOLTAGE-DIVIDER CIRCUIT
Each keg sits on a “keg-sense pad,” load-distributing disk, underwhich a force-sense resistor (FSR) is taped to a felt furniture pad. (The same setup is used to measure CO2).

To get started, I ordered (2) 100-lb tekscan flexi-force FSRs and used them in parallel to make the sensor less sensitive to the placement of the corny keg on the keg-sense pad.

They are wired in parallel so the total resistance:
R = RFSR-1 * RFSR-2 / (RFSR-1 + RFSR-2).
The arduino applies +5V to the FSR circuit, which is wired through a 1MΩ trim-pot voltage divider.
VOUT = VIN * R / (RTRIM + R)
This method has several down-sides. The first and foremost is the low resolution of this circuit resulting from the small dynamic voltage range of 1.7V to 3.9V (2.2V range). Secondly, it is the conductance and not the resistance of flexiforce sensors that positively correlated with force. Because of this, the resistance vs force is non linear. In other words:
GFSR = K * tekscan(F), therefore
1/RFSR = K * tekscan(F),
where G is conductance, F is force on the sensor, and K is some constant.
II. INVERTING OPERATIONAL-AMPLIFIER CIRCUIT
Later I switched to a better (cheaper) design that uses only one 25# FSR per keg-sense pad, and a MCP6004 rail-to-rail operational amplifier. The 25-lb sensors are more suitable because the arrangement of the felt pads causes each felt pad to experience approximately one-third of the weight. A full 5-gallon corny keg weighs 58 pounds (58/3=19.3 lbs).

VOUT = -VIN * (RF / RFSR)
This a cool trick, note that the output voltage is proportional to the inverse of RFSR. Another way to put this is, that VOUT is proportional to the FSR conductance (G) and therefore to force. Recall that:
1/RFSR = GFSR = K * tekscan(F), so
VOUT = -VIN * RF * GFSR, and finally
VOUT = -VIN * RF * K * tekscan(F)
You’ll notice that this circuit requires negative 5 volts through the FSR. There are many ways to achieve this, the easiest for me was to buy a multiple output power-supply. I found one for $20 at “HALTED” which looks a bit like a “wall-wart” that outputs +12V, +5, & -5V. Switching to this higher quality shielded & choked power-supply resulted in a huge reduction of noise in the analog sensors.
III. CALIBRATION CURVE
To calibrate, I placed an empty keg on a pad and repeatedly added a half-gallon of water and took measurements using a voltmeter. I used a 40 kΩ resistor for RF. Note: arduino analog input ADC value = 1024 / 5V.

Calibration measurements yielded this relation:
%full = 20 * (ValueADC - 177) / 142
Because this is so linear, using the map() function from the minimum to maximum value works fittingly.
Later I learned that the flexiforce reading depends on temperature. The better controlled the temperature is the more accurate the reading, plus you must also account for hysteresis. The best way to calibrate is in the fridge at the proper temperature, and allowing 10+ minutes for the sensor to settle between readings.
IV. TEMPERATURE SENSOR
Temperature sensing is done with the Analog Devices TMP36. It’s quite simple and returns a voltage linearly related to the temperature in degrees C.
(VOUT - 0.5V) * (100 ºC / V) = Temperature
I soldered them to the very end of a long ethernet cable which is inside the fridge. To deal with the long cable’s capacitance (which can effect measurements), I soldered two components directly to the TMP36 IC leads:

The final assembly is wrapped in electrical tape then shrink wrapped to keep out any condensation.
I soldered one IC badly (see image to the left), this offset the readings by +1.464ºC, which is corrected in the arduino firmware. (I calibrated using a frozen banana). The other TMP36 IC seemed unaffected.

This display is a 128x64 monochrome LCD based on the KS0108 chipset from adafruit-store. Interfacing this device was pretty straight forward except that the contrast was too bright, and insensitive to adjusting the 10kΩ trimpot. I replaced this trimpot with a 1MΩ trimpot and now the display is readable.
WIRING
Category-5 ethernet cable connects each sensor to a DB25 female solder cup in a project box outside the fridge (hidden in back). From there a DB25 M-M cable connects the breakout-box to the kegbot PCB & µcontroller. The DB25 cable “breaks-out” many unused arduino IO pins to get them close to the refrigerator for any future improvements. This way, for the next version, I can use the same PCB and not mess with wiring inside the case.



The relay board used is the sparkfun version. It simplifies the final kegshield design by keeping all the support & protection electronics near the relay. This relay is hidden inside the thermostat box.
SCHEMATIC
This schematic has main four parts
1. The basic structure for an arduino “shield” which is based on molex-type female headers (extra-long pin type)
2. Many IO pins are “broken-out” to the DB25 cable connector
a. FSRs are connected to trimpot voltage dividers
3. The graphical LCD display connector wiring for parallel IO
4.Ladyada design wireless reprogramming which uses the adafruit XBEE board




CASE / MOUNT

FINAL RESULT
SURPRISES
Arduino IDE version 17 has a bug that disables analog inputs 8-15 of the arduino mega board. A temporary fix can be found here. Noise is real! The FSR signals bounced around by 60% of the mean DC value when using an unshielded wall-wart. I used an RC filter with various capacitors to fix this at first, but settled on using software smoothing because its easier to change. Therefore, my next revision will have a ground plane and shielded signal cables.
My “keg-sense pads” use felt furniture pads to distribute the load onto the FSRs. These absorb water (and beer). Water destroys those tekscan sensors. So a beer spill would get pulled up from the floor onto the sensor thru the pad! Using just one FSR works (instead of two), but the accuracy depends greatly on how centered the keg is on the pad.
I also switched to the max6675 ic and type-k thermocouples. This breakout board simplifies things.
CONCLUSION
In summary, this has been a great project. The FSRs work proficiently in their current configuration using an op-amp. However with an unshielded power-supply & a voltage divider setup, they could only reliability sense between empty & full in quarter-keg increments. Unfortunately with all the noise and nonlinear response, the sensors weren’t very accurate. Using an op-amp to condition the signal to 0-5V instead of using voltage dividers made a huge difference. The accuracy is no longer dominated by noise, but limited by the drift of the sensors, and the placement of the keg on the pads. They drift at maximum about 480mV from the actual value (about 10%). Using two sensors and averaging the input could reduce the total drift error.
I’ve tried to include everything needed to repeat this project and make it better! If you come up with anything please email me a link!
VERSION 2.0 PLANS:
•case
•kegpads that don’t absorb water (w/ connectors)
•op-amp circuit for FSRs & shielded cable
•door-open sensor
•µC controlled fan blowing into tower
•modular design
FILES
eagle files & library (v1.0)
arduino code (v1.0)
laser cutting DXF
RESOURCES
WEBSITES
FSR tutorial (ladyada)
TMP36 tutorial (ladyada)
TMP36 water proofing (instructables)
GLCD (arduino playground)
BOOKS
Making things talk - Tom Igoe
Physical Computing - Tom Igoe
Getting Started in Electronics - Forrest M. Mims III
"Without question, the greatest invention in the history of mankind is beer. Oh, I grant you that the wheel was also a fine invention, but the wheel does not go nearly as well with pizza."
-Dave Barry