Electronic – How to write high-speed A/D data to an SD card

adcmicrocontrollerpicsdspi

I want to use a microcontroller and A/D converter to do some high-frequency (~100 kHz) long-term (minimum of five second buffer, looping until triggered) data logging. It looks like a good way to do this is with an SD card. I know there are different ways of accessing an SD card, including directly through SPI. I also believe that one can write to a file system, or directly to the card without a file system. I'm also concerned about writes having to cover entire sectors instead of byte-by-byte, or about writes interfering with continuing A/D operation, but those may not be valid concerns.

Presently I'm using dsPIC 33 chips, giving me instruction rates of ~60 MIPS; I'm willing to change to a different controller family if necessary.

Best Answer

You may not be able to do this with a PIC33, and almost certainly not just any PIC33. Some flash cards 'go away' for long periods of time (tens of milliseconds or more) despite the high throughput this latency can kill you with a small microcontroller because you'll run out of buffer RAM.

If you allow buffering for 200ms (which should be safe) then you will need 20K words of memory, which a PIC33 may not have (the biggest members of the family have 48K x 8, so if your ADC takes two bytes that's 40K, and presumably your program needs some RAM.

At 100,000 samples/second you also won't be able to do much processing on the data, just grab it. I'd suggest using RAM. And you'd have processing power to spare if you used an ARM with an external SDRAM or even serial RAM.