Notes on using a 16F628A and a DS1820 temperature sensor.
Working on the C framework in sourceboost, tonight. I use the oo.h stuff from the web, customized my LCD_lib.c routine and ended up with the following stuff:
- temp.c - main C file
- oo.h - included in temp.c, defines the port/pin for the one wire
- temp_defs.h - definition file, contains all the #define statements
- LCD_lib.c - LCD library file, home grown and based on the sourceboost lcd.h file. Contains all the library routines. This is VERY dependent on the PIC wiring.
- oo.c - included in the project, contains the one wire functions. I stripped out all the eeprom and serial stuff.
Used the standard wiring for the PIC-EL and put the DS1820 on pin 2 (RA3).
The 'shell' files all compiled and I'm starting with 70% free words with 190 bytes of free ram.
--Stu 21:38, 7 May 2007 (EDT)
LCD works using my home grown library.
Spent hours trying to troubleshoot the 1-wire bus. I was thinking about get a logic analyzer from the web. Instead, I obtained a logic analyzer from the Dayton hamfest. (HP1664 for $175) Works great! (unlike the 475 I bought) Used it to troubleshoot the 1-wire bus. Using the datasheet, I stepped through the code and looked at each bit on the 1-wire bus. I discovered, the oo.h/temp.c files were missing a bus reset before reading the scratchpad of the 1820. Once I issued the reset command (one line!), everything worked.
I also had to do a little math to convert C to F. The DS-1820 outputs degrees C with 0.5 resolution using 9 bits. Since the pic does integer math, I multiplied both sides of the equation by 10, then taking into account the raw reading is actually X 2, the final equation looks like:
[(Raw/2) X 9/5 + 32] X 10 = 10F F = [(Raw X 9) + 320 ] / 10
--Stu 09:57, 3 June 2007 (EDT)
Wiring (from: http://xtronics.com/reference/thermostat_wires.html)
Red - 24VAC Yellow - Cooling Call (Close to activate) White - Heating Call (Close to activate) Green - Fan ON (Auto = open, On = closed)