Friday, July 18, 2014

Designing a Brew Chamber Controller (Update 1)

I've added some code to check the last time the cooler shut off.  This will stop the cooler from cycling which is not good for the compressor.

Don't forget to add TIME_LAST_COOLER and COOLER_TIME to the global variable section near the top of bcc.py

Then replace the cooler function with the code below.

Again, the complete updated code is available on github - https://github.com/cyberlord8/bcc

TIME_LAST_COOLER = 0 #variable to track when cooler was last turned off
COOLER_TIME = 5 * 60 #5 minutes * 60 seconds
#cooler control function
def cooler_control(current_temperature):
    global COOLER_ON, DESIRED_TEMP, DWELL, TIME_LAST_COOLER, COOLER_TIME
    if current_temperature > DESIRED_TEMP + DWELL:
      if time.time() - TIME_LAST_COOLER > COOLER_TIME:#has it been more than 5 minutes?
        if not COOLER_ON:
          COOLER_ON = True
          print "Turning cooler on\n\n"
          GPIO.output("P9_23",GPIO.HIGH)
      else: print "Cooler can't turn on yet", 300 - (time.time() - TIME_LAST_COOLER),"seconds left\n\n"
    elif COOLER_ON:
      COOLER_ON = False
      print "Turning cooler off\n\n"
      GPIO.output("P9_23",GPIO.LOW)
      TIME_LAST_COOLER = time.time()#reset cooler timer
    return

1 comment:

  1. This project is great. I'm glad I found it. I was thinking of setting up a BrewPi but could not bring myself to use a separate microcontroller and computer. Plus this gives me the excuse I've been waiting for the buy a BBB! Thank you. If you need any help please let me know.

    ReplyDelete