Go Down

Topic: Kegerator Temperature Control (Read 7926 times) previous topic - next topic

scoates

Hi,

I built (with many thanks to Daniel) an arduino-based temperature controller for my kegerator (holds my homebrew beer). I did a mini write-up here:

http://www.brewboard.com/index.php?showtopic=77935

I plan on writing something a little more in-depth of uCHobby, but in the meantime, if anyone has any questions, I'd be happy to answer them and share my code if there's interest.

S

ddiez

first of all, my apologies for my bad english.
I will read your mini-write up in a very detailed fashion.
I'm am brewer too, from Argentina, and i'm doing something similar, but
i didn't feel confortable with high tension yet (220 volts, thats the voltage refrigeretors works here).
so I plan in doing something similar to the "Son of the Fermetation chiller" (http://home.elp.rr.com/brewbeer/chiller/chiller.PDF)  but microcontrolled.

anyway in some future when I do brew a lager (up to now I brew Ales only) something like this will be a must.

please keep us informed. and thanks for sharing.
I'm a web/java programmer too, and an electronics hobbyst.

FrankTank

scoates,
Your mini write up sounded cool.  I just started playing around with my arduino, but I was thinking of creating a similar project (on a slightly finer scale).  I want to use a thermocouple to control a peltier plate (with a ssr like your temp. controller).  Being a newbie, I am really bad with the programming side of things, would you mind posting your code so I could work off of your model?
Thanks,
Frank

scoates

Hi,

You'll need to make sure you can get an SSR that handles a DC load.

The whole writeup should be on ucHobby in the coming days. In the meantime, here's the code. I'm sure it could be optimized a bit, but it works for me:
Code: [Select]

// Beer Thermostat

#define STATUS_OFF 0
#define STATUS_ON 1
#define TOGGLE_NOCHANGE 0
#define TOGGLE_ON 1
#define TOGGLE_OFF 2
#define TOGGLE_MALFUNCTION 3

#define WAIT 1000

struct Thermistor
{
 int  base; // *100, see below
 int  diff; // *10 because of floats (10.2, for example->102)
 int  pin;
};

struct Controller
{
 int  relayPin;
 int  thermInvert; // 0 = power on cools, 1 = power on heats
 int  lastRead;
 int  low;
 int  high;
 int  status; // 0=off;1=on
 int  toggle; // 0=nochange; 1=turnedon; 2=turnedoff; 3=malfunction
 int  timer;  // seconds since last status change
 struct Thermistor Therm; // Thermistor
};

Controller Freezer;
Controller Fermenter;

Thermistor ThermA;
Thermistor ThermB;

void setup()
{

 // Thermistor Calibration
 ThermA.base = 22500; // re-calibrate me!
 ThermA.diff = 102;
 ThermA.pin = 0;
 
 ThermB.base = 22500;
 ThermB.diff = 102;
 ThermB.pin = 1;
 
 // Freezer Setup
 Freezer.relayPin = 12;
 Freezer.low = 40; // (10 * ºC)
 Freezer.high = 60; // (10 * ºC)
 Freezer.thermInvert = 0;
 Freezer.status = STATUS_OFF;
 Freezer.toggle = TOGGLE_NOCHANGE;
 Freezer.timer = 0;
 Freezer.Therm = ThermB;
 
 // Fermenter Setup
 Fermenter.relayPin = 11;
 Fermenter.low = 170; // (10 * ºC)
 Fermenter.high = 180; // (10 * ºC)
 Fermenter.thermInvert = 1;
 Fermenter.status = STATUS_OFF;
 Fermenter.toggle = TOGGLE_NOCHANGE;
 Fermenter.timer = 0;
 Fermenter.Therm = ThermA;

 Serial.begin(9600);
 
 pinMode(Freezer.relayPin, OUTPUT);
 pinMode(Fermenter.relayPin, OUTPUT);
}

void loop()
{
 checkTemp(Freezer);
 toggle(Freezer);
 Freezer.timer++;
 doOutput("KEG", Freezer);

 delay(WAIT);

 checkTemp(Fermenter);
 toggle(Fermenter);
 Fermenter.timer++;
 doOutput("FER", Fermenter);

 delay(WAIT);

}

void checkTemp(struct Controller &c)
{
 int span = 20;
 int aRead = 0;
 for (int i = 0; i < span; i++) {
   aRead = aRead + analogRead(c.Therm.pin);
 }
 aRead = aRead / span;
 c.lastRead = (((1024 - aRead) * 100) - c.Therm.base) / c.Therm.diff; // ºC
}

void toggle(struct Controller &c)
{
 c.toggle = TOGGLE_NOCHANGE;
 if (c.lastRead > c.high && c.status != STATUS_ON) {
   // getting too hot
   tooHot(c);
 } else if (c.lastRead < c.low && c.status != STATUS_OFF) {
   // getting too cold
   tooCold(c);
 }
}

void tooCold(struct Controller &c)
{
 if (c.thermInvert) {
   digitalWrite(c.relayPin, HIGH);
   c.status = STATUS_ON;
   c.toggle = TOGGLE_ON;
 } else {
   digitalWrite(c.relayPin, LOW);
   c.status = STATUS_OFF;
   c.toggle = TOGGLE_OFF;
 }
 c.timer = 0;
}

void tooHot(struct Controller &c)
{
 if (c.thermInvert) {
   digitalWrite(c.relayPin, LOW);
   c.status = STATUS_OFF;
   c.toggle = TOGGLE_OFF;
 } else {
   digitalWrite(c.relayPin, HIGH);
   c.status = STATUS_ON;
   c.toggle = TOGGLE_ON;
 }
 c.timer = 0;
}

void doOutput(char name[4], struct Controller &c)
{
 Serial.print(name);
 Serial.print(" ");
 Serial.print(c.lastRead);
 Serial.print(" ");
 Serial.print(c.status);
 Serial.print(" ");
 Serial.print(c.toggle);
 Serial.print(" ");
 Serial.println(c.timer);
}


FrankTank

Thanks for the code, good call on the ssr, I did'nt think of that, luckily I have some DC relays laying around.
Frank

FrankTank

scoates,
This relay issue is beginning to boggle my mind!  I just got my peltier here
http://www.allelectronics.com/cgi-bin/item/PJT-6/775/40_MM_SQUARE_THERMOELECTRIC_COOLER_.html
My problem is the amperage, most low voltage (5vdc) relays are only rated for about 1 amp.  DC ss relays are rated higher, but are way too expensive (in addition, the output voltage is typically around 24vdc)! What relay did you choose for your peltier setup? Do you have any problems drawing too much current?  
Thanks



scoates

Yes, Solid State Relays are much more expensive than regular mechanical relays. My fermenter isn't exactly working right now (-:

I have a regular relay that I found in the surplus aisle of my local electronics shop that's rated for 5A. My Peltiers draw 2.2A each (currently), at 12V.

S

Daniel

#7
Sep 01, 2007, 12:43 am Last Edit: Sep 01, 2007, 07:47 am by Daniel Reason: 1
Quote
scoates,
This relay issue is beginning to boggle my mind!  I just got my peltier here
http://www.allelectronics.com/cgi-bin/item/PJT-6/775/40_MM_SQUARE_THERMOELECTRIC_COOLER_.html
My problem is the amperage, most low voltage (5vdc) relays are only rated for about 1 amp.  DC ss relays are rated higher, but are way too expensive (in addition, the output voltage is typically around 24vdc)! What relay did you choose for your peltier setup? Do you have any problems drawing too much current?  
Thanks


hey

the relay ratings you're talking about are the maximum ratings.... you can just as easily run 12V through them.

A relay with contacts rated 48V, 10A, for example, can handle loads of
5V @ 10A, 12V @ 2A, 36V @ 10A, etc etc. The contacts are always rated for the maximum load they can handle, but you always use less than that.

You can get a cheap relay ( think automotive supply- cars are full of relays) with a 12V coil that will switch lots of amps ( 20 or more). All you need is to add a transistor circuit to the Arduino to drive the relay, and you need a source of 12V for the relay coil. Look in the Playground for more information, under tutorial>relay.

D

PS: solid-state relays are probably not such a hot idea for switching DC, as you need to get a special "DC" model. This is due to the fact that most SSR's use thyristors ( SCR's and Triacs) as their active element, which latch into the conducting state when they are fed DC. You could also try a TIP102 Transistor with a heatsink, or something like an IRFZ40 MOSFET.... google them and you'll get the idea.

FrankTank

Thanks for the quick response guys.  I am going to try wiring a automobile relay (12v coil) according to the tutorial diagram.  Looks like it is time to order a TIP102 transistor.  I don't want to hijack this thread so if I have any more questions I will start my own thread in an appropriate category.
Thanks again,
Frank

al_la

ah, this is almost exactly the project I bought my unit to do :D

could you post, please, schematics and a breakdown of how you set the thermistors up, and how you calibrated them?

--lyndon

scoates

Hey,

Sorry for the delay. The editor over at uchobby finally published my article, so hopefully that answers your questions. If anything is still unclear, feel free to ask.

http://www.uchobby.com/index.php/2007/10/08/arduino-beer-thermostat/

S

CrashingDutchman

Nice!

I found it at Make magazine:
http://www.makezine.com/blog/archive/2007/10/arduinocontrolled_kegerat.html?CMP=OTC-0D6B48984890

scoates

FYI, I've modified this project pretty heavily. I've added support for a 2nd "vessel" with both heat and cool control (for fermenting), added a display, changed my temperature measuring devices to LM35s (changing to DS1624s, soon), and rewrote ALL of the code.

New code is here:
https://svn.caedmon.net/svn/public/beer_thermostat/

S

vanityklaw

I'm thinking about doing a little weather station for my first arduino project -- how do I know what thermistor to get? They're all about 50 cents.. :)

a newb electronic question, but what does the ohm rating mean?

http://www.jameco.com/webapp/wcs/stores/servlet/KeywordSearchResultView?langId=-1&storeId=10001&catalogId=10001&searchType=k&searchValue=thermistor&categoryId=107039&rscount=20


l0cke

I'm trying to get this code to work. It seems to be incompatible with 0017.

This is the error I get
Code: [Select]
In function 'void loop()':
error: 'checkTemp' was not declared in this scope In function 'void toggle(Controller&)':


Can someone help me fix this? I'm more of a hardware guy.  :)

Go Up