Kegconnection Complete Starter Kit and More Giveaway!


Home Brew Forums > Home Brewing Beer > Automated Brewing Forum > Raspberry Pi Brew Controller

Reply
 
LinkBack Thread Tools
Old 01-02-2014, 06:15 PM   #1
tob77
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2012
Location: Napa, CA
Posts: 62
Liked 6 Times on 4 Posts
Likes Given: 16

Default Raspberry Pi Brew Controller

I have recently retrofitted the controls of my old rusty brew rig that I put together back in 2002. I am now using a Raspberry Pi to control my propane BIAB rig. The gpio on the rpi is used to monitor the temperature via a DS18B20 probe and control the burner output via a servo motor attached to the propane regulator valve. The main program is written in python and uses WebPy to serve up the html5 interface. I designed the interface to be optimized for my phone and tablet. It works on my laptop too, but it doesn't auto scale for different screen sizes. At this time, the program controls the temperature during the mash including provisions for multi step mashes, as well as timers for both the mash and boil. I also added some logic to assist chilling including temperature and timer setpoints for hop stands. All temperature and timer setpoints can be configured using the html interface. My rpi program was written around my specific hardware and is not that flexible with other hardware configurations. However, I tried to write the code in a modular manner, so it can probably be tweaked to work with other configurations with a bit of work.

I am by no means a programming expert. In fact, this has been my first time programming with python, html, and javascript. As a result, I have employed the use of some dirty hackery (especially in the javascript), and borrowed heavily from all over the web. Here are some of the main sources that I used throughout my programming:

Python Code Structure - steve71's RasPiBrew python code was used extensively for the early development.
https://github.com/steve71/RasPiBrew

Servo Motor Control - richardghirst's servo blaster software is used to operate the servo motor.
https://github.com/richardghirst/PiB...r/ServoBlaster

16x2 LCD - Adafruit's python LCD code is used to update the lcd using gpio.
https://github.com/adafruit/Adafruit...afruit_CharLCD

DS18B20 Temperature Sensor - Adafruit's python DS18B20 code is used to monitor the temperature sensor.
http://learn.adafruit.com/adafruits-...nsing/overview

HTML5 Widgets - The JMWidgets library was used extensively to develop the html interface.
http://www.jmwidgets.com/

All of my source code can be found here:
https://github.com/tob77/BrewNpi






__________________
tob77 is offline
3
People Like This 
Reply With Quote Quick reply to this message
Old 01-02-2014, 06:44 PM   #2
helibrewer
HBT_SUPPORTER.png
Feedback Score: 1 reviews
 
helibrewer's Avatar
Recipes 
 
Join Date: Nov 2011
Location: Santa Rosa, CA
Posts: 3,073
Liked 173 Times on 157 Posts
Likes Given: 39

Default

Nicely done neighboor!!

__________________
Something is always fermenting....
"It's Bahl Hornin'"

Primary:
Brite Tank/Lagering:
Kegged: Hefeweizen, Chocolate Hazelnut Porter, Kumquat Saison, Tart Cherry Cider, Belgian Tripel, Maibock Bock, Ommegang Abbey Ale Clone, Belgian Golden Strong, German Pils (WLP830)
Bottled: Belgian Quad (Grand Reserve), Derangement (Belgian Dark Strong)
On Deck:
My Site: www.restlesscellars.com
helibrewer is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 03:39 AM   #3
craigmw
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2012
Location: Villa Park, CA
Posts: 138
Liked 15 Times on 12 Posts
Likes Given: 4

Default

Tob... This looks great! Pretty much what I want to do to automate my Blichmann burner to accomplish better control over my BIAB mash temps. I have a couple of questions...

1. How do you control ignition? I would imagine that the burner may need to turn down so low as to turn off the gas flow to the point where it would need to be reignited. How is this accomplished? I'd really like the ability to "set and forget" temp control during the mash, but this would need there to be some way to control ignition when the temp was near or exceeded the target temp. Turning the burner back on would require either a pilot light or some sort of igniter if I didn't want to babysit the burner during the mash. I retrofitted my Blichmann burner with a BBQ spark igniter that I could use for refiring the burner (along with a relay and some logic for this), but I am wondering about your thinking along these lines.

2. Does your program allow for control of burner output during boiling?

3. How linear does the output of the gas valve vs. heat output need to be in order for the PID loop to work? It would seem that this could be an issue, but your results suggest that your PID tuning is giving quite a reasonable level of precision without overshooting the target mash temp.

4. What are you using for a servo? I would imagine you need a pretty hefty servo, and one that can rotate more than 180 degrees.

Overall, a great build! Thanks for the info and for uploading your code. This should be fodder for some interesting experiments.

__________________
craigmw is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 03:47 AM   #4
craigmw
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2012
Location: Villa Park, CA
Posts: 138
Liked 15 Times on 12 Posts
Likes Given: 4

Default

Tob... another question if you don't mind. How is the volume in the mash affecting the PID tuning? In my current setup, I use a DTC temp monitor (DTQ450Q) to track the temp, and find that this is too slow to be effective. For example, if I have a 152 mash temp and the current temp drops to 149, turning the burner back on leads to a considerable lag before I see a temp increase. I usually recirculate the mash, and while this should in theory lead to better heat distribution, I still have a strong likelihood to overshoot the target temp. This has led to a couple of times where the mash temp was considerably over the desired target, and has resulted in reduced attenuation during fermentation, an issue I've concluded was due to denaturing the alpha and beta amylases. How does your system give such tight control over mash temp, and is this impacted if you do a larger mash volume?

__________________
craigmw is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 04:09 AM   #5
craigmw
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2012
Location: Villa Park, CA
Posts: 138
Liked 15 Times on 12 Posts
Likes Given: 4

Default

Okay.. one last question (for now):

Do you have a schematic or some info regarding the GPIO pin assignments or schematic to show how you wired all of this up? I have been very much considering eBIAB, but love the portability of propane. Plus, I really don't want to cut another hole in my nice 20g kettle, so this would be the perfect option. Your efforts could be really helpful to many of us! Thanks for all of the great work and inspiration.

__________________
craigmw is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 07:22 AM   #6
tob77
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2012
Location: Napa, CA
Posts: 62
Liked 6 Times on 4 Posts
Likes Given: 16

Default

Quote:
Originally Posted by craigmw View Post
1. How do you control ignition? I would imagine that the burner may need to turn down so low as to turn off the gas flow to the point where it would need to be reignited. How is this accomplished? I'd really like the ability to "set and forget" temp control during the mash, but this would need there to be some way to control ignition when the temp was near or exceeded the target temp. Turning the burner back on would require either a pilot light or some sort of igniter if I didn't want to babysit the burner during the mash. I retrofitted my Blichmann burner with a BBQ spark igniter that I could use for refiring the burner (along with a relay and some logic for this), but I am wondering about your thinking along these lines.
I am using a spark module from a gas range for ignition. The spark module is energized by a relay that is linked to the rpi gpio. I do not have a thermocouple on the burner right now so the rpi has no way of knowing if the flame goes out. My burner makes an audible pop whenever the flame goes out so I know when I need to hit the manual ignition button. I always stay in earshot while brewing just in case it goes out. I have programmed an adjustable minimum burner setting that I set each brew day according to the wind to prevent the burner from going out on me and I have an automatic burner shutoff temperature setpoint to automatically turn off and on the burner if it gets too far above the PID setpoint. This has worked out good so far. The burner stays lit and maintains temperature within +-0.4 deg F (depending on the wind) as long as I leave the lid off my keggle during the mash.

Quote:
Originally Posted by craigmw View Post
2. Does your program allow for control of burner output during boiling?
Yes, I have a setpoint that allows me to set the burner output during the boil. However, it is static and doesn't automatically change.

Quote:
Originally Posted by craigmw View Post
3. How linear does the output of the gas valve vs. heat output need to be in order for the PID loop to work? It would seem that this could be an issue, but your results suggest that your PID tuning is giving quite a reasonable level of precision without overshooting the target mash temp.
I think this is an important detail because the output of the gas valve is not linear at all. My solution was to linearize the valve output by recording the rate of change of the temperature as it increased past 120 deg F for multiple tests throughout the span of the valve. The output to the valve is then adjusted according to the linearization data so that it appears linear to the PID.

Quote:
Originally Posted by craigmw View Post
4. What are you using for a servo? I would imagine you need a pretty hefty servo, and one that can rotate more than 180 degrees.
I am using a HiTec HS-645MG servo. The servo only travels 180 degrees but that's all I need for my valve. There are some servos that can travel up to 3.5 turns. Take a look at jrubins thread for more info and to see where I originally got my inspiration for the servo from: http://www.homebrewtalk.com/f235/any...ropane-380624/

Quote:
Originally Posted by craigmw View Post
Tob... another question if you don't mind. How is the volume in the mash affecting the PID tuning? In my current setup, I use a DTC temp monitor (DTQ450Q) to track the temp, and find that this is too slow to be effective. For example, if I have a 152 mash temp and the current temp drops to 149, turning the burner back on leads to a considerable lag before I see a temp increase. I usually recirculate the mash, and while this should in theory lead to better heat distribution, I still have a strong likelihood to overshoot the target temp. This has led to a couple of times where the mash temp was considerably over the desired target, and has resulted in reduced attenuation during fermentation, an issue I've concluded was due to denaturing the alpha and beta amylases. How does your system give such tight control over mash temp, and is this impacted if you do a larger mash volume?
My recirc pump pulls from under a small false bottom so it is always moving the hottest wort from the bottom to the top. The chance of overshooting is minimized because the PID is always looking at the hottest wort. The lag is fairly short because the temperature doesn't necessarily reflect the entire kettle, only the hottest part. The wort returning from the recirc pump seems to be about 1 degree hotter than the wort at the top of the kettle so there is a little temperature gradient from the top to middle to bottom. I'm sure a bigger pump or a motorized mixer might help minimize this but I'm not sweating it for now. I haven't played with different sized mash volumes so I can't comment on that one but I don't anticipate any big issues.


Quote:
Originally Posted by craigmw View Post
Okay.. one last question (for now):

Do you have a schematic or some info regarding the GPIO pin assignments or schematic to show how you wired all of this up?
I don't have a schematic but the gpio pin assignments are detailed in the begining of the main python program (brewNpi.py). I am using a 3.3v to 5v level shifter to connect the rpi's gpio with a 5v relay board.
http://www.adafruit.com/products/735
http://www.amazon.com/Kootek-Channel...ds=relay+board

Quote:
Originally Posted by craigmw View Post
I have been very much considering eBIAB, but love the portability of propane. Plus, I really don't want to cut another hole in my nice 20g kettle, so this would be the perfect option. Your efforts could be really helpful to many of us! Thanks for all of the great work and inspiration.
No problem, I'm glad to help where I can. So far so good with my rig, but I have to add a word of caution. I have burnt quite a few hours getting all of this together. Be prepared to invest a bit of time building , programming and tuning the system if you go down this path. I think that an electric setup would be easier to tune, and you wouldn't have to worry about the whole burner ignition and blowout issue. However, I enjoy brewing outside with the option of brewing in my garage in poor weather so propane is my fuel of choice. Not to mention that I reused all of my propane equipment saving a few bucks.
__________________
tob77 is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 05:16 PM   #7
craigmw
Feedback Score: 0 reviews
Recipes 
 
Join Date: Dec 2012
Location: Villa Park, CA
Posts: 138
Liked 15 Times on 12 Posts
Likes Given: 4

Default

Tob:

Okay, thanks for the clarification and pictures. I'll read your Python files for more info about the GPIO pins used and can pretty much figure out the hardware from there. I've also considered using a thermocouple to control the spark ignitor circuit. I outfitted my burner with a Brinkmann electronic igniter kit (http://www.amazon.com/Brinkmann-Univ.../dp/B007VAXQF8). I could easily modify the circuit in this to allow for external control from a 5V relay. I will also need to use level shifters, or accomplish switching functions (e.g. pump, igniter) using 1-wire switches (e.g. DS2408 or DS2413), the latter of which have the advantage of using a single 1-wire bus and thus fewer GPIO pins.

Regarding flame sensing, there are 1-wire thermocouple drivers (MAX31850) that could work for this application. Blichmann apparently uses a different method. From what I gather by looking at their TOP Control Module, they appear to somehow detect heating of the spark igniter via a single high voltage cable. I'm not sure how this works, though I guess that they must be measuring changes in the ignitor's resistance due to heating. I think I'll just stick with the thermocouple method.

I think your method of testing the temp from the bottom of the kettle makes the most sense to avoid overshoot. I will have to come up with a way to do this on my rig. I am not so concerned about overall heat distribution, but want to avoid overshooting the target temp. It seems that the most difficult part of the build is getting the gas valve to respond reasonably linearly to the PID output. Are you using a lookup table or linear regression calculation for this? Also, your readme file mentions a gas solenoid valve, which appears to be plumbed right before the input to the burner. What is the purpose of this, since you already have a servo valve to control gas flow?

__________________
craigmw is offline
 
Reply With Quote Quick reply to this message
Old 01-04-2014, 09:35 PM   #8
alien
Feedback Score: 1 reviews
Recipes 
 
Join Date: Apr 2012
Location: Philadelphia, PA
Posts: 1,233
Liked 65 Times on 58 Posts
Likes Given: 61

Default

Very nice interface Tob.

__________________
Magic Smoke brewhouse and grill

Arduino PID controller - Automatic Smoker - Cooler MLT - Counterflow Chiller - SSR demo - PWM timer - Folding Brew Table
alien is offline
 
Reply With Quote Quick reply to this message
Old 01-05-2014, 07:00 PM   #9
tob77
Feedback Score: 0 reviews
Recipes 
 
Join Date: Sep 2012
Location: Napa, CA
Posts: 62
Liked 6 Times on 4 Posts
Likes Given: 16

Default

Quote:
Originally Posted by craigmw View Post
Tob:
I outfitted my burner with a Brinkmann electronic igniter kit (http://www.amazon.com/Brinkmann-Univ.../dp/B007VAXQF8). I could easily modify the circuit in this to allow for external control from a 5V relay.
The only problem with spark modules is that they produce a lot of electromagnetic interference. I have spent quite a bit of time trying to shield my system from the problems it introduces. Try to keep the spark gap as small as possible. I have found that less EMI is produced with smaller spark gaps. I have also found that for whatever reason that some of the electric outlets in my house are grounded better than others. I can not brew off of one of the outlets in my garage because of the poor grounding and resultant EMI from the spark module. As it is, I still get some problems with my LCD on my control panel from time to time when the spark module fires. To counter this I have programmed an initialization command to the LCD after the spark module has been automatically fired. For what it's worth, the rpi has never been reset due to EMI. The only problems I have seen were in the 1-wire comms and the LCD display.

Quote:
Originally Posted by craigmw View Post
Regarding flame sensing, there are 1-wire thermocouple drivers (MAX31850) that could work for this application.
Thanks for pointing out the MAX31850, I haven't seen that before. I'll probably look into this sometime in the future. I'd have to figure out somewhere to place the thermocouple that wouldn't burn up. Usually the thermocouples are placed on pilot lights. I could probably get away with putting one close to the flame but not in the flame but idk. Do you have any thoughts on this?

Quote:
Originally Posted by craigmw View Post
Are you using a lookup table or linear regression calculation for this?
The data that I got from my linearization tests wasn't the best. I think it had to do with poor mixing, and other environmental changes between tests (not all of the tests were taken on the same day). I plotted all of the data that I had in excel and created a curve in excel that best fit my data. The python program uses linear interpolation to linearize the output based on the data from the curve.

Quote:
Originally Posted by craigmw View Post
Also, your readme file mentions a gas solenoid valve, which appears to be plumbed right before the input to the burner. What is the purpose of this, since you already have a servo valve to control gas flow?
I already had the propane solenoid valve from my previous configuration so I kept in in the loop. It has the added bonus of being my gas on/off so I don't need to close the regulator valve with the servo all the way tight. This means that my servo never has to deal with the high torque necessary to clamp the valve shut even though I think that it has plenty of torque for the job.
__________________
tob77 is offline
 
Reply With Quote Quick reply to this message
Old 01-07-2014, 12:24 AM   #10
jrubins
Feedback Score: 0 reviews
Recipes 
 
Join Date: Aug 2012
Location: San Jose, CA
Posts: 88
Liked 5 Times on 3 Posts
Likes Given: 3

Default

Nice work, tob77, that is really impressive.
I wonder if you could post some more info on your sparker setup and how you are using it - manually, through code, etc. I'd also really like to see the inside of your control box. Finally, I don't see a pump on your recirculation arm, so I'm curious as to how you are siphoning the wort from bottom to top.

I see you're in the North Bay, do you ever come south? I'd love to hang out and talk beer/kit. I'm going to try hanging out at the Silicon Valley Sudzers meetup this Friday in Los Altos.

__________________

In bottles: Last Day IPA, AAPL American Pale Ale
On deck: Some sort of porter type thing

The answer to the ultimate question of life, the universe, and everything? 42. The number of bottles in my first batch of homebrew? 42. Coincidence? I think not.

jrubins is offline
 
Reply With Quote Quick reply to this message
Reply


Quick Reply
Message:
Options
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
StrangeBrew Elsinore - Raspberry Pi based brewery controller DougEdey Electric Brewing 369 05-18-2014 12:58 AM
StrangeBrew Elsinore - Raspberry Pi based brewery controller DougEdey Automated Brewing Forum 1 07-15-2013 09:23 AM
Raspberry Pi Temp Controller steve071 Automated Brewing Forum 70 07-14-2013 06:18 PM
BrewPi released! A feature rich raspberry pi brewing controller! Elkoe DIY Projects 0 09-29-2012 05:29 PM
Raspberry Pi Brewhouse controller? SGFBeerBuzz DIY Projects 15 08-14-2012 04:26 AM