Thermo

Temperature Controller

Wine doesn’t like subzero temperatures, and during wintertime, my “winecellar” got pretty cold.
There was an electric heating element, but the thermostat was broken, so it was either full burn or nothing.

That’s how the temperature monitor/controller came to be.
It was an obvious task for a small processor and I’ve always wanted to test the Dallas temperature sensors.

So, I designed this little device which could monitor the temperature and control the heater.

It’s based on an AT90S2313 and a Dallas DS1621 Digital Thermometer. The temperature is displayed on a dual 7-segment display, and two buttons are used for setting parameters. A high current relay switches the heating element.

I used an AVR 2313 as it just the right number of pins for this task. Also, it’s programmable in C, which makes things easier. An alternative would be the 1200, but I’ve got some bad experience with that.
A 4 MHz ceramic resonator is used for clocking the 2313.

The displays are common cathode displays. The segments of both displays are tied together and multiplexing is handled in software. Note that the decimal point segment also are used. More detail about this later.

The power supply is straight forward. A single or double tap 9 V transformer with a rectifier circuit and a 5V voltage regulator. The rectified input to the regulator is also supplied as a drive voltage to the relay.

The Dallas DS1621 chip interfaces to the 2313 using a I2C interface. This is a 2 wire bidirectional bus with a speed up to 400 kbps.
Up to 8 DS1621 devices can be connected on the same I2C bus, but in this case there’s only one device, so the address selector pins on the DS1621 is pulled low, giving it address 0 (well, 0x90 actually).
Actually, the DS1621 has a thermostat output, which can be programmed to a certain temperature, but it’s not used in this application.

The relay needs about 40-50 mA and is driven by a standard NPN transistor.

The two buttons are used to set the temperature where the relay should kick in. As the code is now, the relay will always be ON when the measured temperature < set temperature, but this could be changed (if you would want to control an air-condition f.i.)

Normally, the display show the measured temperature. The left decimal point will toggle on/off to show that the system is “alive”. The right decimal point show the state of the relay, on or off.
A short press on either the UP or DOWN button, will display the set temperature for about 1 second. If the key is held down, the set temperature will be increased or decreased respectively.
Pressing both keys at the same time gives access to two parameters :
The first is the hysteresis (indicated by the middle segment in the left display being lit, the right display show the parameter value), which determines the relay switch points. For instance, if the hysteresis is set to 2, and the set temperature to 21 degrees, the relay will go ON at 19 degrees, and OFF at 23 degrees. This is to avoid a situation with an oscillating relay.
The second parameter is the display duty-cyle (indicated by the bottom segment in the left display being lit, the right display show the parameter value). This controls the display multiplexing, and effectively determines the display brightness.
Both these settings are stored and fetched from the in the EEPROM.

A fun little construction and a good way to learn about the DS1621.