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

Did you think about reading one of the hundreds of tutorials about almost the same task? Don't expect us to write the code for you. Start with code of one of the tutorials, make the necessary changes and if you get stuck ask again here, providing a wiring diagram of your setup and the code you're working with.

MominNadeem:
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

Taking a look at your specs, you want 'simultaneously.' Which micro controller do you have that will be doing the "simultaneously'?

Idahowalker:
Taking a look at your specs, you want 'simultaneously.' Which micro controller do you have that will be doing the "simultaneously'?

I am using arduino pro mini.
I did the same as most of the people done i.e. Opened a file >> wrote it and closed it , then simultaneously opened another file >> wrote it then close it. then repeated this process 10,000 times. But it took time more than expected (6-7 sec means maximum 1.66K samples/sec)

I want to write the files for 10s with 2000 samples/sec.

Suggest that you write all the data to one file that you split later. The SD will have a lot less to do that way.

2 entries every millisecond, how many bytes each entry?

SD writes occasionally have gaps where the card has to find a new page to write (SD cards do their own wear leveling) so you may not get full SPI data rate all the time.

MominNadeem:
Opened a file >> wrote it and closed it , then simultaneously opened another file >> wrote it then close it.

"subsequently" is the word you're looking for, not "simultaneously".

Opening and closing files takes time, buffering and writing larger blocks will work a lot better. 32, maybe 64 values in an array, write them out in one go.

wvmarle:
Opening and closing files takes time, buffering and writing larger blocks will work a lot better. 32, maybe 64 values in an array, write them out in one go.

The libraries we have do the buffering and write 512 bytes (at burst-mode speed using default buffer) when full.

If I wanted to be more sure about speed and SD pauses I would have 1 duino dedicated to the SD, and that one would have at least a double buffer scheme.

You -could- hang 2 SD cards onto the SPI bus, select and write to each in turn. It would save time.

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: Adafruit SPI Non-Volatile FRAM Breakout - 64Kbit / 8KByte : ID 1897 : $5.95 : Adafruit Industries, Unique & fun DIY electronics and kits 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

gilshultz:
Have you considered FRAM (Feroresemot Random Access Memory)

You really seem to be a great fan of FRAM!
But you always fail to point out the severe limitations of it, is I did in an earlier reply to a similar comment of yours. Especially the very limited maximum size of those chips (1 MB) and high price (per byte of storage about 100,000 times that of Flash) should be mentioned. Then there's of course still the issue of transferring the stored data to a PC for further processing...

$6 for 8KB. How many seconds at how many bytes per second does the OP need to store?
They have a 32KB FRAM module for $10 though. That's 4x the storage for less than twice the price.

Usually the next alternative to SD is an EEPROM. They do come much larger than 64KB.

SPI is the only bus fast enough for what the OP wants.