Pages: [1] 2 3 ... 5   Go Down
Author Topic: Atmega328p Power Saving Techniques  (Read 5282 times)
0 Members and 1 Guest are viewing this topic.
USA
Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I wondered if any one has successfully gotten the atmega328p power consumption down to nanoAmps. I'm currently following Nick Gammon's power saving technique for the atmega328p and got the current down to about 0.40mA (400 microAmps) but couldn't any lower.

Here's a link to his site: http://www.gammon.com.au/forum/?id=11497

I'm between Sketch C and D in the link and reading 0.40mA after by turning ADC off. I should expect a huge power reduction according to his method, but I'm not. I don't know if I'm missing any steps leading up to that reduction, but if you could help, that'll be fantastic!

Thanks.

Here's my setup:

- AVRISP MKII as programmer to atmega328p on breadboard with 5V external power to breadboard.
- Atmega328p has an external 16mhz crystal
- Arduino v1.0.3
- Windows 7 x86

Here's the sketch:

Code:
#include <avr/sleep.h>

void setup ()
{    
  // disable ADC
  ADCSRA = 0;  
  
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  sleep_enable();
 
  // turn off brown-out enable in software
  MCUCR = _BV (BODS) | _BV (BODSE);
  MCUCR = _BV (BODS);
  sleep_cpu ();  

}  // end of setup

void loop () { }

Moderator edit: [code] ... [/code] tags added. (Nick Gammon)

« Last Edit: April 02, 2013, 11:58:37 pm by Nick Gammon » Logged

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

I tried that exact sketch on my bare-bones board (the one used in the article) and the power consumption was around 100 nA.

How are you measuring the current? Are other devices drawing power, eg. voltage regulators?
Logged

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

I'm measuring with a digital multimeter with the lead pins connected in series with the 5V supply line on microAmps notch. The power is supplied by the arduino uno's 5v and GND slot to the breadboard with the atmega328p. The only pins connected to the chip comes from the AVRISP mkii pinout for uploading sketches.

At first I thought the AVR programmer was drawing current, but after taking it out, it stayed relatively the same.

The pins out from the atmega328p are:

- pin 6 (VCC) to 5V
- pin 7 to GND
- pin 8 and 9 to 16mhz crystal with two 22pF to GND
- pin 14 (AVCC) to 5V
- pin 16 to GND 
Logged

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

What multimeter? You might be at the limit of its resolution.
Logged

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

This multimeter:

http://www.amazon.com/Sinometer-Manual-Digital-Multimeter-MS8268/dp/B000JQ4O2U/ref=sr_1_5?ie=UTF8&qid=1364966950&sr=8-5&keywords=multimeter

I didn't change the extended fuse using avrdude. Is that why I couldn't get the power that low? I used your sketch C instead. Or is it because of the external 16mhz crystal? I imagined it wouldn't be much of a difference. In your research, were you using an internal 8mhz clock?
Logged

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

These are my fuse settings for the test I did an hour ago:

Code:
LFuse = 0xE2
HFuse = 0xDF
EFuse = 0xFF

So that was using the internal oscillator, however I don't think it makes much difference once it is powered off. My brown-out detection was off in the fuse, but that shouldn't matter.

I just changed the extended fuse to 0xFB (which is 4.7V BOD) and still got 116 nA current draw.

I can't find the specs for your meter. Did you get a manual? What does it say about the milliamps range?
Logged

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

Okay, so it's not really the fuses or the oscillator then (knowing that 8mhz consumes less power than 16mhz). But I'm going to try and burn the fuse and set to the internal oscillator and see what happens.

Here's a link to the manual: http://www.panda-bg.com/datasheet/646-340035-Multimeter-MS8268.pdf
Here's a youtube video:

All the way down the manual page, here's what it said about mA DC current:

Range  | Resolution | Accuracy
400µA  | 0.1µA       | ±(1.2% of rdg+3 digits)
4000µA | 1µA
40mA   | 0.01mA
400mA | 0.1mA
10A     | 10mA        | ±(2.0% of rdg+5 digits)

Overload protection: F 10A/250V fuse for 10A range.
Resettable fuse(F400mA/250V) for µA and mA ranges.
Maximum input current: 400mA dc or 400mA ac rms for µA and mA ranges, 10A dc or 10A ac rms for 10A ranges.

For measurements>5A, 4 minutes maximum ON to measure
10 minutes OFF.

Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Something from SainSmart... isn't very smart. Radio shack sells a better product.. that aside.. for now
Quote
 
    Range  | Resolution | Accuracy
   400µA   | 0.1µA       | ±(1.2% of rdg+3 digits)
The lowest scale only has a resolution of 100 nA + 3 digits, which 3, I wonder.
Prior to digital panel meters, D'Arsonval analog panel meters were used exclusively for measurements and most engineers used the 20% rule because of a particular non linear response of the meter and the resistors required for a best fit for overall accuracy. This made the first 20% and the last 20% the least accurate area's of a meter due to those factors and were avoided by those who knew to get the best of their test equipment.
Unfortunately trying to make a measurement of 100 to 500nA with a device with 400uA F.S. +/- 1.2% FS and +3 digits of stated error is not a very good idea.
For the same reasons..
and the required minimum resolution simply isn't there... 100 nA / 400 uA = 0.00025% of F.S.

Bob
« Last Edit: April 03, 2013, 02:58:57 am by Docedison » Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

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

I'm between Sketch C and D in the link and reading 0.40mA after by turning ADC off. I should expect a huge power reduction according to his method, but I'm not.

What reading do you get? You say it is "not" a huge power reduction, but was is it?

Quote
400µA  | 0.1µA  | ±(1.2% of rdg+3 digits)

First, the resolution is 100 nA so you will be pushing it to determine the difference between 100 nA and (say) 300 nA. Then there are the +3 digits. That means, I believe, that it could read 0.4uA when it is really 0.1uA.

Plus, the meter may not be as accurate as it claims. I'm going to try to set up a test which doesn't rely on the meter microamp accuracy so much.


http://www.designworldonline.com/how-to-determine-digital-multimeter-accuracy/#_
Logged

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

It's fiddly to prove the figures another way, but I think I have done so now to my satisfaction. smiley

  • Put a 1M resistor in series with the power to the board.
  • Put a meter across this resistor to measure the voltage drop over it.
  • Temporarily short out this resistor with a lead with alligator clips or similar.
  • Turn on the power and let the board "boot" and go into sleep mode.
  • Remove the short across the resistor
  • Take a reading of the voltage drop

I read 105 mV drop over 1M. Now using Ohm's law:

Code:
I = V / R

I = 0.105 / 1000000 = 105 nA

So this more or less agrees with my reading taken a different way of 116 nA.

You need to short the resistor initially or there is too much voltage drop across it, and the chip doesn't boot properly or at all.

Be warned, I was initially measuring the overall voltage (ie. the voltage to the board) but simply measuring it increased the current from 100 nA to about 600 nA. So there's a trap! Measuring things changes what you are measuring.
Logged

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

Ah, you both are right about the multimeter's inaccuracy at the nanoAmp level. But the thing is, the measurement is not even in the nano range yet, and barely into the micro range. I'm currently measuring it on mA notch, reading 00.38mA and when switched to µA, it reads 380.0 µA. Also tested it using a suckier multimeter with the same result.

Between sketch C and D, I'm reading 0.40 mA (400 µAmps). With ADC off, it reads 0.38mA (380 µAmps). I have burn the fuse and set to 8 MHz, yet the power consumption is still at 0.38mA:

- low_fuses        =  0xE2
- high_fuses       =  0xDF
- extended_fuses = 0x07
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 46
Posts: 2865
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Lefty says that a lot... and your error is the same percentage of F.S and the last digit error of +3 digits little has changed you as still trying to measure in the mud.
Use Nick's technique.. 100 mV is a lot more accurate than .38 mA @ 4 mA F.S. In the event that it isn't your meter you do have a better means of monitoring the voltage.

Bob
« Last Edit: April 03, 2013, 03:43:08 am by Docedison » Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

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

I started getting a bit obsessed about why I got 105 nA one way and 116 nA another way. So I used the meter that gave the 116 nA current rating, and this time got it to do the voltage measurement. It came in at 116 mV, so at least it's consistent. Whatever internal reference it uses, is consistent across volts and amps.

Quote
I'm currently measuring it on mA notch, reading 00.38mA and when switched to µA, it reads 380.0 µA. Also tested it using a suckier multimeter with the same result.

Either the measurement is wrong, or the sketch isn't doing what you think it is. Try the test with the resistor I mentioned. Then make sure you uploaded the sketch. I made mine blink an LED 5 times, just to confirm it was working. Of course I took the measurements after the LED stopped blinking.
Logged

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

Also add some 0.1 uF decoupling capacitors, to be on the safe side.
Logged

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

What meter are you using? I'm going to get one like it.
Logged

Pages: [1] 2 3 ... 5   Go Up
Jump to: