 # Formula for calculating audio channels / max frequency per channel?

I'm trying to get my head around as to how I can calculate the maximum amount of channels that could be used at a specific frequency..

For example:

Clockrate: 100Mhz Desired sample rate: 50Khz Bitrate: 16bit

How many channels could I run over SPI / I2C?

How do I replicate this with any given factors? For example:

Clockrate: 75Mhz Desired sample rate: 22.2Khz Bitrate: 8bit

1 MHz = 1 million bits/second.

But this is meaningless without reference to specific devices.

Clockrate: 100Mhz

What Arduino do you have?

For SPI one bit is transferred per SPI clock pulse. But then you have software overheads to fetch the next byte or do something with the byte you have recieved.

For I2C you need 10 I2C clock pulses to transfer 1 Byte. Normally I2C runs at 100KHz but you can get some devices that work at 400KHz or even 800KHz.

as to how I can calculate the maximum amount of channels that could be used at a specific frequency.

No idea what you mean by a channel though.

Single channel of CD quality audio from SD card is possible with 16 MHz Uno/1284P. See the discussion here using 16 bit ADC & DACs. http://forum.arduino.cc/index.php?topic=180769.0

2 byte * 44100 samples/second = 88,200 bytes/second. SPI needs 17 bits/byte x 1//16000000 = just 1uS/byte sent under ideal conditions.

Grumpy_Mike: What Arduino do you have?

For SPI one bit is transferred per SPI clock pulse. But then you have software overheads to fetch the next byte or do something with the byte you have recieved.

For I2C you need 10 I2C clock pulses to transfer 1 Byte. Normally I2C runs at 100KHz but you can get some devices that work at 400KHz or even 800KHz. No idea what you mean by a channel though.

To clarify what I mean by 'channels':

An AD5206 digital pot has 6 channels..

I am running on a Teensy 3.2, but wrote values to make this simple (eg 100MHz seems a good round number).

Thanks for the feedback everyone, however, it's not really answered my question as of yet.

This is basically what I am asking:

Q: If I have a 100MHz MCu and wish to run multiple 16bit channels at 48KHz, how many channels can I run at that frequency.

If this is still unclear, please let me know what other information you require and I will get back to you as soon as I can.

48.000 x 16 = 768.000 100.000.000 / 768.000 = 130 channels. Roughly. SPI start/stop overhead may round this up to 1 MHz per channel, and you probably need 8-bit for address, anyway I'd expect over 50 channels. The problem may arise not in the throughput of the SPI, but processing data with such high rate. Even for 1 channel DMA seems desirable

Magician: 48.000 x 16 = 768.000 100.000.000 / 768.000 = 130 channels. Roughly. SPI start/stop overhead may round this up to 1 MHz per channel, and you probably need 8-bit for address, anyway I'd expect over 50 channels. The problem may arise not in the throughput of the SPI, but processing data with such high rate. Even for 1 channel DMA seems desirable

Awesome! Thank you so much.

This was effectively what I was looking for.

So, as a formula I could state it as:

C - Max Channels R - ClockRate B - Bitrate F - Desired Frequency S - SPI Transfer rate

C = R / (B (F + S))

Example values:

R - 100,000,000hz (100Mhz) B - 16bit F - 48,000hz (48Khz) S - 1000hz (1Khz)

Substitution:

C = 100,000,000 / (16 (48,000 + 1,000))

C = 1M / (16 (49K)

C = 1M / 784K

C = 127.5510204081633

C = 127 channels!

Therefore / IF:

R - 20,000,000hz (20Mhz) B - 8bit F - 22,100hz (22.1Khz) S - 1000hz (1Khz)

Substitution:

C = 20M / (8 (22.1K + 1K)

C = 20M / (8 (23.1K)

C = 20M / 184.8K

C = 108.23

C = 108 channels.

If this is correct, please could someone verify that this is the case please?

Thanks in advance and to anyone that has helped thus far!