I've been on my annual long holiday (4 weeks!) and have had time to catch up on a few things.
I finally got around to re-doing the digital thermometer I built during last years holiday. I've been using it on and off - literally, because the batteries had a short life. It's weird because the seven segment LCD and driver chip it's based on, draws very little current (less than 10uA), so I always suspected the PICAXE 08M chip that I use for the microcontroller. After some investigation it turned out there were a number of things I could do to significantly reduce the power draw.
Firstly I built the circuit to run off a 9V battery so I used a 78L05 regulator - bad move, even when bypassed it draws about 1.2mA! So I changed to 3x 1.5volt AA cells (~4.5v) and removed the regulator altogether. Then I discovered the Dallas DS18B20 digital temperature sensor can draw a fair amount, so I connected it to a port on the PICAXE and I now software-control the power to it. I switch it off when not in use. I also tied all unused port pins to either vss or vdd, saving a few more microamps. I now had the current draw down to about 70uA (0.07mA) during times when there was no temperature reading occurring. The next thing I found was that the PIC chip (the PICAXE 08M is actually a PIC 12F683) will draw ~50uA less when the brown-out detector is disabled during sleep.
Woohoo, I now have my thermometer drawing a total of 12.7uA (yes microamps), for about 15 of every 17 seconds. The other 2 seconds it draws ~1mA. This 2 seconds is where the micro wakes up (kicked by the Watchdog timer), turns on the DS18B20, reads the temperature then turns off the DS18B20, updates the LCD, then goes back to sleep for ~15 seconds. One problem with getting to here was that although with the PICAXE 08M you can disable the brown out detector (disableBOD command) - that only works with firmware version 9.2 or better. My 08M's are all the original ones with 9.0 firmware - doh!
So I re-programmed the whole thing using PIC assembler! This was a whole other little journey that took the best part of a week given that I was kinda relearning PIC assembler along the way. A couple of times I referred to this tutorial, which I found useful. Although the data tables on tutorial 10 got me into trouble. When the table was located across address 0xFFH - the ADDWF instruction only handles 8-bit numbers, so the jump-to address "rolled over" and the PCL went back to 0x00h! Took a few hours and a good PIC simulator to find out what was going on.
The 7 segment LCD display is an old surplus part I had from when I worked for a fuel dispenser manufacturer some years ago (it's known as an FRS1320PH). The driver chip for it is a Motorola MC145453 LCD Driver with Serial Interface. The micro is a PIC 12F683 (it's only a tiny 8 pin package). Temperature sensor is a Dallas DS18B20 which uses the 1-wire protocol. Speaking of 1-wire I also found the code here useful for saving some time and getting the 1-wire stuff to work properly in PIC assembler (I already had all this working in PICAXE basic).
No comments:
Post a Comment