펌웨어디자인(Firmware Design)

온도제어기

arirangled 2008. 11. 11. 18:01

 

Temperature Controller
http://www.myplace.nu/avr/index.htm

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.

Comments are always welcome at jesperh@telia.com

View schematics

Download C-code

Click on each of the pictures to see in in a larger size.

This is how the controller box look.
It's a plastic box with a transparent (but slightly tinted) lid.
The display is clearly visible, but to adjust the switch temp or other parameters, the lid have to be removed. This is easily done due to the "handles" on the plastic screws.


An inside view of the controller. It's build on a standard 0.1" experimental board. The electronics doesn't generate much heat, but it's enough to keep the inside of the box about 15 degree Celcius above the ambient temperature.
 
 

반응형

'펌웨어디자인(Firmware Design)' 카테고리의 다른 글

AVR 마이크로컨트롤러설계도구  (0) 2008.11.11
AVR USB AT90USB162 마이크로컨트롤러  (0) 2008.11.11
AVR ATMega128  (0) 2008.11.11
5인치표시온도계  (0) 2008.11.11
적외선무선제어조광기  (0) 2008.11.02