Go Down

Topic: Faster data logging with SdFat and a RTOS (Read 4893 times) previous topic - next topic


SD cards can have occasional write delays of up to 200 milliseconds.  This due to erasing large flash blocks and remapping bad spots.

These delays can cause data points to be lost at rates over a few points per second.

A real-time kernel can be used to solve this problem.  Data is captured in a high priority task and queued for a lower priority task to write to an SD card.

I have posted several sketches for faster data logging using special tricks but a real-time kernel is a more general way to solve this type problem.

I have ported two real-time kernels to the Arduino, FreeRTOS and ChibiOS/RT, and developed fast data logging sketches that use these kernels.  The kernels are easy to use Arduino libraries so no modification of the core Arduino files or IDE is required.

The examples are here http://code.google.com/p/beta-lib/downloads/list in files ChibiOS20111027.zip and FreeRTOS20111031.zip.

On a 328 Arduino it is possible to log up to 976 points per second (one point every 1024 microseconds) to an CSV file where each point is the value from two analog pins.

On a Mega, with more buffering, values from four analog pins can be logged at the above rate to a CSV file.

More about the ChibiOS/RT port is here http://arduino.cc/forum/index.php/topic,76932.0.html.

The FreeRTOS port is described here http://arduino.cc/forum/index.php/topic,77362.0.html.


Nov 10, 2011, 09:56 pm Last Edit: Nov 10, 2011, 10:00 pm by tevroc Reason: 1
I've used duinos and it seems to work very well.  I just need to port it to 2560 now  :P


Both libraries and the examples should work on the 2560.


Mar 25, 2012, 06:10 am Last Edit: Mar 25, 2012, 06:40 am by slayer1991 Reason: 1
I have a program that calculates RPM, speed, fuel from different sensors (2 digital 2 analog) and outputs the info through serial3 (arduino mega2560) onto an LCD screen. I'm trying to implement data acquisition too. What would be the easiest way to record some buffered CSV to a file?
Right now i'm thinking of something like

Code: [Select]
obufstream bout(buf, sizeof(buf));

but this doesn't do any buffering except creating a string for all the values together. Any tips?

Go Up