Go Down

Topic: SD read to DAC speed (Read 435 times) previous topic - next topic

masterchef

Hi,

I am planning a project using a Mega 2560, the project involves reading from an spi sd card and writing to an 8 channel DAC which is also spi. The sd card contains 16 bit samples for each of the DACs 8 channels, there are 6400 samples per second for each channel so that works out around 0.82MBs per second that I need to read. I need to update the DAC 6400 times a second, so the write to DAC needs to happen every 157 micro seconds. So my question would be is it possible to read 8 16bit samples from a file in less than 157 micro seconds and write it to a DAC vis spi? Any advice would be excellent, thanks in advance!

Masterchef

PaulS

Quote
So my question would be is it possible to read 8 16bit samples from a file in less than 157 micro seconds
The SD library uses a 512 byte buffer. It only actually reads from the card when the buffer does not contain enough data to satisfy the latest request. The buffer will only contain enough data to supply 256 samples, or 32 sets of data. After that, the SD class will actually have to fetch data from the card. That will take significantly longer. Exactly how long, I don't remember, but you can easily test that.

Of course, you will spend some type getting the data shifted out to the DAC, so you probably don't have 157 microseconds to fetch data from the card.
The art of getting good answers lies in asking good questions.

masterchef

Is there any other libraries I could use to speed it up? I have looked into getting an arduino due for this project which has a faster clock speed, would this be useful in getting faster read times?

PaulS

Quote
Is there any other libraries I could use to speed it up?
The problem is NOT the library.
The art of getting good answers lies in asking good questions.

Go Up