Computing stuff tied to the physical world

Sleep!

In AVR, Software on Sep 1, 2010 at 00:01

The “powerdown_demo.pde” sketch in this recent post draws 20 µA, which surprised me a bit…

A while back, I got it down to a fraction of that, by turning off the brown-out detector (BOD) through a fuse bit on the ATmega. That’s a little circuit which prevents the ATmega from coming out of reset and doing anything if the voltage is too low.

As it turns out, you can turn off the BOD in software, but only for sleep mode. The reasoning being that there’s no point in protecting the processor from going berserk while it’s not doing anything in the first place…

Well, my code to turn off the BOD was wrong. You have to do this right before going to sleep. Here’s the updated powerdown_demo.pde sketch:

Screen Shot 2010 08 28 at 12.50.18

(correction – I mixed up my bits: change “PINB |= …” to “PINB = …” or “PORTD ^= …”)

The result?

Dsc 1872

Now we’re cookin’ again!

  1. You’re not gonna cook anything at 3.3µA! Not without getting a 115KV feed to your house! :-p

    Is it just me, or does 3300nA sound way cooler?

  2. The “zzzz” part of your sketch can be reduced to three macro calls (defined in avr/sleep.h) with the additional advantage of being portable across the whole AVR family (some models use different register and bit names):

    sleep_bod_disable(); set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_mode();

    Oh – and I think the blinker should use “PORTB ^= bit(1)” inside the loop.

    • Ah, thanks for that tip! I’m moving the generic low-power code to the Ports library, will switch to those macros. There’s also a note in the avr-libc docs about a race condition. Might explain why using the RFM12B’s watchdog failed occasionally.

  3. WFT 3.3 uA? Awesome:-) Checking out the BSOD thingy was on my todo list. I thought I could only disable it via the fuses. This was one of the reasons I ordered your flash board:-)

    If this works out then my non-motion room nodes will last 25 years on the omnicel 3.6V batts. Perhaps the world is not even there anymore in 25 years… better add some more power consuming sensors to my nodes;-)

  4. Stef, I hope you are going to leave battery changing instructions for the generations to follow!

Comments are closed.