I was playing around with the ADC of the Arduino. When I change the pre-scaler to 32, I can get around 38k samples per second. The main problem right now is to store these values.
I have a slight doubt regarding the write latencies. I know that the memory in the SD card is divided into chunks of 512 bytes each, and each chunk gets filled up before the next. I got this idea of storing all the samples from a project (somewhere online, I'm really sorry, I don't remember who did this) where the person uses double buffers.
Let's say I have 2 buffers (both 512 bytes, because if I keep them as 1kB, the entire RAM would disappear). I constantly write one buffer's data to the SD card while storing the ADC values through interrupts in the other buffer. The person who had done the project said that there is plenty of time to get the samples written on the SD card.
But I have a question. If we write 512 bytes of from a buffer to an SD card, does it write all 512 bytes in 1 instant? As in, will there only be 1 write latency for all 512 bytes? Or will there be a write latency for each of the integer that we write on the SD card? 512 bytes gives us 256 integers, so does this mean I'll have 256 write latencies?
If this is true, is there any way I can store all these samples into an SD card?
tl;dr - How do I store 19k or 38k samples per second into an SD card and overcome the write latencies?