EcoRenovator

EcoRenovator (https://ecorenovator.org/forum/index.php)
-   Appliances & Gadgets (https://ecorenovator.org/forum/forumdisplay.php?f=21)
-   -   Arduino controlled "chest freezer" refrigerator (https://ecorenovator.org/forum/showthread.php?t=1175)

skyl4rk 10-10-10 02:00 PM

Arduino controlled "chest freezer" refrigerator
 
Below is arduino code that uses a thermistor voltage reading to turn a chest freezer on and off to maintain a certain temperature.

The thermistor measured about 500 ohms at 20C. 5V was applied to the thermistor and a 1000 ohm resistor in series, and the resulting voltage was measured at the junction between the two, as if you were using a voltage divider. On an analog input pin, the arduino displays a number between 0, which represents 0V, and 1000 which represents about 5V.

The voltage level at specific temperatures is determined by putting the thermistor in an ice bath (0 Celsius) and reading the result, then heating the water a bit to 10 Celsius and reading the result, and extrapolating the other degree levels.

Most of the following code is used to display the temperature by blinking an LED or sending a tone in morse code.

Void(loop) repeats every 1000 milliseconds, in other words, it checks the temperature every second.

The very bottom of the code, after void(loop), is where the arduino senses the current voltage level, and if it is outside of parameters, it turns on the voltage at pin 5. Pin 5 delivers 5V to a relay which is used to turn on the chest freezer. Vdyn is the dynamic voltage, in other words the voltage returned every 1000 milliseconds. Vmax is the parameter for the maximum desired voltage (which represents the maximum temperature before the compressor should turn on).

Because the chest freezer motor is an inductive load, a high amp relay is needed. I used a dual 10 amp relay, which is not the same as a 20 amp relay but almost as good.

Code:

// Kegerator Controller
// Kegerator control to digital pin 5
// Thermistor to analog pin 2
// this example is with a 500 Ohm thermistor at 20C and a 1k Ohm resistor to ground
// 5VDC to thermistor to resistor to ground, pin 2 to thermistor/resistor junction
// Vmax is 4C, Vmin is 2C on my thermistor circuit.
// Vdyn is the current voltage read from the thermistor
// Pin 13 flashes morse value for Vdyn on LED, pin 9 sounds a morse tone on speaker for Vdyn
// 434-> 0C, 447-> 1C, 459-> 2C, 472-> 3C, 484-> 4C, 497-> 5C, 509-> 6C, 522-> 7C, 534-> 8C, 545-> 9C, 559-> 10C

int Vmax = 484; 
int Vmin = 459;
int ThermistorPin = 2;
int ditlength = 25;
int hundreds = 0;
int tens = 0;
int ones = 0;
int Vdyn = 0;
int status = 0;
int x = 0;
int c = 0;

typedef void (*FunctionPointer) ();
FunctionPointer numeral[10] = {zero,one,two,three,four,five,six,seven,eight,nine};

int conversion[9] = {434,447,459,472,484,497,509,522,534};

void zero(void) {dash(); dash(); dash(); dash(); dash(); pause();};
void one(void) { dit(); dash(); dash(); dash(); dash(); pause();};
void two(void) {dit(); dit(); dash(); dash(); dash(); pause();};
void three(void) {dit(); dit(); dit(); dash(); dash(); pause();};
void four(void) {dit(); dit(); dit(); dit(); dash(); pause();};
void five(void) {dit(); dit(); dit(); dit(); dit(); pause();};
void six(void) {dash(); dit();dit();dit();dit(); pause();};
void seven(void) {dash(); dash(); dit(); dit(); dit(); pause();};
void eight(void) {dash(); dash(); dash(); dit(); dit(); pause();};
void nine(void) {dash(); dash(); dash(); dash(); dit(); pause();};

void dit() {
for (x=0; x<ditlength; x++){
  digitalWrite(9, HIGH);
  digitalWrite(13, HIGH);
  delayMicroseconds(2800);
  digitalWrite(9, LOW);
  digitalWrite(13, LOW);
  delayMicroseconds(100);
  }
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(100);
}

void dash() {
for (x=0; x<ditlength*3; x++){
  digitalWrite(9, HIGH);
  digitalWrite(13, HIGH);
  delayMicroseconds(2800);
  digitalWrite(9, LOW);
  digitalWrite(13, LOW);
  delayMicroseconds(100);
  }
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(100);
}

void pause(){
  digitalWrite(9,LOW);
  digitalWrite(13,LOW);
  delay(300);
}
   
void setup() {
  pinMode(9, OUTPUT);
  Serial.begin(9600);
}

void loop() {
 
Vdyn = analogRead(ThermistorPin);
Serial.println(Vdyn);

if(Vdyn > Vmax){
  status = 1;
  }
 
if (Vdyn < Vmin){
  status = 0;
  }

if(status == 1){
  digitalWrite(5, HIGH);
  Serial.println("Compressor On");
  }

if(status == 0){ 
  digitalWrite(5, LOW);
  Serial.println("Compressor Off");
  }

hundreds = int(Vdyn/100);
tens = int((Vdyn - (hundreds*100))/10);
ones = int(((Vdyn - (hundreds*100)) - (tens*10)));

numeral[hundreds]();
numeral[tens]();
numeral[ones]();

delay(1000);

for (c=0; c<9; c++){  //if in range 0 to 8, sound and flash morse degrees Celsius
  int  d = c + 1;
  if (Vdyn > conversion[c] && Vdyn < conversion[d]){
    numeral[c]();
    Serial.println(c);
    }
  }
delay(1000);
}


skyl4rk 10-10-10 02:23 PM

The relay used was this one:

relays, solenoids, buzzers, timers, sockets & accessories

http://www.lineelectric.com/gif/photos/cr.jpg

It is double pole double throw so there are actually two 10 amp relay actuators. Depending on the size of your chest freezer motor, you may want to move up to the 20 amp relay.

A base for this relay is also needed. Make sure that the relay is rated at 6VDC (more or less) so that it kicks in when the arduino turns on the 5V to the trigger circuit. I think my relay was rated at 12VDC, but it still worked. The relay rated at 12V might have used more current than desirable at 5V.

The thermistors were part of a grab bag of thermistors from American Science and Surplus. They do not have them anymore, as far as I can tell. Any thermistor rated at 500 ohm to 1000 ohm should work fine. Just match it with a similar sized resistor. When you calibrate the thermistor you make up for any differences in ohmage.

AS&S did have this: American Science & Surplus : Solenoids and Relays

There was hysterisis built into this code, the code turned the compressor on at Vmax (484 or 4C), and did not turn it off until Vmin (459 or 2C).

I did this project quite a few years ago and had several arduino scripts on an old archive hard drive. I can't tell you for sure if this was the working script, but it should be fairly easy to troubleshoot if it is not the right one, it is a very simple script.

knowbodies 10-10-10 03:50 PM

I'm a geek and all, and I love hacking stuff but wouldn't a line voltage thermostat for a walk-in cooler have been a lot simpler?

skyl4rk 10-10-10 07:09 PM

Yes, that would be much easier. But that gets you no mad scientist points.

Clev 10-11-10 12:44 AM

Quote:

Originally Posted by knowbodies (Post 8631)
I'm a geek and all, and I love hacking stuff but wouldn't a line voltage thermostat for a walk-in cooler have been a lot simpler?

A walk-in cooler thermostat can't tweet its status.

Tweet Library for Arduino

skyl4rk 10-14-10 08:58 PM

Here is a kit for a thermostat. It is not cheap but the schematic is available on this page:

:: Mikey Sklar :: Holy Scrap ::


All times are GMT -5. The time now is 11:10 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Ad Management by RedTyger