Practical difference between CPU speeds and power inputs.

I have need of a long term power source for a stand along ATmega328P based device. I plan on using a 328P chip stripped of all but its barest essentials to run (no USB, no power regulator, no ADC, no brown out, etc) all to get max battery life. It needs only to run the I2C bus and a few digital pins (sense HIGH or LOW and send a messaage to another Uno, etc ).

My question is could I run my "bear bones" 328P on say 3.3VDC at 8MHz? I have read the power savings over say 5VDC @ 16 MHz is about 6 1/2 times less power consumption. If I have no "heavy lifting" programming wise could I even use the internal 1 MHz OSC and thus eliminate the external XTAL? As long as the chip can respond to a pin state change in say 1/10 of a second and "tell" the other Uno I would be happy.

Thank you in advance.

Are you sleeping the processor? The clock is stopped while it's in sleep mode powerdown, so you don't save much by changing the clock speed, assuming it's sleeping and only waking on pin change...

Gammon Forum : Electronics : Microprocessors : Power saving techniques for microprocessors has a great guide to power saving on AVRs.

DrAzzy:

I did not think of that... thanks for pointing it out. If i put it to sleep between pin HIGH/ LOW changes how long will it take to "wake" and be fully functional?

So all it has to do is sleep (forever in theory) then "wake" and send a I2C message if one of the PIR sensors goes off... or if it gets a I2C message from the other Uno wake as well. It does nothing more.

SamBrownADK:
how long will it take to "wake" and be fully functional?

Check out the "System clock and Clock options" section of the datasheet. Depending on configuration it can vary from 6 clock cycles to 32 thousand clock cycles. Basically you want to give the clock a bit of time when coming out of "power down" or "power-save" sleep modes to become stable before starting. How much time is necessary depends on the clock source, how close you are to the maximum frequency, and how important frequency stability is at start-up. I found it interesting to see that ceramic resonators, which are generally considered inferior to crystals, allow a significantly lower start-up time.

Thanks Pert... I will check that out. Can I just do away with the external XTAL and use the internal 1MHz XTAL? I am new to electronics and programming so please bear with me.

All I need the chip to do is sleep forever unless it gets a "wake up" from a PIR sensor (powered by its own power) or a message from another Uno via I2c.

Yes you can use the internal RC oscillator. In fact it will allow you to run at up to 8 MHz. It also allows the shortest start-up time from "power down" or "power-save" sleep modes, 6 clock cycles!

My understanding is this clock source is less accurate, the speed varies with temperature or voltage. This could cause problems for timing critical operations. I believe it could be a problem for serial communication for example. It is possible to calibrate it. I've used the internal RC oscillator on an ATmega328P quite a bit without encountering any problems so far.

My understanding is that, if you can sleep whenever the microcontroller isn't doing anything, you will actually use less power at a higher frequency. The reason is that you can get what you need to do done and then go back to sleep faster even though you are using more current while awake at the higher frequency. If you are forced to spend time waiting while awake the equation may change as there is no speed benefit to running at 8 MHz burning battery power while just sitting there twiddling your thumbs.

99.99% of the time (litteraly) the chip will have nothing to do... from everything I have read, sleep mode is ideal for this situation. The 328P only has to do something if a PIR or I2C goes off.

I guess my next question is if a 328P is in sleep mode how fast can it "wake" and will it be fast enough to read a I2C message to is correctly?

I am going to experiment with a regular Uno R3 board to see how long a "sleeping" Uno will burn through a battery pack compared to "awake" all of the time but doing nothing. I will post my results.

SamBrownADK:
I guess my next question is if a 328P is in sleep mode how fast can it "wake" and will it be fast enough to read a I2C message to is correctly?

pert already gave you an answer: between 6 and 32,000 clock cycles.

For the Arduino's clock setting (Low Power Crystal Oscillator), it's 16,000 clock cycles. For a 16 MHz clock, that's 1 ms. If you're sleeping for less than a few milliseconds at a time, you can use the Standby mode instead of Power Down. The only difference is that Standby leaves the main oscillator on, Power Down turns it off. You're probably going to want Power Down.

For the 8MHz internal RC oscillator, it takes 6 clock cycles to wake up. That's not even worth worrying about.

I thought the device was going to be sending an IIC message, not reading one? either way it doesn't matter. TWI Address Match is a supported interrupt for waking up the ATmega328P from any sleep mode.

I am going to experiment with a regular Uno R3 board to see how long a "sleeping" Uno will burn through a battery pack compared to "awake" all of the time but doing nothing. I will post my results.

You will not notice a big difference, because of all the extra crap on an Uno board sucking power.

Build it standalone, and you won't be able to measure the difference, because the estimated run time of the sleeping controller will be well over a century, 10 times longer than the shelf life of your average battery.

I am going to experiment with a regular Uno R3 board to see how long a "sleeping" Uno will burn through a battery pack compared to "awake" all of the time but doing nothing. I will post my results.

Someone already did that, and posted on the forum.

It would be a complete waste of your time, because the UNO R3 uses far too much power to run for any significant length of time on batteries. Even CAR batteries!

Carefully study, and fully embrace, Nick Gammon's post on power saving.

jremington:
Someone already did that, and posted on the forum.

It would be a complete waste of your time, because the UNO R3 uses far too much power to run for any significant length of time on batteries. Even CAR batteries!

Carefully study, and fully embrace, Nick Gammon's post on power saving.

Depends on the board. A knockoff that uses a proper USB-Serial chip instead of the half-assed ATmega16U2 that genuine ones use can get down pretty low if you remove the power LED. A proper USB chip should go to sleep when USB is not connected. The ATmega16U2 used on genuine boards doesn't do that, so it's stuck running full blast all the time.

I suppose you could reflash it with a new firmware that just goes straight to sleep so it'll use almost no power. You'll lose the USB-Serial functionality, and at that point you might as well just knock it up on perfboard for all the trouble you're going through. It is an option though.

A knockoff that uses a proper USB-Serial chip instead of the half-assed ATmega16U2 that genuine ones use can get down pretty low if you remove the power LED. A proper USBchip should go to sleep when USB is not connected.

The 16u2 and/or USB chip is only part of the problem with an Uno. The voltage regulator uses significant quiescent current (~75uA at low loads, compared to less than 1uA for max sleep modes of the AVR._ The OTHER voltage regulator has a HIGH quiescent current (~10mA.) (and this is assuming that whatever board you got is using the The op-amp used in the power-switching circuit is not low-power.

Hmm. Putting the 16u2 into low-power mode when no USB is present should be a firmware change, too. But with the other board-level issues, it's not worth the effort.

BTW, "standard wisdom" is that for lowest power operation, you should run the CPU at full speed when it's on, and sleep as deeply as possible in between. There is a more-or-less linear relationship between speed and consumption, and another linear relationship between on-time and power consumption, so they tend to cancel each other out (half speed uses half the power for twice the time.) Add clock-related times to the time to get in and out of sleep modes, and the faster clocks come out ahead. Usually.

westfw:
The 16u2 and/or USB chip is only part of the problem with an Uno. The voltage regulator uses significant quiescent current (~75uA at low loads, compared to less than 1uA for max sleep modes of the AVR._ The OTHER voltage regulator has a HIGH quiescent current (~10mA.) (and this is assuming that whatever board you got is using the The op-amp used in the power-switching circuit is not low-power.

Hmm. Putting the 16u2 into low-power mode when no USB is present should be a firmware change, too. But with the other board-level issues, it's not worth the effort.

I agree that there's better options, like Pro Minis or a custom circuit. I'm just saying that those aren't the only options.

westfw:
BTW, "standard wisdom" is that for lowest power operation, you should run the CPU at full speed when it's on, and sleep as deeply as possible in between. There is a more-or-less linear relationship between speed and consumption, and another linear relationship between on-time and power consumption, so they tend to cancel each other out (half speed uses half the power for twice the time.) Add clock-related times to the time to get in and out of sleep modes, and the faster clocks come out ahead. Usually.

I've brought this up in a different thread, so it's good to see someone else that gets it. There was a Sparkfun article investigating low power (which I think has been replaced, I can't find it anymore) where the author put sleeping into the sketch, saw a huge power reduction, then reduced the clock frequency from 16 MHz to 8 MHz and was confused that there was no change and not the 1/2 reduction that was expected from the common wisdom.

The reason for that is that the CPU is by far the biggest power consumer in the chip. Even the lightest sleep mode (Idle) which just turns off the CPU and Flash clocks reduced power consumption by about 70-80%. Once the CPU is turned off, the remaining peripherals by-and-large operate relatively independently of the choice of CPU clock frequency (assuming their prescalers are chosen properly), or are completely analog (like the voltage reference and comparator peripheral).

For this reason, when you liberally use sleep modes, reducing the clock speed only provides a significant benefit if you also lower the supply voltage. The Speed Grades chart in the datasheet shows that higher clock frequencies require higher supply voltage. Conversely, lower speeds can use lower voltages. With a 4 MHz clock you can go all the way down to 1.8V. Since the repeated charging and discharging of the MOSFET gates during CPU operation acts like a switched-capacitor resistor, using less voltage means less charge pumped per clock cycle, which means lower power usage. All other things being the same, a 2V power supply will require less power than a 5V one, even if you are using linear regulation to get it. Do the math yourself. Calculate the current draw from a 9V battery when using a 2V regulator to power a fixed resistor, compared to a 5V regulator to power the same fixed resistor.

Spoiler: The 2V regulator will technically be "less efficient", but will use less total power than the 5V one. Try and make sense of that.