Thursday, January 17, 2008

An Accurate PIC-based Large-display Thermometer


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).

About Time

Apparently it's about time I got a blog, so here it is. I probably won't add much to it as I generally think there's already enough crap online. It's worse than free to air television and that's pretty bad.

Speaking of time I saw an ad today (don't I everyday?) for Newscientist magazine's latest issue due on the newstands tomorrow. It contains an article discussing that time may be an illusion. This got me thinking and more often these days I turn to the 'Net to see what's out there on the topic. I found this interesting blog entry and felt the need to comment. Which in turn led me to start this blog dammit.

After some thought/meditation on this, my thoughts are that time probably isn't an illusion per se, but certainly something weird is going on. I suspect that past/present/future possibly do exist all at once but only if viewed from another dimension (meaning?), or perhaps "outside of" our universe - if there is such a place (for another discussion).

My interest in all this was sparked today by my reading of The Invisible Century by Richard Panek (a Christmas gift). Not a bad read if your into science history with some coincidences thrown in for good measure.

I've often thought about time. It can be considered in some ways our enemy, but it can also be on our side. I remember my physics teacher at High School saying on the subject "time is because things happen". He was referring to physical events of course. I immediately thought - if *all* motion in the universe stopped, would time cease to exist?! According to the blog I referred to earlier space-time exists only because both space and time exist so if everything stopped moving would space-time (i.e our universe) cease to exist? If that's the case then our universe depend on motion for its very existence. Yet for motion to exist there has to be space and time because motion is distance (space) travelled over time (i.e v=d/t). Hmm this is awfully circular. If time is illusory then it follows that motion is also, and so is the space-time that underpins our universe! Hmmm