Friday, September 16, 2011

AVR Low Power

My RC airplane Lost Model Alarm (LMA) runs off a tiny CR1225 50mAH battery so low power operation was a must. Here's how to save power with your AVR or Arduino project.

Sleep Baby, Sleep

Let's say you want to poll a sensor periodically (think weather station, timer, etc). The MCU doesn't need to run continuously. You can make use of AVR sleep modes to save power.

AVRs can put themselves to sleep and will wake up under certain interrupt conditions. You can use timer/counters to fire interrupts to wake up the chip or use the watchdog timer to do the same.

The Lost Model Alarm goes into full sleep mode; the MCU and every peripheral is off until the watchdog timer wakes up the processor every second.

void enableWatchdog()
	// Enable watchdog interrupt, set prescaling to 1 sec
	WDTCR |= _BV(WDTIE) | _BV(WDP2) | _BV(WDP1);

  //do stuff here



Slow Down

If your processor doesn't need turbo speed, why use it? Higher clock speeds burn up power. You could set the AVR clock with fuse bits but flashing new firmware is a pain. So get the best of both worlds. Set the fuse bits for normal fast clock operation but, once the AVR starts up, your code tells the MCU to slow down the clock to a miserly speed.

I run the LMA's AVR at 9.6MHz but slow down to only 150kHz after the code initializes. Don't forget to redefine F_CPU in your code!

// 150kHz
void slowClock()
	CLKPR = _BV(CLKPS2) | _BV(CLKPS1); // scale = /64

Low Power Circuits

Use the 80-20 rule to reduce current draw from designs.

When you're talking about microamps, the whopping 10-30mA draw of an LED is ghastly huge. Ditch the LEDs from any low power circuits.

Select components that minimize current draw. Choose low power versions of devices. For example, a CMOS 555 timer instead of a standard 555. Use high efficiency switching regulators (or no regulator) instead of linear regulators. In my case several buzzers were available with < 5mA current draw requirement and one with only 1mA draw so I chose that one.

Make sure voltage dividers have high enough resistance to minimize current. Leave MCU pins low or better in high impedance mode. Avoid circuits that default to a state that draws substantial current. For example, some transistor circuits, logic gates for certain logic families, etc.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.