Low-power interrupt generator

atmegainterruptslow-powersleep

My objective is to generate an interrupt on an Atmega328P processor every second or so, using substantially less average current consumption than the inbuilt watchdog timer.


You can see from the datasheet that with the watchdog timer enabled the current consumption at 5V and 25 °C is around 6.5 µA:

Current with watchdog enabled

With it disabled we are down to around 100 nA:

Current with watchdog disabled

Something in-between, say 1 µA, could result in substantially longer running from a battery, but still allow the processor to wake up and check for things like the current light level, temperature, that sort of thing.


I've been experimenting with this:

Watchdog circuit

The idea is that the capacitor will be charged quickly (50 µs) through the resistor which limits current to around 22 mA (assuming 5V operation for the moment). The output then goes to high-impedance, and we wait for a falling interrupt to wake the processor and deal with it.


Test code:

const byte capacitor = 2;
const byte LED = 13;

volatile byte fired = true;

void myISR ()
  {
  digitalWrite (LED, HIGH);
  fired = true;
  }

void setup() 
  {
  pinMode (LED, OUTPUT);
  attachInterrupt (0, myISR, FALLING);
  }

void loop() 
{
  if (fired)
    {
    delay (1000);
    digitalWrite (LED, LOW);
    digitalWrite (capacitor, HIGH);
    pinMode (capacitor, OUTPUT);
    delayMicroseconds (50);
    EIFR = bit (INTF0);  // clear flag for interrupt 0
    pinMode (capacitor, INPUT);  // high impedance
    digitalWrite (capacitor, LOW);
    fired = false;
    }  // end of if fired
}

This code does not have the sleep code in it, it isn't really relevant to the question.


Testing indicates that this gives a delay of about 970 ms from when I start charging the capacitor, to when the interrupt fires, which is about what I want.


The questions

  • Is this the best way (or at least a reasonable way) of generating a timed wake-up signal with minimal power consumption?

  • I calculate that the average consumption would be:

    22 mA / (1 / 50 µs) = 1.1 µA
    

    Does that look correct? Or is it even less as the capacitor would take less current as it charges? Like, approximately half that?

Best Answer

Not only is this scheme supply voltage dependent as you've noted, but it also depends on the precise atomic-level geometry of the input transistors, specifically their leakage and voltage threshold.

If you want even lower power than the WDT then you should consider using a watch crystal and the asynchronous timer. The datasheet puts typical power consumption for this method at 0.8µA at 1.8V and 0.9µA at 3V, making an extrapolation of 1.1µA at 5V very reasonable.