Go Down

Topic: SD -> Arduino -> DAC? (Read 3409 times) previous topic - next topic

baum

which is what is on the breakout board linked above. (10k)

baum

Do you think that the SD lib included with Arduino 022 is fast enough for audio playback? Also, should I get a buffer chip to buffer the SD lines (MOSI, SCK, SS)?


baum

baum

I just did some research on the I2C DAC: If in fast mode (400kbps), I can clock out one value (2 bytes) in 40us, giving an ideal maximum sample rate of 25khz. This is just enough for 22khz sample rate wav. However, in high-speed mode (3.4Mbps), one cycle is only ~5us, giving a max sample rate of 212kHz(!) Is this to fast for the arduino? If not, I would love to use the high speed mode and free up some pins...

Also, do I need a buffer on the SD card? is 40mA enough?

Thanks!
baum

Grumpy_Mike

Quote
However, in high-speed mode (3.4Mbps), one cycle is only ~5us, giving a max sample rate of 212kHz(!) Is this to fast for the arduino?

Remember that the I2C bus is dependent on the clock rate you send it. We are just talking about the maximum rates here. There is no problem with sending data at any rate up to the maximum. With the arduino running at 16MHz I think the maximum clock rate for the I2C bus will be 4MHz but you would have to check the data sheet.

Quote
do I need a buffer on the SD card?

What do you mean by this? You defiantly need some logic level converters resistive potential dividers don't always work.
Current requirements for SD cards vary so you are better off regulating down to 3V3 from 5V.

baum

I am running this whole setup from 3.3V (everything...) so no converters are needed... I'm just wondering about an actual buffer if the AVR i/o pins can't handle the sd card requirements.

Quote
4MHz

I2C high speed mode is 3.4Mhz...

baum

Grumpy_Mike

Quote
I2C high speed mode is 3.4Mhz.

Yes so? The arduino hardware is capable of going faster than this it doesn't mean you have to make it go this fast.

If the whole system is 3V3 then I would not expect you will need a buffer.

baum

So high speed mode should work for my purposes.

Nick47

What would be the code to get the I2C bus to 3.4Mhz? I've seen everywhere that is is possible but I don't know how to set it that high. I have mine currently set to fast mode at 400kHz but I need faster.

Paul Stoffregen

I'm doing something like this, too. Is an I2C DAC too slow, or would a parallel one be necessary? Also, could the SDfatlib be used, or is that too slow?
What is or isn't too slow depends quite a lot on the sample rate and quality level you're trying to achieve, and whether you wish to accomplish anything else while you're playing the sound.

The sad reality is 8 bit AVR-based Arduino is quite slow.  The Adafruit Waveshield manages 22 kHz sample rate, but to do so it uses a special optimized version of the SdFat library.  The AVR processor is not able to do much else while moving the data at this speed.

If you want 44 kHz or higher sample rates or you wish to do significant other work while the sound plays, you're probably going to need a faster processor.  Better processors have a type of communication called I2S.  It's totally different from I2C, even though the first 2 letters are "I2".  I2S is for streaming audio.  Nearly all DACs meant for quality audio use I2S protocol, not I2C or SPI.  Boards which have I2S feature efficient DMA engines which automatically move data from memory to the DAC in large blocks, which allows the CPU to spend time doing other tasks, rather than being fully consumed just struggling to move the audio data.

Whether you need I2S and more powerful hardware really depends on the quality and features you're trying to achieve.  If you only need moderate to low quality audio output and you don't need to do anything else while the audio plays, 8 bit AVR may work well.  But even achieving that low level or performance is difficult with such a slow 8 bit processor, so you should really look at the Waveshield's library and examples.  People who have come before you have already done this difficult work, so do yourself a favor and at least look at what they did, even if you must reinvent the wheel (eg, for an academic project?)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy