Kegboard
From KegbotWiki
The Kegboard is a special-purpose circuit built to control and monitor a kegerator. It consists of two relays and a PIC microcontroller, a few inputs for sensors, and a computer interface. It is designed to:
- Control two AC outlets (one connected to a freezer and one connected to a solenoid valve, in the typical case)
- Monitor a temperature sensor
- Monitor a flow sensor
This page describes some of the details of the current kegboard's design, and ideas for revisions.
Contents |
Current Design Details
- Microcontroller
- Kegboard 1.0 uses a Microchip PIC16f628 microcontroller. Main features for this chip are: onboard USART, plenty of GPIOs, cheap, easy to program, onboard oscillator, plenty of ways to flash. Interface with the host computer simply involves connecting a MAX232 to the TX/RX pins. Alternately, a module containing a FTDI USB-Serial chip can be plugged in for 'free' USB support.
- Relays
- Currently using two normally closed, non-latching relays rated for 10A @ 240VAC. Most fridge compressors should fall quite comfortably within this spec.
- Flowmeter
- A hall effect sensor flow meter is connected to an interrupt pin on the microcontroller. The microcontroller maintains a 2 byte wide counter of pulses.
Schematic
At right is an image of the most current Kegboard schematic. Version history below:
- v1.01 - 08/03/2005 - part n/a
- Fix(schemo): FTDI LED orientation
- Fix(layout): Relay coil trace width
- Fix(layout): Relay coil trace placement
- v1.00 - 07/26/2005 - part kb-002
- First PCB design
- Single relay type for both switches (JS1a)
- v0.10 - 10/01/2003 - part n/a
- Breadboard version
- Not widely produced :)
Parts List and Cost
Note: the following table is incomplete as of this revision. Discrete components (resistors, etc) are omitted for the time being. Please also see the Revision Plans section following this.
| Name | Part | Description | PN (Digikey unless noted) | Approx. Cost |
|---|---|---|---|---|
| IC1 | PIC16f648A | Microcontroller | PIC16F648A-I/P-ND | $3.63 |
| IC2 | MAX232 | RS232 Level Convertor | 296-1402-5-ND | $0.90 |
| RELAY1 | JS1a-5v | AC/DC Power Relay | 255-1106-ND | $1.15 |
| RELAY2 | JS1a-5v | AC/DC Power Relay | 255-1106-ND | $1.15 |
| U1 | FTDI232BM | USB-Serial Adapter (optional) | 626-DLP-USB232M (Mouser PN) | $25.00 |
Controller Interface Spec
The microcontroller presents a serial interface to the world. The Kegboard plugs in to a serial port and speaks at 115200bps. An old version of the firmware, written in JAL, is available here: Kegboard.jal.txt
Commands
You can say the following things the the kegboard, each by writing the specified character:
- CMD_STATUS = 0x81
- Tell the microcontroller to send a status packed (described below)
- CMD_VALVEON = 0x83
- Enable the solenoid valve (RELAY1)
- CMD_VALVEOFF = 0x84
- Disable the solenoid valve (RELAY1)
- CMD_FRIDGEON = 0x90
- Enable the freezer relay (RELAY2)
- CMD_FRIDGEOFF = 0x91
- Disable the freezer relay (RELAY2)
Reading the thermostat is not included in the current Kegboard.jal.txt but is mostly there. Matt S. also has a pure PIC ASM firmware that handles 1-wire reads of a ds1820.
Status Packet
The kegboard defines a single message, the status packet, which is returned under either of the following circumstances:
- When it is requested with CMD_STATUS
- Following any other command
(Yes, this means that CMD_STATUS is a NOOP!)
The following is the format of the status packet:
| BYTE | BYTE | BYTE | BYTE | BYTE | BYTE | BYTE | BYTE |
|---|---|---|---|---|---|---|---|
| 'M' | ':' | fridge status | valve status | flow high | flow low | '\r' | '\n' |
Revision Plans
- Kegboard 1.1
- Replace the 16f6XX series PIC with an 18 series PIC that includes an onboard USB USART. (The DLP module should no longer be necessary; it was a kludge to support the older RS232-only PICs. Works nice, but way too expensive, and I'm not surface mounting the 232BM..)
- Remove legacy MAX232 altogether (in conjunction with previous)
- Modify power relays by adding two more pads so that the relays don't necessarily have to share the same source.
- Possibly unite FLOW and THERMO connectors in to one 4-pin header, eliminating the redundant VCC/GND lines (but possibly reducing flexibility?)
- Future
- Investigate an alternate uC (eg AVR)
- Use or support the Digi Connect ME as the controller itself or as an ethernet-to-serial interface
