Fastest possible way to read data into arduino?

Hello
I'm new to arduino, waiting for the hardware to arrive, dreaming about what i want to try to do with it first :wink:

One of my plans is a special kind of sound generator. I realize that it will need all the CPU power (at least) to be of any use. But then i also want to have an interface to change the produced sounds in real time, having different ideas how this interface would be realized. If i understand things right how analog input works internally i think this would probably interrupt the program flow far too long to be acceptable here. I expect the same for serial data connections. Maybe i just dream up things that are too demanding on behalf of CPU power... I think i will try to use two arduinos, one to receive data from the human interface and do some maths on it. Then it would be transfered to the sound generating arduino. I don't know yet how many bits i will need for that and how often i'll need to transfer data, but it will not be very much anyway. The problem is more how long the program flow of the receiving arduino will be interrupted by the transfer. So how do i do that?

Can i read several digital input pins at once or only one after the other?
How fast can a serial connection between two arduinos be?
Should i look at SPI?
Other ideas?

Sorry for the vague description of this project, it is still in the dream-about-stage :wink:
So let's just concentrate on the fast data transfer issue. Thanks for any hints.

Sorry for the vague description of this project, it is still in the dream-about-stage
So let's just concentrate on the fast data transfer issue. Thanks for any hints.

This is the problem with answering any of your questions. Without understanding what are you going to do, on a detailed level, how can any advice be given?

You seem to have made the assumption that the ATmega isn't "powerful" enough for your application, whatever your application is. Why is this the case? Are you doing DSP intensive operations in your code? If this is the case, maybe the ATmega/Arduino is a poor choice for this application.

You want to know how to transfer data fast. What is fast? How much data and what kind of data? Is this a stream of data, a burst, in and out, etc?

The more useful information you give, the more useful answers you will get.

As CMiYC says we need more info, but as a general comment your comms shouldn't take up too much of the processor's time if you use the hardware IO and interrupts, a quick write to a register and the character is on it's way, meanwhile you are free to do other stuff.

Can i read several digital input pins at once or only one after the other?

You can read 8 at once as long as they are on the same port.

How fast can a serial connection between two arduinos be?

With SPI up to CLK/4 which is 4Mbps.

Maybe it's worth approach the requirements from a slightly different direction.

Let's use Stereo CD as a baseline.

Wikipedia "Red Book" defines CD Audio as
2 channels x 44,100 samples per second per channel × 16 bits per sample = 1,411,200 bit/s = 1,411.2 kbit/s.

SPI is 4Mbits/second, so, if the program did no useful work while sending data, about 2/3rd of the Arduino's time is left to do something useful.

If the program used SPI hardware, in relatively simple way (very little sneaky stuff) I'd estimate that those 2x44,100 samples/second could be sent in 44,100 x 6uSec = 0.265 of a second leaving almost 3/4 of the Arduino to do useful stuff.

If sending the data was only slightly sneaky, it would take about 2x44,100 x 2uSec = 0.176 of a second, leaving the Arduino almost 5/6ths of its time to do something useful.

Lets take another baseline.
Wikipedia defines Super Audio CD as 2822.4 kHz 1 bit/channel.
So two channels of SACD would be beyond SPI's capability.

Folks who record live music, seem to use 192k samples/second, 24 bits/sample for each audio channel. That's 4.6m bits /second. Beyond SPI, but feasible if the data were shifted out in, say, 8 bit chunks (an Arduino only has 18 or 20 I/O pins, so 8 is a reasonable number to use for sound output).

Summary, if CD stereo is good enough quality, then sending the data probably isn't going to be too difficult.

If you want lots of audio channels, or higher quality than CD Audio, then it might be worth explaining what it is your trying to do so that folks can help.

What is likely to be more difficult than data communications is generating high quality, interesting sound.

HTH

Thanks a lot for all replies.

I see that the I/O situation is much better then i thought, even using SPI.
A special thank to point me to 'ports'. The information about that is very well hidden on www.arduino.cc (I could not find that on my own, not even with your tip. Had to ask google).
See Arduino Reference - Arduino Reference

OK, now I wait for my hardware to arrive before asking any more questions...