Friday, September 17, 2010

Standalone DS1821 thermostat programmer



As a continuation of the previous project I decided to make a standalone gadget to program DS1821 thermostats. As mentioned before these devices are non-MicroLan 1wire thermometers capable of standalone thermostat operation. After configuration for thermostat mode the center (1Wire DQ) pin becomes a thermostat output pin. Since it's still an open collector pin it needs a pull up resistor, and since it's still basically a 4mA GPIO a transistor at least is needed to switch anything meaningful with it.

I've used the ATMega8 "devboard" that I used in the v1 heating cable thermostat. Made a plug in board for that (don't call it shield) with a couple of TIL311s, 3 buttons, some pullup resistors and a socket for the 1821s.


On the underside is an incredible mess of cables that I'm not going to show.
Buttons are Up, Down and OK

First it asks for the TL, then the TH 1 digit each (settable 0-9).
Then it'll display A0. with the 0 being switchable between 0 or 1. This is the POL (0 for heating 1 for cooling thermostat)
B0 similarly is the thermostat mode (0 = 1wire sensor 1= thermostat)
C0 is the negative setting. Since I'm only using 2 displays this is how I'm handling negative entry.
C0 = neither value is negative
C1 = TL is negative
C2 = TH is negative
C3 = Both are negative

Once OK is pushed here it'll program the settings and display 00
That's it!

Spaghetti BASCOM code can be found here

Any latching BCD display could be used in place of the TILs, these are just what I had lying around. Hookup can be determined from the source code. I have no schematics or pcb as I was just hooking stuff up on the fly and coding to adapt. Pullups needed for buttons and the 1wpwr and DQ pins. Most delays in the code are probably not needed.

UPDATE:

Congrats if you've read this far. Two things I'd like to add. This is a sideproject from the more useful application of the DS1821: Keeping my pipes from freezing in during the winter.

And I actually made two videos during the making of this that I didn't include because well.. They're dark and boring and I didn't think another blog(HackedGadgets) would pick up this particular project. Thanks Alan.
Well, here they are. If you're wondering no I didn't record it in the dark. Actually, the room was blasted with four 40W CFL tubes. This is just how bad my point-and-shoot is.

First one's just testing out the TILs counting 0-F on each. (and I called it shield.. d'oh!)





Second one shows the programmer working



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.

Wednesday, September 8, 2010

USBasp



Just made an USBasp. It's a USB AVR in-system programmer project by Thomas Fischl. Used the PCB by J.A. de Groot found on the USBasp project page. Had to add 2 missing zeners, but other than that the build was straightforward and problem-free.
This programmer handles USB communication in firmware on an AtMega8 or 48.


Tested with ATTiny2313 and ATMega8 sofar. Works fine.



No need to bother with the LPT port anymore.