Arduino (AtMega 328) sleep mode current consumption

Discussion in 'Embedded Systems and Microcontrollers' started by yatindeshpande77, Jan 12, 2016.

  1. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Hello guys I am using atmega 328 for my NRF24L01 project which I have to use with battery so I need to reduce current!
    I did power down in NRF module and it works fabulous!
    Now turn to reduce current through atmega328!
    Data sheet says on 1Mhz crystal I can reduce consumption upto 0.1uA but currently I am using 16Mhz as I am coding it using Arduino!
    But in the following code in sleep mode uC consumig 1mA as I checked on Ammeter, I am confused and dont no where I did wrong!
    My code is as follows:-
    Code (Text):
    1. #include <avr/sleep.h>
    2.  
    3. int counter =0;
    4.  
    5. void setup()
    6. {
    7.  
    8. Serial.begin(9600);
    9. digitalWrite (3, HIGH);  // pull-up
    10.  
    11. //pinMode (13, OUTPUT);
    12. //digitalWrite (13, HIGH);  // awake
    13.  
    14. Serial.println ("But does it get goat's blood out?");
    15.  
    16. }  // end of setup
    17.  
    18.  
    19. void loop()
    20. {
    21.   delay(1000);
    22.   if (++counter % 5 == 0)
    23.     sleepNow();
    24. }  // end ofloop
    25.  
    26.  
    27. // interrupt service routine
    28. void wake()
    29. {
    30.   sleep_disable();         // first thing after waking from sleep:
    31.   detachInterrupt (1);     // stop many many interrupts
    32. }
    33.  
    34.  
    35. void sleepNow()
    36. {
    37.  
    38.   Serial.println("SET_SLEEP_MODE");
    39.   set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    40.   Serial.println("SLEEP_ENABLE");
    41.   sleep_enable();          // enables the sleep bit in the mcucr register
    42.  
    43.   Serial.println("SLEEP_MODE");
    44.   digitalWrite (13, LOW);  // asleep
    45.  
    46.   attachInterrupt(1, wake, LOW);
    47.   sleep_mode();            // here the device is actually put to sleep!!
    48.  
    49.   //digitalWrite (13, HIGH);   // awake
    50.  
    51.   Serial.println("MCU is back in business");
    52.  
    53. }  // end of sleepNow
    Can any expert have any guidance on this
    Thanks in advance
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    The difference in operating frequency is huge when it comes to current consumption. You also need to turn off the peripherals you are not using. Just because the processor is asleep says nothing about the peripheral devices like timers, and the A/D subsystem.
     
  3. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    When we use maximum power saving (power down is maximum power saving mode in arduino) is peripheral still remain on?
    When we use power down I thought we also bypass external oscillator!!! So is it still make affect and evem if it is does it that high as I am expecting curent in few micro Amp and getting 1 mA?
     
  4. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Modern processors have more than one oscillator, and you need to read the datasheet very carefully to understand what is and is not running in low power modes. Something has to continue to run if you ever hope to wake up from sleep mode. Did you ever think about that?
     
  5. sailorjoe

    Member

    Jun 4, 2013
    361
    63
    BR-549 likes this.
  6. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    sailorjoe,
    I tried with the given link but still I am on 1mA!
    @Papabravo:- I am trying to find something from datasheet, hope I will get something new!
     
  7. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Nothing I found!
     
  8. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    So you changed the crystal from 16 MHz. to 1 MHz. and your still measuring the same power consumption?
    Are you still using the external oscillator?
     
  9. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Nope i didn't change crystal as i am using arduino it is hard to change crystal as it won't allow me to make coding!
     
  10. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Well I guess if you've done everything else to reduce power consumption then
    c'est le fin des haricot.
    Translation: This is the end of beans.
     
  11. Carlmikael

    New Member

    Aug 25, 2011
    2
    0
    Hi what kind of arduino do you use?
     
    Last edited: Jan 18, 2016
  12. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Ok I finally able to reduce my atmega328 current consumption to 16uA with 16Mhz oscillator and 3.3V,
    The problem wasnt the code actually, its strange one, I used a 1n4007 after 3.7V battery to reduce the voltage to 3.3 which was increasing my current to 1mA, As when I tested without diode it consume 16uA and with 4007 it consume 1mA! Strange, and I didnt understand why so!
    @Carlmikael:- I am using Arduino UNO for coding and testing is done on breadboard with munimum ckt, as on arduino it has regulator and other ckt which consumes current!
     
  13. Carlmikael

    New Member

    Aug 25, 2011
    2
    0
    What is the diod connected to? Is it the radio? Can you put the radio to sleep?
     
  14. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    I don't doubt your observations, but I'm not sure I understand how the diode can consume current unless it is your claim that it converts 0.4V*.001A into 0.0004 watts of heat. Had you provided us a schematic diagram at the outset the solution might have been more obvious. Why didn't you do that?
     
  15. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Here is my basic schematic!
     
    • uc.JPG
      uc.JPG
      File size:
      151 KB
      Views:
      5
  16. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    So the 16 MHz. is not even connected to the processor. It must be running off of the internal oscillator. So it appears that even your description was misleading. Your schematic has three missing pins (7, 8, & 22) on the processor and there are no obvious connections to power and ground. This is IMHO a pretty misleading schematic. Also you have no bypass capacitors.
     
  17. yatindeshpande77

    Thread Starter Member

    Dec 20, 2015
    38
    0
    Sorry I didnt have any good software so I made this schematic in proteus!
    In that software we doont get Vcc and other obvious pins!
    Vcc is connected to 7 ( terminal vcc in that picture), 8,22 to ground XTAL1 and XTAL2 to 9,10 respectively!
     
  18. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    The next problem is that you have a CMOS device with floating pins. This is almost guaranteed to increase power consumption. Good practice would be to tie unused pins high or low. I'm not sure what conclusions to draw from your schematic and your observations. I don't consider your setup to be a reliable one for making measurements of any kind. You have too many things which are uncontrolled.
     
Loading...