Writing to SD card becomes slow with large file size

Hey there everyone.

I'm working on a data logging project which requires getting pretty significant amounts of data (once a second for days on end from up to 16 sensors.)

I'm running the program in such a way that it takes sensor data and checks it for validity every ".1" seconds and prints the data along with a few other things such as a "time stamp" to an SD card. currently this program is running for 6000 x 5 minute cycles. Now at the ~4000 cycle mark, however, I'm noticing that an LED used to indicate the passage of every .1 of a second seems to be periodically delaying...about once a second. This leads me to believe that the delay is due to the print function. Since this doesn't happen when the program first starts, I have to assume this has something to do with the ever increasing file size.

Is this a correct assessment? If yes, is there any way to eliminate the delay, aside form, say, using multiple files?

Thanks

edr2694:
Hey there everyone.

I'm working on a data logging project which requires getting pretty significant amounts of data (once a second for days on end from up to 16 sensors.)

is there any way to eliminate the delay, aside form, say, using multiple files?

Thanks

Look into preallocating your datafiles

#include <SdFat.h>
#include <SdFatUtil.h>

if you pre-allocate, all of the fat overhead is done at startup. The SD library just has to write the individual sectors.

You would just have to truncate() the file before you close it.

Chuck.