Reading analog input at high frequency using arduino mega 2560 and SD card

Hello,

I am trying to read a couple of signals using my arduino mega 2560. I need to read them at 4kHz. To do so I am using interrupts and the analogRead function.

My question is: how can I continuously send the data to a SD card? I can create a buffer and send it when is full but I don't know how to avoid data losses with the reading and writing speeds so different.

Thanks in advance

See this Try this super fast analog pin logger - Storage - Arduino Forum.

That is great! Thank you.

I only have one question so far: how can I control the acquisition time? If I only need 10 secs, is there a way to set it?