Wednesday, September 15, 2010

Water Pipe Anti-Freeze Heating Take 2


With winter approaching I decided to simplify my water pipe anti-freeze system. The initial project here used an ATMega8 and an I2C thermometer. I replaced that with a single DS1821. This small device looks like a transistor but is actually a thermometer chip capable of standalone thermostat operation once configured via 1Wire.

The DQ pin becomes a thermostat output pin, which in my case is then used to control a transistor which switches the Heating On LED and an optocoupler which then switches the ATX PSU. The system looks exactly the same from the outside and I'm not taking pictures of the inside as it's basically just the schematic above implemented on a piece of stripboard with the DS1821 at the end of some telephone cable running a few meters under the insulation putting the thermostat where the yellow tape is on the picture below.


Note that the DS1821 is NOT a MicroLAN capable device, it doesn't support the protocol required for MicroLan enumeration/operation. It also cannot be connected to my 1-Wire MicroLan modded Fonera. To program it I used an ATTiny2313 and some ugly hacked-together piece of BASCOM code. The 1821 has to be hooked up according to the pins configured in the code (the bottom 3 pins on the left side of the chip by the way, I basically just put 3 pins from an ic socket there to hot-swap the devices.) pullups then need to be added to DQ and Vcc(4.7kohm will do). Also configure the fusebits to use the internal osc of the ATTiny with the clock divider disabled, setting it to run at 8MHz.

The ATTiny's UART then needs to be connected to a PC. To program first issue a read command.

>read
temp:0
conf:84
TH:10
TL:5

This device is already configured for my pipe-heater. The temp will be 0 because we haven't issued a Start command to the chip. For info on the conf register byte consult the datasheet.
TL is the low threshold TH is the high threshold.

the set command configures the device. It'll just ask for TL and TH, then print out the read-back values for verification.

>set
TL:5
TH:10
5
10

deploy then ends the configuration of the device

>deploy
POL1
Thermo1

POL is the POL bit in the config register. It determines whether the Thermostat output is active-low or active-high. Simply put: you use POL0 for heating and POL1 for cooling.

Thermo1 actually switches the device over into standalone thermostat mode. If you set 0 here the device will remain in 1Wire mode.

When the device is in thermostat mode it can't communicate over 1Wire anymore unless a specific reset sequence is performed. The read command in the code automatically performs this sequence if the device doesn't respond. It will mark this with ".." so if you see .. .. .. .. it means the device isn't responding despite that and you should check your connections :)

As always, leave a comment if you end up building this.

No comments:

Post a Comment