Computing stuff tied to the physical world

Power consumption – more savings

In AVR, Hardware, Software on May 16, 2009 at 00:01

Let’s get that JeeNode power consumption down

The no-savings baseline from two days back was 10 mA, with a few simple measures getting it down to 1.31 mA, i.e. waiting in idle mode with the pre-scaler set to 64 and turning the RFM12B clock off.

It turns out that the ATmega328 is quite a bit more power efficient in that mode, the same sketch consumes 0.67 mA, i.e. half that of an ATmega168. Great – that’s an easy gain. Unfortunately it doesn’t carry over as much to power down mode: 125 µA versus 137 µA. There is still some unexplained power use there – maybe some of the circuits need to be turned off explicitly, or some more output pins floated.

Anyway, the next idea to go beyond 1.31 mA is to use the watchdog timer for idling away in power down mode. The basic code structure will be as follows:

Picture 1.png

Ooh, wait – turns out that there is a simpler way, which doesn’t require changing the main application logic after all. We can let the watchdog generate an interrupt without resetting the system. Here’s the code I ended up with after some experimentation:

Picture 2.png

Note the added dummy watchdog interrupt routine. Without it, the code apparently enters a nasty infinite loop when the watchdog fires, which is hard to get out of – even after a hardware reset.

Usage: 139 µA while waiting – 99% of the time. Great.

The code can actually be streamlined a bit – simply leave the watchdog running to pull the processor out of power down mode once a second:

Picture 4.png

But there’s more. The ADC can be disabled to reduce the power drain even further:

Picture 5.png

Now usage drops to 24 µA while waiting. Cool.

One last change is to disable the brown-out detection, which in turn disables the internal voltage reference. Changing the high fuse from 0xDD to 0xDF drops total power usage to a diminutive 6.8 µA. Perfect.

So there you have it – 1500 times less power usage!

Update – see the discussion in this post for a change which gets this down to 3.7 µA …

Update 2 – changed the low fuse from 0xFF to 0xEE, i.e. 64 µs start-up i.s.o. 1+64 ms (ok for resonator, not ok for a crystal). This will help get the power up duration down once I start looking into it.

  1. I really like your site and commitment to this project. nice powersaving, can a node run on a battery now?

  2. Great stuff! Checkout the battery life calculator excel spreadsheet found here http://www.xbow.com/Support/wAppNotes.aspx

    Should give a good indication on what the battery life will be.

  3. To prevent the compiler from generating push/pop boilerplate code that is unneeded for the dummy ISRs, you can define them like this:

    ISR(WDT_vect, ISR_NAKED) { reti(); }

    This reduces the memory and CPU footprint of the ISR by a factor of 10.

  4. Now you need an easy way to monitor battery voltage for your nodes now they are running silent on a whiff of an electron…..been researching this myself just today and looks like you can use the ADC to read the internal reference no external components (have not tried this yet myself):

    BATV = VREF * ADC_FS/ADC_Count

    where: BATV = battery voltage VREF = internal voltage reference = 1.1v for 168 ADC_FS = ADC full scale count = 1024 ADC_COUNT = actual ADC reading of internal reference by reading ADC channel 9 (1110)

    ….and amazing what you can find when reading the tech manual, it looks as though you can use a variation on this to also use the voltage reference as a temperature sensor (p261 in the reference manual) I wonder how accurate it is?

  5. Yes I’ve been following HOPERF site and waiting for their new modules, their documentation does not have any physical sizes or footprints yet (last time I looked), but is an interesting read, lots of registers to play with!

    It looks like they are releasing them around June, I wonder how pricing will be? Maybe their RFM12B modules will drop in price (here’s hoping anyway)

  6. I found a better battery calculator found here in the downloads area http://www.silabs.com/support/pages/support.aspx?ProductFamily=EZRadio (might need to register to D/L)

    These guys make the chip that the RFM12B is based on, their documentation and examples are much better than HOPERF.

  7. Great tip -thanks!

  8. Thx. Yep.

  9. Thx – good to know.

  10. Exactly, since the ADC is variometric you need a fixed voltage to compare against. Note that I’m using a low-drop voltage regulator which takes 0.1..0.2 V but can gracefully follow a voltage dropping below 3.3 V. Only problem could be the 16 MHz resonator I’m using – may have to run on 8 MHz for voltages much lower than 3.3 V.

    FWIW, there’s a new RF23 module (not yet released) which includes a temperature sensor and battery voltage readout, so that could become another option in the future.

    My plan is to use 3 AAA cells (at least initially), which will stay above 3.3V for a long time.

  11. Looks excellent indeed. Yes, I have the Silicon Labs docs, though I find the HopeRF docs ok as well.

Comments are closed.