Thursday, March 20, 2014

Automated Home Brewing

Brewing Controller User Interface
I have been a “home brewer” in the electronic hobbyist sense for decades, but I am also a “home brewer” of beer.  I mentioned this in my post on Reading Temperature With Thermistors.

I now use digital temperature sensors (typically the DS18B20) read over an I2C bus.  Adafruit has a good tutorial on how this is done located at http://learn.adafruit.com/adafruits-raspberry-pi-lesson-11-ds18b20-temperature-sensing/overview

It is fairly common to control a refrigerator and heater to keep a constant (or slowly changing) temperature during the fermenting process, especially with lagers.  I have done this using the Raspberry Pi, thermistors, and an A/D convertor.  Now, I decided to get a lot more ambitious.

I won’t go into all the details of the brewing process since there are many resources on the web to provide that.  For a quick look at this process, see the article on my photo blog.  I wanted to be able to control at least the following items for one of the simpler methods of brewing (called partial mash.) 


  • Valve to a tank of propane
  • Grill ignitor to light the burner
  • Sensor to detect if the burner actually did light
  • Temperature sensor for the wort (the brew of water, malt extract, and hops)
  • Pump for circulating water through the wort chiller

What I needed to do this:

  • A relay to output 12V to control the propane valve
  • Another relay to output much higher amperage of 12V to run the pump
  • A relay connected in place of the button on the grill ignitor
  • A connection for one or more DS18B20 temperature sensors

The hardware is described below.  I also wrote software for the Raspberry Pi (in C, my language of choice) to manage this hardware and the brewing logic.  C# .Net provides the user interface on a Windows laptop. That is the image at the top of this post. The laptop and the Pi communicate via socket calls over wifi.

There were three major problems that had to be overcome once I started testing.  One is that I tried using a DS18B20 to detect the flame.  Well, the maximum for that sensor is 125°C and I did not use a high temperature version.  The flame is VERY hot (duh!) and the sensor eventually melted, shorting 5V to ground and shutting down the Pi.  Fortunately it was not damaged.  I doubt changing to a high temperature version will help, but I will try that next.  Another option is to do what every furnace, stove, and hot water heater does for its pilot light – use a thermocouple to detect the heat.  I may have to investigate this to see if I can devise a simple interface for one.

The second problem was that the wiring for the ignitor kept shorting out and creating a spark too far from the flame to light it.  Additional insulation and a change in how it was mounted solved this problem.

The third problem was that the EMI created by the ignitor caused massive interference on the I2C bus that made it unusable.  This was corrected by re-wiring my temperature probes with well shielded cables.  I used shielded audio cables commonly used for microphones.  I am also a musician so I had some of this already.  If you have to buy a small reel you may find that it is rather expensive.  Cat-5 cable may also work well.  That is what I use for my hot tub controller, but it is not subjected to the massive EMI of this system.

I disabled the flame detection logic. This is a critical safety feature and must be corrected for this system to be trusted.  However, this did allow me to successfully use this system to brew.

This is a good place to state that working with flammable gas and boiling liquids can be hazardous.  I take no responsibility for your use of the advice provided in this post.  BE CAREFUL!  And drink responsibly.

Hardware

Control of all of the above components is pretty straight-forward.  Search my blog or the web and you will find how to control relays.  The Adafruit link above will show you how to connect the I2C temperature sensors.

I used audio connectors since they are cheap and readily available.  ¼ inch mono for the relays and stereo for the I2C bus.  Using an audio connector for the I2C bus gives the added benefit of being able to use pre-made splitters and extension cables and these tend to be well shielded and relatively inexpensive.


The 5V line from the GPIO connection is only used for the I2C bus.  I already required 12V (which is actually 13.8V) for the valve and pump.  However, the relays I used were controlled with 5V.  This voltage does not need to be accurate, so I made a simple voltage divider using three 100 resistors.  Two 100 resistors are used for R1 and one 100 resistor is used for R2.  This divides the input voltage by 3 to provide 4.6V, which is adequate to control the relays.





The final interface box looks like this. The red and black power connector you see is called an Anderson Power Pole.  I chose to use this since I already have 12V supplies for my HAM radio equipment.  (I think maybe I have too many hobbies.)





Modified Grill Ignitor

The ignitor can be found in many hardware stores as a replacement for repairing gas grills.  The cheaper versions of these use a spring and a piezoelectric voltage generator to create the spark.  These are not suitable for this application.  You must get the more expensive type that uses a battery.  I removed the push button and made my own connection that runs to the relay in the interface box.

I still have a few kinks to work out in this system, but I am sure that this automation will make the process of brewing much easier and more consistent.  This is definitely the most enjoyable project that I have done so far with the Raspberry Pi, and that is not just because I end up with great beer.

The system set up for brewing

The temperature sensor is a water-proof high temperature DS18B20 covered in food grade shrink tubing.  These are available at Adafruit.com







Here, the system is set up for chilling the wort.  
The cooler has water and 10 pounds of ice cubes.

Sunday, March 16, 2014

Stupid Simple Tip #4

Murphy was an optimist. I have repeatedly had problems with USB cables.  USB cables are held in place only by the friction of the connector.  Repeated insertions and removals WILL wear out a USB connector.  Anyone with an old laptop has probably encountered this problem.

Another problem is in systems that get moved around a lot or are subjected to a lot of vibrations.  Here is what I did to eliminate this problem in a recent project.  Zip ties are wonderfully useful.



Thursday, March 6, 2014

Server Box with Utilization Displays

A while back I built a server with the system root moved to an external hard drive.
Blog Post - Running From an External Hard Drive

That system has now failed. I shouldn't be surprised since it was built with very used parts. I decided to rebuild it and put it into a nice enclosure this time, rather than just having parts all stuck together. I also decided to add LED bar graphs to show CPU and I/O utilization.



The first step was to build the LED interface. This was accomplished using two 10-segment LED bar graphs and a GPIO extender. The GPIO extender is needed in order to drive all 20 LEDs. I used a MCP23017 I2C GPIO extender which provides 16 GPIO bits. Another 4 GPIO bits were taken directly from the Raspberry Pi.

The LED board is shown here before the GPIO lines were attached.



The next step was to attached the LED board and a Raspberry Pi to the top of the case.  The LED board is attached using epoxy with the LEDs showing through holes cut in the plastic case.  The Pi is attached using
plastic offsets and machine screws.

Notice that the analog video output connector has been removed from the Pi.  The case was just a little to tight a fit for it to work with that in the way.

A power connector will supply 5V to the LED board and to the USB hub and will use the power supply that was included with the hub.  The Pi is powered through the GPIO pins.

A hard drive salvaged from an old laptop is placed in the bottom of the case.  It is connected using an IDE to
USB adapter.  The USB cable is fed out of the case and then back in to the USB hub.  This part is a little odd, but is the only way I could get it to fit in a case this small.







Here, the power connector has been  mounted, the USB hub has been added, and all other connections have been made.  It's time to squeeze it all inside this plastic enclosure.












Here are a couple of pictures of the completed server.


















Below is a video which shows how the utilization LEDs look in action.


Thursday, February 20, 2014

Stepper Motors

Stepper motors are unlike ordinary motors.  A simple motor will spin when current is applied to the coils.  Reverse the polarity of the current, and the motor spins in the opposite direction.  Stepper motors, however, contain multiple coils which can be energized individually to provide precise "stepping" of the motor.

This precise control makes them perfect for a variety of applications.  They are commonly used in floppy drives, hard drives and CD/DVD drives to precisely control the speed that the disc turns as well as where the read/write heads are positioned.  They are also used in scanners to position the scanning optics and in ink jet printers to move the paper and position the print head.  Any application that requires precise positioning is likely to use stepper motors.

For more details on the many varieties of stepper motors, see the following pages:

http://en.wikipedia.org/wiki/Stepper_motor

http://www.engineersgarage.com/articles/stepper-motors

Quick Start for Beginners - http://www.freescale.com/files/microcontrollers/doc/app_note/AN2974.pdf

Stepper Motor Basics - http://www.solarbotics.net/library/pdflib/pdf/motorbas.pdf

There are two basic methods for controlling a stepper motor.  One is to use an IC specifically designed as a stepper motor controller.  The other option is to use a microprocessor (the Raspberry Pi, in this case) to directly control the individual coils of the stepper motor.  This is the method that I demonstrate in the following video.




The code for the program used in this demo follows.


Wednesday, February 19, 2014

Stupid Simple Tip #3

The ribbon cable connector used for floppy disk drives on PCs can be used as a GPIO connector.


They are larger than than the Pi GPIO connector (34 vs 26 pins) so they overlap some.  These are cheap (free if you have old PCs to scavenge from.)  One problem - they won't fit in a case made for the Pi, but I have used them in cases that I built that held the Pi as well as other hardware.  If you do use this cheapskate trick, I recommend trimming the unused lines from the ribbon cable to prevent confusion.  It is also a good idea to plug the unused holes on the connector so that you don't accidentally plug it in wrong.

Monday, February 17, 2014

Stupid Simple Tip #2

The body of an old ball point pen can be easily made into a standoff of any size.  And it's hard to beat the price.


Stupid Simple Tip #1

A rubber band and a pair of pliers make an quick and easy clamp for holding components while soldering.