Using sdfat lib - question about SD Card hardware and sample rate


hi all,

i'm working on university project.
we want log data several sensors (connected i2c bus) micro sd card using spi , sdfat-lib on arduino uno (sd card reader catalex ebay).

in context kind of dig out post:
http://forum.arduino.cc/index.php?topic=49649.0

we used procedure of "controlling flush call" described in post above high sample rate (50/s great, not mandatory).
we used class 10 card , benchmarked "bench-code" (write speed: 249kb/s, max latency 24451µs, avg latency 2049µs)

thereby managed increase our sample rate 20-25/s (already quite good), first of ;)!

we store 20 values in cvs file float 5 digits after decimal point (e.g.: 6216.00000;1014.87750;23.04688; .... ). call flush every 1000 measurement rows , works quite (see code fragment details)
we use pushbutton start/stop measurement , open/close sd file on event. log data 5min.


code: [select]

#define data_length 20
#define flush_rate 1000
//[...]
file.open(filename, o_creat | o_write | o_append) //open sd file when button pushed
//[...]
  // write sensor values
  (uint8_t = 0; < data_length; i++)
  {
    file.print(datatosd[i],5);    // write data array sd card controller(?)
    file.write(';'); //separator after each value
  }
  file.println();  // 1 row of data array ready, make new line
 
  if(count%flush_rate==0) //count counts measurement rows logged
  {
  file.flush(); 
  }


we don't care data loss in case of e.g. power failure because can perform measurement again. hence flushing every 1000 measurement rows not issue us.

my questions, since explain correctly in thesis:
1)
it mentioned sdfat-lib has internal buffer of 512bytes. put more 512bytes "somewhere" print- (and write) method:
where data go? going sd card? max. amout of data can put "there" before have call flush again not risking "overwrite" or that? there official documentation explains how sd card work on hardware level?

2) in order possibly increase sample rate 50/s? possible beginner without using sophisticated coding?


thanks lot upfront, sorry long post , best
tim

if don't care data loss don't have flush @ all. close file when you're done collecting data.

the library writes data card whenever buffer fills. unless close file (or call flush) fat doesn't updated , appear if nothing written.

for 50 records per second, that's 20ms per sample. latency exceeds affect timing. think have little more sophisticated in order maintain sampling rate, or accept fact there glitch. else have better advice on me.


Arduino Forum > Using Arduino > Storage > Using sdfat lib - question about SD Card hardware and sample rate


arduino

Comments