Pages: 1 [2] 3   Go Down
Author Topic: arduino with internal oscillator on 1Mhz  (Read 34159 times)
0 Members and 1 Guest are viewing this topic.
Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

because simply replacing the crystal won't do you any good -- the clock frequency is hard coded into the bootloader.

re-programming the clock frequency on the fly allows you to experiment with varying power consumption.

but then yes, ultimately you may wish to burn a new bootloader specific to requirements and use a new crystal.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi! New to the boards... came here in seek of a way to run an arduino pro 3.3v (from sparkfun) on 2 AAs. This is important because I'm actually just stealing the power rail from a wireless xbox controller. The two batteries only give me 2.6-2.9 volts, which is only enough to boot the micro on a good day.

I tried running

 CLKPR = (1<<CLKPCE);
 CLKPR = B00000011;

in my setup loop but it still would not power on with 2 AAs. Are there additional steps or tricks I can try?
Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

we were discussing changing the clock frequency in software.

you can't change the voltage in this way.

here are a couple of options:

1. buy an arduino that will run on 3.3V (e.g. arduino pro mini)

2. build a circuit like the Adafruit minty boost that takes 2 x AA and gives you 5V.  This is useful if you also have other parts needing 5V anyway.  I did it myself very recently.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do have the 3.3v arduino pro, it is not the mini however. http://www.sparkfun.com/commerce/product_info.php?products_id=9221

Someone had mentioned earlier in this thread that voltage was linked to clock frequency, so thats what I was going off.

I did find a 3.3 volt dc-dc converter circuit that is now in the mail. That should work for sure. I was hoping to keep power consumption as efficient as possible by using extremely low voltage and not needing the loss in a dc-dc conversion, but I'll explore saving power with watchdog/sleep instead.

Thanks.
Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Someone had mentioned earlier in this thread that voltage was linked to clock frequency, so thats what I was going off.

Couldn't spot that statement just now, but... looking at the datasheet for the ATmega328P it does say that it will run at:

1.8-5.5V for a clock of 0-4MHz,
2.7-5.5V for clock 0-10MHz and
4.5-5.5V for clock 0-20MHz

So running at 4MHz *in principle* should mean you can go down to 1.8V which would give you decent battery life on AAs I guess.

Trouble is that if you're using the clock tweaks described previously then you'll still need to boot up at full clock speed first.  Hmmm!
 
(You would probably need to connect Vcc on the pro direct to your supply as well, rather than going through U2, whatever that is - presumably a regulator.)

Sounds like it would be easier to reprogram a 4MHz bootloader into the 328, really.

I'd be interested to know how you get on.

« Last Edit: October 06, 2009, 11:51:32 am by mungbean » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, interesting. I don't have any special hardware to burn a bootloader so I guess this project will have to go on hold. Something I'll circle back to as I am interested in revising this project to be low power.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 106
Where's the Kaboom?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've got a stand alone battery prowered 328 project that runs off 3 AAs - it "works ok" but reading here is sounds like I'm on the edge of it running successfully at 16MHz.

I was considering dropping the crystal down to 8MHz to give me a wider power margin - Comms is not an issue as I'm programming the 328 in an Arduino then taking it out and dropping it in my PCB.

But it sounds like just changing the crystal won't work either and it will require a software tweak too - is that correct?

Cheers
Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As I understand it, clock speed is hard-coded into the bootloader, so changing the crystal isn't enough to change the speed.  You would need to program a new bootloader in as well.

Given what we've been discussing about clock dividers above, it would seem that changing the crystal isn't actually necessary - a bootloader that sets the clock divider would suffice.
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 106
Where's the Kaboom?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But without the capability to reprogram the bootloader that's going to be a bit awkward. Ho hum.

Cheers
Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you have a windows machine and can solder a 4-way header onto your standard-format arduino (diecimila, duemilanova etc) then you can reprogram the bootloader:

http://www.geocities.jp/arduino_diecimila/bootloader/bitbang_w_ide_en.html

When I last tried with a mac (July 09) it wasn't possible using the mac's FTDI driver.  Instead I used Windows running under parallels.

See also this post/thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1258854659/7#7
Logged

0
Offline Offline
Sr. Member
****
Karma: 0
Posts: 388
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Marvin Martian, why do you think you would need to reprogram the bootloader?

You also said
Quote
Comms is not an issue as I'm programming the 328 in an Arduino then taking it out and dropping it in my PCB.
So when you want to reprogram the sketch on the 328, pull it out of your PCB, replace the 328 in your Arduino (which still has the 16MHz crystal) and re-program the sketch there.

[edit]I know there are timing issues with some of the libraries when they are used with a crystal other than the 16MHz one. But it still seems that is separate from the bootloader issue. If the logic in the sketch cannot be adjusted for a lower crystal speed, there is no point in changing the bootloader anyway. If the logic can be adjusted or does not need to be adjusted, the procedure I outline above should still be valid without needing to reprogram another bootloader onto the 328. At power-on, the standard Arduino bootloader may take a little longer (at the reduced crystal speed) to recognize that there is no data coming in on the serial port, but it should eventually time out and start the sketch anyway, right?[/edit]
« Last Edit: December 02, 2009, 07:03:55 pm by TBAr » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 106
Where's the Kaboom?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Marvin Martian, why do you think you would need to reprogram the bootloader?

Because of what mungbean said earlier:
Quote
As I understand it, clock speed is hard-coded into the bootloader, so changing the crystal isn't enough to change the speed.  You would need to program a new bootloader in as well.

So I'm still confused as to whether this is or is not necessary  :-/

Logged

tytower
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Spookyman166
Quote
Why reprogram the arduino when you can just buy a crystal for 2 bucks

Personaly I have a box full of old crystals I'd like to use up. As I am presently at a river mouth  about to head  to sea I would have to allow two days to tie up ,catch a cab 40Ks to the parts shop, buy my crystal and catch a cab back.

I  find it cheaper to reprogram it.
Its all a matter of your own circumstances and then how narrow or broad your vision is.

Marvin I am using a 14.890MHz crystal in an ATMega8 because of the above . To get the chip to run I have to change the Makefile and recompile the bootloader allowing for this crystal speed . I also have to create a board in "boards.txt" to get an entry for my board

If I program the chip with a sketch in a standard duelmilanov board with a 16MHz crystal and put a standard bootloader on the chip first it will all go off OK. When I put it back in my experimental board with the slower crystal the sketch will run just a little slower but not that I can notice ,however I cannot upload another sketch to it unless I put it back in the standard board


« Last Edit: December 03, 2009, 08:04:03 am by tytower » Logged

Bangalore, India
Offline Offline
Jr. Member
**
Karma: 0
Posts: 77
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Marvin Martian -- if all you want to do is reduce power consumption, then you can change the clock speed once you've booted (in your setup function), as described above.

I posted some test figures earlier in the thread, showing the reduction in current for various clock speeds.  If it's possible to put the arduino to sleep for longish periods of time when it's not doing anything, then this will save power further.

If you want to run on a LOWER VOLTAGE, then you may need to reprogram the bootloader to get the arduino to bootup on that lower voltage, depending on how low you want to go.

I'm basing this assumption on what we found in the ATmega328 datasheet, again mentioned earlier in the thread.

I'm beginning to think it would be GREAT to have a slightly modified bootloader that selected clock frequency based on some jumpers on the board. Anyone fancy giving us an early christmas present...? ;-)

Logged

tytower
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

Back on page 1 wolfpaulus said
Quote
The last thing that needs to be done is adjusting the Arduino IDE preferences file: ~/Library/Arduino/preferences.txt on the Mac and C:\Documents and Settings\<USERNAME>\Application Data\Arduino\preferences.txt on Windows:
The build.f_cpu preference needs to be set to 1000000L

I see that on Linux "preferences.txt " is in the library directory and I could find no mention of "build.f_cpu".

Is this now obsolete ?
Logged

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