Pages: [1]   Go Down
Author Topic: How to achieve lowest power consumption.  (Read 776 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am build a project and I would like to run it off a single Li Ion battery ( 3.7v 900ma) and have it last months or longer on a single charge.
Basically I would like it to "wake up" every minute or so and check an input and then goto sleep if input is still low.
If input is high then program would run for as long as required then shut down when input goes low again.
I would also like to have an input that when ever pressed will wake it up.

So.. can an Arduino mini pro be put to sleep? ( so to speak) And how?
If so how much current will it draw?
If no how much current will it draw? ( I am more than happy to remove the "power" LED
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26359
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, Atmega328 can be put to sleep.
I don't know about non-hardware wake ups, these bits will do a lot of the rest.
Make sure to set your unused inputs high or low, don't leave them floating.

#include <avr/sleep.h>      // powerdown library
#include <avr/interrupt.h>  // interrupts library

Hardware interrupt to wake up
//***************************************************
// *  Name:        pin2Interrupt, "ISR" to run when interrupted in Sleep Mode
void pin2Interrupt()
{
  /* This brings us back from sleep. */
}

//***************************************************
// *  Name:        enterSleep
void enterSleep()
{
  /* Setup pin2 as an interrupt and attach handler. */
  attachInterrupt(0, pin2Interrupt, LOW);
  delay(50); // need this?
  /* the sleep modes
   SLEEP_MODE_IDLE - the least power savings
   SLEEP_MODE_ADC
   SLEEP_MODE_PWR_SAVE
   SLEEP_MODE_STANDBY
   SLEEP_MODE_PWR_DOWN - the most power savings
   */
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);  // setting up for sleep ...
  sleep_enable();                       // setting up for sleep ...

    // Disable ADC
  ADCSRA &= ~(1 << ADEN);

  // Power down functions
  PRR = 0xFF;

  sleep_mode();                         // now goes to Sleep and waits for the interrupt

  /* The program will continue from here after the interrupt. */
  detachInterrupt(0);                 //disable interrupts
 
    // Power up functions
  PRR = 0x00;

  /* First thing to do is disable sleep. */
  sleep_disable();

  // then go to the void Loop()
}

***********************************************************************
// set up the pins as Inputs, Outputs, etc.
void setup()
{
  /* Setup the pin directions, write inputs High to turn on internal pullups */
  pinMode(pin2, INPUT);                 // our sleep interrupt pin
  digitalWrite(pin2, HIGH);
}
void loop()
{
  if (sleep_count>1000){                      // check if we should go to sleep because of "time" --> Try shorter versions of this
    sleep_count=0;                           // turn it off for when we wake up
//    Serial.println("Sleep");               // for debug only
 
    enterSleep();                             // call Sleep function to put us out
   
                                              //  THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep()
  }                                           // end of checking to go to sleep
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

excellent

Thanks for that.

Will inspect and digest code later.
So how much current will it consume?
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26359
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are running the LiPo battery direct to the Vcc pin, bypassing the regular, and you remove the power LED, consumption will be pretty low:

Low Power Consumption at 1 MHz, 1.8V, 25°C for ATmega48PA/88PA/168PA/328P:
– Active Mode: 0.2 mA
– Power-down Mode: 0.1 μA
– Power-save Mode: 0.75 μA (Including 32 kHz RTC)

A little higher at 8 Mhz (3.3V Promini). I have an RF Remote that I put in sleep mode. Kept the LED, has an RF Tx module that draws a little also, and a MAX1811 battery charge control chip that draws a little, charges it up from a 5V source. Flashes an LED when I press a button.
1000mAH LiPo goes about a month before I don't see an LED flash anymore.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I did some tests of low power mode here:

http://www.gammon.com.au/forum/?id=11149

I didn't exactly get such low figures though. However this was using a 16 MHz resonator.

I got about 25 μA when asleep. However to wake it up you need the watch-dog timer (unless you have some external interrupt source).

According to the Atmega328 spec on page 381, using the watchdog timer significantly increases power consumption (eg. from about 0.1 μA at 5V at 20 degrees to about 6 μA under the same conditions).

Dropping the clock rate and the supply voltage looks like it would help somewhat.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So feeding power into VCC instead of RAW will bypass the on board regulator and the board will consume less power?
But then the VCC will have to be 3.3volt? or can I still feed upto 4.2 volt into it?

While a months sounds like a long time I would prefer 6 months stand by time if not more.

I will also be using a LM 348 Op amp. Can I power this via one of the digital outputs so it does not draw current while asleep?
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 197
Posts: 12743
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


@Nick: Did you do anything to keep the unused pins from floating?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Nick. That looks promising.
clock speed is not an issue at all.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Nick: Did you do anything to keep the unused pins from floating?

No, although I turned off the ADC in software.

I will also be using a LM 348 Op amp. Can I power this via one of the digital outputs so it does not draw current while asleep?

Certainly. I powered an entire clock board from a digital output to turn it on and off as required.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Avtel have a writeup on Pico Power Basics. I have written some stuff about power saving using sleep modes and the watchdog timer in my blog, but I'm still learning. So keep an eye on my Arduino notes   smiley-red
« Last Edit: August 19, 2011, 07:28:18 am by ManicDee » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 518
Posts: 26359
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"So feeding power into VCC instead of RAW will bypass the on board regulator and the board will consume less power?
But then the VCC will have to be 3.3volt? or can I still feed upto 4.2 volt into it?"

Yes. Board will run at 8 MHz from Vcc from ~2.5V up to 5.5V; see section 29  of the datasheet. I do not regulate it at all, just whatever the LiPo battery puts out.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17261
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just be sure to research the Arduino BOD fuse setting and adjust as appropriate. Li-po useful discharge voltage range is 4.2 down to 3.5, under that cell can be damaged due to over discharge.

Lefty
Logged

Pages: [1]   Go Up
Jump to: