Tuesday 17 July 2012

Frankenstein's Thermometer Mk2

Well it's been just over a year since this blog started and what better way to celebrate than revising an old project? I'd had a look at Frankenstein's thermometer before, using a neat trick with a mono jack plug and a stereo socket to switch the power. However I wasn't really pleased with this arrangement, because it separated the thermistor from the main box when it wasn't in use.

The idea was to upgrade the firmware to put the ATtiny into deep sleep after a short time. The complete code is now:

The main additions are:
  • the sleep() routine which causes the ATtiny to enter a power-down mode,
  • the PCINT1_vect which wakes it up again when the push-button is pressed.
The port PB1, which the push-button connects to ground, generates PCINT9. On the ATtiny84, there are two pin-change interrupts, PCINT0 and PCINT1. The former handles pin change signals on Port A, while the latter handles those from Port B. Our handler simply checks whether the interrupt has woken us up, or was to change the units of temperature.

The sleep routine switches off all of the LEDs and the ADC before putting the ATtiny to sleep. When it wakes up again, the ADC must be re-enabled.

With the new software installed,  the device consumes about 11mA when on but 0.16mA when off. With a nominal capacity of 1000mAh, this would drain the batteries in about 6000 hours (or 250 days). This was a bit surprising, as was the discovery that this current was still drawn when the AVR was removed altogether. This indicated that the source of the drain was the voltage divider comprising the thermistor and a 10k resistor. (See the circuit diagram in the original posting.) At room temperature, the current drawn would be 3v/20k or 0.15mA.

Rather than complicate the circuit with a MOSFET switch, we decided simply to increase the value of the bias resistor from 10k to 47k. This reduced the current by a factor of 4 increasing the battery life to over 2 years. (The calculation of the Thermistor equation has been cleaned up a bit too: the original made the assumption that the 10k resistor would cancel the thermistor's resistance at 25C.)

No comments:

Post a Comment