Go Down

Topic: data logging speed is very slow (Read 948 times) previous topic - next topic


Dec 07, 2019, 05:10 am Last Edit: Dec 07, 2019, 06:52 am by biyoman
Hi There,

I am trying to record any analog pin data on the SD card, but the recording speed is too slow! I can record at most 60 records per second. Am I making a mistake somewhere, or are the Arduinos so slow? I'll write down the source code below which I've simplified as much as I can. Thank you in advance for the help.

#include <SPI.h>
#include <SD.h>
File dosya;
void setup()
char isim[] = "DATA__00.CSV";
for (uint8_t i = 0; i < 100; i++) {
isim[6] = i / 10 + '0';
isim[7] = i % 10 + '0';
if (! SD.exists(isim)) {
dosya = SD.open(isim, FILE_WRITE);
} } }
void loop()
float voltKAYIT = (5.0 / 1024.0) * analogRead(A3);
dosya.println(voltKAYIT, 3);


It takes time to write to SD cards, that will slow you down a lot.  Why not buffer the data then write it to the SD card. As a Suggestion:  Have you considered FRAM (Ferroelectric Random Access Memory), not the cheapest but definitively reliably.   It's similar to Static random-access memory, only with a ferroelectric layer instead of a dielectric layer. The bytes you write are non-volatile and you can write them very fast!. Some of the advantages I see in FRAM are high speed reading and writing, non-volatile storage but they do not have the density of flash. You get virtually unlimited read / write cycles - you can't wear it out unlike some other types of non-volatile memory. To get started  try this link: https://www.adafruit.com/product/1897  There board has a write enable input so you can lock it down and read it on another machine without worry about trashing the date. There are no delays like you get with SD cards. It is easy to use them, with SPI or I2C. This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!


Dec 08, 2019, 02:36 am Last Edit: Dec 08, 2019, 02:49 am by noob314
Can you get anything on SD card  if you not flush data that often? Perhaps on every 10th write or so?

If I remember correctly, that worked on some earlier versions of SD library, as anyway there is internal buffer of 128 to 512 bytes. I'm not quite certain, perhaps depend which MCU is used, i.e. how many RAM is available.

Is that is still possible, all will be radically faster, as anyway maximum allowed data block which is sent to SD card is much larger than what your firmware sending.



Most of the issues with limited write speed are SD card related and not program issues. Older 1 or 2 GB SD cards have small internal buffers of 128 - 512 bytes and very slow write algorithms of 50-125 milliseconds, actual test times, to transfer the data to the Flash cells. The newer 16 GB SD cards, Verbatum or SanDisk, write in ~20 milliseconds. Their internal buffers are around 4KB. Fill the internal buffer to >60% capacity before you flush the data. I recommend adding a milli() time stamp to your data if a 20 millisecond write cycle posses an issue for your data collection.  

FRAMS are another option that I use when capturing data at >1000 s/sec.      

Go Up