Hack a Picnic Cooler (into a Thermostatic Chamber)

8.5K487

Intro: Hack a Picnic Cooler (into a Thermostatic Chamber)

My colleague David and I need to soak our scintillation detectors at known constant temperatures if we are ever to graduate. Our thesis advisers need their lagers at 6 to 9 degrees Celsius, ales at 7 to 11 degrees Celsius and the occasional stout at 13 degrees Celsius.
This is what I came up with. Enjoy!
Martina

STEP 1: The Task

The lab already had a picnic cooler, supposedly for climate-testing of the radiation detectors (?!). The cooler came equipped with a Peltier pump that can run off AC mains or 12V DC and can either heat or cool (depending on the switch setting) the box interior. Unfortunately, there is no thermostatic control built in, so the internal temperature either approaches approximately the ambient temperature less 20 degree Celsius or heats up to +50 Celsius and stays there (probably limited electronically).

This simply screams for some micro-controller driven decision making.

Aside from a picnic cooler, the final bill od materials consisted of:

  • an arduino board
    (we used a pro mini 328/5V/16M, simply because they are the cheapest Arduino clone on eBay @ $2.83),
  • 2 relays (5V/1ch relay modules from eBay at $0.99 each),
  • 2 momentary push-buttons (stolen from colleague Klemen)
    [Klemen comments: "Borrowed not stolen. One day I will have them back."],
  • an electronics thermometer (we used a DS18B20, eBay @ $1.04),
  • 5 resistors (see schematics, later on),
  • an LCD 2x16 display module (HD44780 compatible module, eBay @ $2.26),
  • a 7805 voltage regulator (eBay @ $0.90) and its two decoupling capacitors,
  • an electrical enclosure box from the hardware store ($6.00 for the cheapest one!),
  • many, many, many... wires (depths of supervisor's drawer).

STEP 2: Reverse Engineering & the Hack

The chamber cover is where all the action is. After removing the black foam "rope" (that runs the perimeter of the cover and acts to seal against air drafts) and unscrewing a zillion screws underneath, the two plastic clams fall open to expose a large piece of styrofoam and all the electronics.

Our target is the underside guts of the COOL-OFF-HEAT selector switch. If you can switch between these three states by hand, it should be possible to bypass it with a handful of relays, right?

Four wide copper traces lead to the three-state switch. Two of them eihave 12V DC between them, regardless of the switch position. The remaining two are both "cold" when the switch is in the OFF position, and become energized with 12V between them for both the COOL and HEAT switch positions, but with opposite polarities for the two cases. Lookin' good! So the switch literally selects the current flow direction through the Peltier element, in turn making it pump heat ther in or out. All we need to do is cut off the connections from the switch and route them out using four thick (several amperes of current!) wires to where we will attach the relays.

STEP 3: All of the Toppings

Separately, the controller part needed to be developed.

User interface first.
We decided that we want two buttons and a display. The display would show the desired target temperature, the actual temperature and the heat pump state (i.e. Off, COOL, or HEAT). User input would be via two momentary push-buttons. One of them would increase the target temperature by a small amount, say a tenth of a degree, each time it is pressed, and the other one would decrease it in the same sense with each press.

Thermometer
There's nothing like the simplicity and robustness of a DS18B20. I hope they gave that Dallas guy a good pat on the back when he invented it. The connection, including the 4k7 pullup, is as shown on the schematics.

LCD connections.

Switching.

Power.
The four wires that got routed out from the chamber guts in the previous step will provide a free 12V supply for the Arduino board if connected at the RAW pin. The on-board regulator will provide 5V power at the VCC pin for the thermometer and for the LCD. Powering the relays is a separate issue because they need up to 85mA each, while the board regulator can only provide some 150mA of current, of which 30-100mA is used on-board already. For this reason, we included a separate 7805 with its two decoupling caps to provide power for the relays.


For controlling the current direction we can use 2 relays. With relay we
electrically switch between two options, in our case we switch between 12V and ground. It has 3 inputs, ground, Vcc (5V) and signal from arduino board which tells relay which option to choose. With two relays we have 4 combinations. Option in which current doesn`t flow is when both sides of Peltier element are on the same potential (0V or 12V). If we have on one side ground and on the other 12V the current flows and from that on which side is higher voltage depends direction of the current.

We will need two buttons for adjusting temperature, 2 relays and a temperature sensor for reading chamber temperature and a voltage regulator. We put all the pieces together following the sketch above which emerged during the program and chamber testing.



STEP 4: Temperature Control Logic

To compile the program you need arduino IDE and some libraries. Those are OneWire and DallasTemperature for thermometer and LiquidCrystal for LCD display module.
The code consist of 3 parts:
-reading temperature from sensor and writing it on display, we check temperature every 800ms
-reading buttons and writing desired temperature on the display
-deciding between heating, cooling and off state. We included temperature hysteresis to avoid switching between two states to often when we are near desired temperature.

PROGRAM:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

unsigned long lasttime;
int comand;
float oldTc;
float Td = 21;     //desired T, controlled with buttonI and buttonD
float Th = 1.0;      //allowed deviation
float Tc;          //chamber temperature
int buttonD = 9;  //button which decrease desired T
int buttonI = 8;  //button which increase desired T
int relay1 = 5;   
int relay2 = 4;

//FUNCTION WHICH READS CHAMBER TEMPERATURE
#define ONE_WIRE_BUS 6 // Temperature sensors data wire is plugged into pin 6 on the Arduino.
OneWire oneWire(ONE_WIRE_BUS);
//Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
LiquidCrystal lcd(A3,A2,A1,A0,13,12); 

void setup(void){ 
  lcd.begin(16, 2);
  delay(200);
  // Start up the library
  sensors.begin();
  sensors.setWaitForConversion(false);
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT); 
  lasttime = millis();
}

void loop(void)
{
  int button_state;
  if((millis()-lasttime)>800){
       Tc = sensors.getTempCByIndex(0); 
       sensors.requestTemperatures(); //Send the command to get temperatures.
       lasttime = millis();
                            }
  lcd.setCursor(0, 0);
  lcd.print("T=");
  lcd.print(Tc,1); 
  lcd.print("C ");
  lcd.setCursor(0, 1);
  lcd.print("Desired T=");
  lcd.print(Td,1);
  lcd.print("C ");
  int down = 0;
  button_state=digitalRead(buttonD); 
  if(button_state==0) {       
       Td = Td - 0.1;
       down = 1;
                     }
  button_state=digitalRead(buttonI);
  if(button_state==0) {
       Td = Td + 0.1;
       down = 1;  
                     }
  if (down) {     //for faster/better button response
       delay(200);
           }

//SELECTING BETWEEN HEATING, COOLING AND OFF
 if(Tc<=(Td-Th/2)){
       comand = 1; 
                 }
 if(Tc>=(Td+Th/2)){
       comand = -1;
                 }
 if(Tc>Td && oldTc<=Td) { //hysteresis
       comand = 0; 
                       }
 if(Tc=Td) { //hysteresis
       comand = 0; 
                       }
 oldTc = Tc;
 
//commands for heating, cooling and off
 lcd.setCursor(9, 0);  
 if(comand==-1) { //cooling
       digitalWrite(4, HIGH);
       digitalWrite(5, LOW);
       lcd.print("COOLING");   
               }
 if(comand==1){ //heating
       digitalWrite(5, HIGH);
       digitalWrite(4, LOW);
       lcd.print("HEATING");
             }
 if(comand==0) { //off
       digitalWrite(4, HIGH);
       digitalWrite(5, HIGH); 
       lcd.print("OFF    ");
              } 
}






STEP 5:

On the top of the chamber we attach a box in which we fix relays and arduino on which we already upload our program. In the box we make holes for wires from relays and thermometer to connect them to the chamber. We attach LCD display and buttons on the cover of the box.
Vcc pin can provide 150mA of current, of which about 30-100mA is used for processing the board. Because one relay requires 85 mA we have to supply relays from other source. We connect relays with (12V) source that supplies Peltier element. We also need a voltage regulator because these relays maximum voltage input is 5V.
The next step was testing the chamber. In the chamber appeared a temperature gradient because Peltier elements ventilator is to weak to mix all the air. We will try to solve this problem with adding another ventilator. Another reason that the air near the top wall of the chamber is hotter is that the cover is not as good isolated as other walls of the chamber. After adding ventilator and another measuring the temperature profile we will upload the upgrade.

7 Comments

As far as the thermistor, that's reasonable to go for a calibrated module versus calculating against a precalibrated source and software converting values. As far as the FETs go, I believe you would use an H-Bridge configuration similar to how you drive a motor backwards and forwards.
Aha,
I think you're right. We could go for something like a L298 based dual H-bridge and use both channels in parallel. Thanks for the great insight!
After three days of my weekend time, I found an error in your code that finally allowed the code to work. You can't use an "=" sign when comparing two variables in an IF statement. Otherwise it will make two variables the same. Use "==" instead.
if(Tc=Td) { //hysteresis
comand = 0; it has to be: if(Tc==Td) for comparing Tc and Td.
When I ran the program, it was stuck in the OFF mode.
I protoboard the circuit to check it's operation. Substituted leds for the relays and added the buttons and LCD (Sharp LM16255, without the extra buttons). I can get it to display to the LCD and change the set point. The LCD always show it in the "OFF" state and I can move the setpoint up and down. Both temps displayed move up and down as the same value. Doesn't seem to report the chamber temperature. I know the sensor works. I added a print statement to display the temperature variable at the serial port and it moves if I warm the sensor. Yet, the leds that simulate the relays always remain on. Doesn't seem to get out of the OFF MODE. What's wrong?
I like this project and want to build to test temperature drift of electronic circuits and references. I am thinking of using mosfets instead of relays to switch polarity to the Pelter device configured as a H bridge. This will eliminate sound of clicking of relays. May also consider a PID loop to stabilize temperature, if it is needed. An H bridge control IC may integrate quite nicely. You meantioned something about an upgrade. Have you done this yet?
I like the project, but I had a few suggestions. Instead of using relays, you could use logic level n channel FETs. This would eliminate the need for an additional 7805 and caps. Instead of using a thermometer circuit, you could try building a simple one from a thermistor and a voltage divider. I don't think the former suggestion is cost efficient, but the latter most likely is.
Hi, thanks!

Regarding remark 1, we cannot figure out how to wire the FETs so that we could
* run the peltier in both directions
* never possibly short the power supply with faulty software.
Like you, I'm also not sure about pricing of low impedance FETs with 5 amp rating and robust to inductive kick of both fans? The relays cost us $1.98 and give off very satisfying audible clicks. :-).

Regarding remark $2:
* the 18B20 thermometer cost $1.04 S&H incl in quantities of 1. We buy bags of 10, so they run only $.50 or so. They are very accurate and come calibrated. With an NTC resistive divider, we'd have to calibrate the system ourselves. We were simply too lazy to go for that. ;)