How Fast is it?

I am looking in to using the Arduino for an automation job. Two things that would help tremendously is to know:

1 - How long does it take to startup (with/without writing a new bootloader)
2 - HOw fast can it pulse an I/O pin? If I put it in a tight loop - what kind of freaquency will it pulse? I am shooting for 7kHz.

1 - How long does it take to startup (with/without writing a new bootloader)
2 - HOw fast can it pulse an I/O pin? If I put it in a tight loop - what kind of freaquency will it pulse? I am shooting for 7kHz.

Startup time will depend on the clock fuse settings (I don't know off-hand what these are for the Arduino, but it's not hard to look it up) and what the bootloader does (this is something I have no familiarity with).

On a 16 MHz mega168, you can pulse an I/O pin at maybe 2 - 4 MHz, depending on the implementation and how important it is to have a specific duty cycle. On an Arduino you won't be able to achieve such high speeds just because of the overhead associated with loop(). Just jumping into and out of the subroutine incurs a relatively large delay (large compared to the time it takes to set an I/O pin), and I'm not sure if there is any other substantial overhead occuring outside of loop(). Nonetheless, 7 kHz is quite slow, so you would have no problem achieving this on an Arduino.

  • Ben

About Arduino, the decimilia takes less than one second to boot up with a 4k program (not sure this changes anything, but...)

For what bfrye said about the loop() function delay, it is probably very easy to hack the environnement to change the way the preprocessor works.

Note you can also use the Arduino with other environnements/programmers, you'll just may have to override the device signature check - Arduino sends 0x000000 where ATMega168 is expected to be 1E 94 06

1 - How long does it take to startup (with/without writing a new bootloader)
2 - HOw fast can it pulse an I/O pin? If I put it in a tight loop - what kind of freaquency will it pulse? I am shooting for 7kHz.

I'm not sure if there is any other substantial overhead occuring outside of loop(). Nonetheless, 7 kHz is quite slow, so you would have no problem achieving this on an Arduino.

  • Ben

There is a significant overhead of around 5us to toggle the state using the Arduino digitalWrite function. That limits the maximum frequency to around 200khz, still plenty fast enough for the application mentioned.

There is a significant overhead of around 5us to toggle the state using the Arduino digitalWrite function. That limits the maximum frequency to around 200khz, still plenty fast enough for the application mentioned.

Oh yeah, I forgot to mention that if you really want to reach high frequencies when toggling I/O lines, you should avoid using digitalWrite() and directly manipulate the registers themselves. For example, you can use the SBI and CBI assembly instructions to set and clear specific PORT bits. These instructions take two cycles (125 ns) to execute.

  • Ben

Thanks for the fast responses. Sounds like this is a pretty good fit for me. I looked at one of the BasciStamps - they are just too slow so I would have to introduce additional hardware to handle the 7Hz pulse. The BasicStamp1 has a execution speed of 2000 instructions per second. That is just God awful slow. As far as boot time - ~1 second is good. I can live with that - I thought I read somewhere that is was 7 seconds... I must have miss-read that.
Thanks again

oh yeah - also... As a NEWBIE to all of this - what do I need to 'buy' to sit down and start playing. Just the Arduino and a way to hook it up to my PC? Maybe this is a dumb question - but... Is the program space non-volatile? That is - if I up my software to the chip - is it there whenever I turn the chip on?

AFAIK, Basic Stamp is just a PIC controller with a basic interpreter onboard.... So yes, it is fucawfully slow.

Yes, you just need to buy an Arduino, download the Arduino software, install some drivers (for USB version) and start playing. The program flash is non volatile. The "way to hook it up to your PC" is just a common USB or RS232 cable, depending on which Arduino you choose, which you most probably already own.

Thanks all!

Just jumping into and out of the subroutine incurs a relatively large delay (large compared to the time it takes to set an I/O pin), and I'm not sure if there is any other substantial overhead occuring outside of loop().

AFAIK nothing happens outside the call to loop(), so there's no reason why you can't set up your own infinite loop within loop() itself to avoid the function call overhead.

If I wasn't feeling lazy I'd include the Arduino main.c here---> :slight_smile:

--Phil.

  • I thought I read somewhere that is was 7 seconds... I must have miss-read that.

The older boards did have a boot time of around 7 seconds. The main advantage of the Diecimilla over the NG is that it dropped that to around 1 second.