SD card multiple file write with high sample rate

Hi ! I am new here. I am working on a data logger project. My target is to record the signal from pin A0 and A1 in two different files (e.g. test.wav and test.csv) simultaneously at sampling rate 2000. I am unable write such a code to do the said task. Kindly guide me. Thnaks

What do you have so far?

2000 what? Samples per second?

Which Arduino do you have?

wildbill: What do you have so far?

I have tries the direct way i.e. open the file >> write it >> close it>> open another file >> write it and close it >> do this 10000 times . But it takes more time then expected :(

I want to store 20,000 samples in 10s i.e. 2000 samples/sec

Opening and closing a file is “expensive”. It takes a lot of time.

If you are doing 10-second data samples and don’t mind if you lose the last one if power us unplugged halfway through then you should never close the file during a 10-second write. Try to write your code to do that. Let us see it to comment on it.

MorganS: Opening and closing a file is "expensive". It takes a lot of time.

And switching between files as well.

I've read something like wav and csv, 2 analog inputs. If both inputs read the same signal, then it doesn't make sense using two.

Since switching between files is also slow, you may use the same technique as WAV files for stereo audio: intercalating (alternating) samples. That is, log the first input, then the second, then the first again, then the second again, and so on; all into a single file.

Futhermore, because writting binary data is faster than writting text, you'll maybe have to generate the CSV file in a "post-processing" stage where timing constrains no longer exist.

Have you considered FRAM (Feroresemot Random Access Memory) It's similar to Static random-access memory, only with a ferroelectric layer instead of a dielectric layer. This gives it stable handling (the bytes you write are non-volatile) with dynamic responsiveness (you can write them very fast!). Some of the advantages I see in FRAM are high speed reading and writing, non-volatile storage (it remembers its contents without needing power or battery backup), virtually unlimited read / write cycles - you can't wear it out unlike some other types of non-volatile memory. To get started try this link: There board has a write enable input so you can lock it down and read it on another machine without worry about trashing the date. Good Luck & Have Fun! Gil