run arduino at lower speed

I am not sure if I am at the right forums.

Say if I write some code in Arduino IDE, and set the CPU_F to say 1MHz in the Arduino IDE, and upload the code to Arduino Mega 2560(or other arduino) with a programmer(wipe out the bootloader), will I still get the right time? eg delay and URAT com. etc...

My goal is to run the chip in just enough speed to save energy.

or if it won't work, what are the other option to run the clock slower.

Zhuhua

bug13: I am not sure if I am at the right forums.

Say if I write some code in Arduino IDE, and set the CPU_F to say 1MHz in the Arduino IDE, and upload the code to Arduino Mega 2560(or other arduino) with a programmer(wipe out the bootloader), will I still get the right time? eg delay and URAT com. etc...

My goal is to run the chip in just enough speed to save energy.

or if it won't work, what are the other option to run the clock slower.

Zhuhua

CPU_F does not control how fast the atmega runs it's a constant so that the compiler can make assumptions. You can mess with the fuse bits and/or change the crystal to do this and adjust CPU_F to match. There is a LOT of code that does not like speeds other than 16 and 8 mhz. Expect to have to program it via a ISP as the bootloader will not work correctly or be painfully slow. Any serial will need to be a low baud rate and general give you grief.

You can achieve a great deal of power savings from turning parts off that are not used and entering sleep modes.

The most used avr chip for Arduino's is the ATmega328P. This chip is able to set a clock divider while running. So it can set it's own clock to a lower rate. But if you do so, you mess up a lot. The baudrate is no longer valid, the millis() function is no longer valid. All pwm and tone functions are no longer valid.

As silasmoeckel wrote, power saving is done with the sleep mode. You can achieve the maximum power saving with that. As far as I know, there is no Arduino library for it. So you have to read the datasheet of the ATmega328P to see what the different sleep modes do.

For maximum power saving sleep is not sufficient. He must go down to 1 MHz in order to be able to lower the voltage. It saves more power to use the build in RC oscillator instead of a crystal. It also uses less power to a 1 MHz oscillator instead of dividing a higher clock down to 1 MHz. It does NOT save any additional power to lower the clock any further. This is because the power consumption per tick depends only on the current mode. So if you sleep during unused ticks having a lower clock frequency will keep the processor longer awake. Although this should make no difference it will as soon as other peripherals come into play. As a rule of thumb you should stick to the highest possible frequency at the lowest admissible voltage. It does not hurt to increase the voltage slightly but it will of course increase power consumption again. In addition the RC oscillator allows for the shortest start up time after sleep reducing power to a crystal even further. Unfortunately RC has the poorest frequency stability of all.

In addition you should shut down all peripherals that are not needed before going to sleep, e.g. unneeded counters, AD converter, SPI / serial interface, WD, brownout detector and so on BEFORE you enter sleep mode.

For maximum power saving

For maximum power savings, or even reasonable power savings, you probably need to design different hardware. There is nothing on the MEGA2560 board designed to make it a low-power device; the voltage regulator isn't particularly low power, the power switching circuit isn't particularly low in power, there's that whole USB interface that can't be turned off (?), and there are extra LEDs.

Stuff about power savings:

http://www.gammon.com.au/power

Hi

thanks for all the input, the information is very helpful.

The thing is that the USB<->Serial converter chews power even if not on USB.
You will need a different type of board for lower consumption.
Not to mention around 5ma for power LEDS.