1

My datalogging system which consits of the Flora, RTC, SD card breakout board, LSM9DS0 sensor is shown in the picture below;

https://www.dropbox.com/s/d8pwcn59nq11lzs/2014-11-25%2012.26.56.jpg?dl=0

The sampling rate/s is capped at 30 when writing into the sd card. If I disable the sensor and only save the time it goes up to 65. Writing into the serial interface rather than the sd card makes the rate goes up even higher at 127. for my application I need at least 100 samples/s. I am thinking the sd card is the problem after making the tests mentioned. The flora clock at 16Mhz is surely able to provide a higher sampling frequency. After checking the sensor datasheet and library I haven't found any limitation either. any input on this issue?

  • 2
    We can't help much without any code. – Gerben Nov 25 '14 at 15:17
  • What sd card model do you use? Write performance varies a lot between models. – jfpoilpret Nov 25 '14 at 17:02
  • 1
    SD cards have a lot of intermittent delay. To stream to them well, you need to buffer a full sector worth of samples to write at once, and have spare buffer memory to hold incomming samples across the maximum expected SDcard delay until you can write to it again. You will need a primitive form of multitasking, even if as simple as collecting your samples in an interrupt. – Chris Stratton Jan 25 '15 at 20:51
  • Add some debugging code that writes "Serial.println( millis() )" before and after the SD card write so you can figure out how long it's really taking (is that really the bottleneck?). Then make a short demo program that demonstrates just the bottleneck, post it here and let us help you make it better. – David Cary Feb 24 '15 at 17:54
1

First, based on my experience with similar hardware, something about the sd card I/O stinks: it should be plenty fast enough. Using a class 4 (cheapo) sd card I've seen a 16mhz AVR do a FAT filesystem open for appending, write a new record of maybe 70 characters and close the file, all a few hundred times per second. This was with the Arduino "SD" library apparently written by Sparkfun in 2010 and improved by Adafruit sometime later.

Maybe the I/O library you're using is dog slow? Another possibility is that your SD card has a lot of files on it and something about directory (folder) traversal during an open is the bottleneck? (my experience is with just a few files on a given sd card)

But you could try buffering N samples so each sd card write records N samples.

If you do this, don't forget to "flush" any remaining samples when you go from "sampling" to "not sampling" modes, if that's possible. That is, if something is telling the thing 'start', then 'stop', part of the response to 'stop' is to get the N-m buffered samples written out to the sd card.

0

I have used Sparkfun's OpenLog as I have also found the SD library slow when writing many small samples. It lets you log directly from the Serial connection, so you should be able to get at least the 127 samples per second. You may also try increasing the baud rate, especially if you are using outputting to Serial.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.