Fast data logger for multiple analog pins

maybe it is a better idea, dont know... may I ask, if my idea to put data in the queue with FreeRTOS functions synchronizing the tasks is better than to create a single buffer like the example in NilRTOS!?!?!??

I do not know how it is with Freertos, but I did it with Nilrtos - the NilFIFO.h is a ready class, and it works. I sampled and wrote struct=88bytes of data 333x per second to the sdcard without lost bytes (with 1284p and 14kB ram used).

The FIFO is needed because of the sdcard's write latencies (up to 250ms, typically 10-80ms). So you want write your struct into FIFO with the first task at sampling intervals, with the second one you write the struct from FIFO to the sdcard (when the FIFO not empty). During sdcard's outages the FIFO fills itself, when the sdcard is ready to accept the writes the FIFO empties..

Mind the FIFO ram size depends on struct size and the sampling period and expected latencies. With ie. struct=100bytes and with 200x per second sampling rate and 250ms worst case sdcard's latency the FIFO needs 100x200x0.25=5kBytes of ram.

I tryd to use this sketch for logging with a manual on/of switch on a digital pin instead of serial character.
I tryed simply to replace " while (!Serial.available()) { " with " while (!Pinbutton high()) { "
but couldn,t get it to work.
any suggestion for this Where to place the digitalpin read ?

Try:

while( !(digitalRead(buttonPin) == HIGH))

Hi!
I was wondering, would this program be able to log 100,000 samples? I have an Arduino Uno code that is able to log 100,000 samples with a high quality SD card but it can only log one analog input. I upgraded to a Mega and I was wondering if this multiple analog input logger can go up to 100,000 samples. I only need to log maximum 3 analog inputs.
Thanks!

No.

The AVR ADC can log one pin at 100,000 samples per second but accuracy is reduced to under 8-bits. It is not possible to log faster.

It is possible to log much faster with modern ARM devices using DMA. I have been experimenting with STM32 chips with a 2.4 MSPS ADC. This ADC can automatically log multiple channels using DMA at (2,400,000/). per second.

Edit: Are you sure you are not missing points at 100,000 samples per second? How are you doing the 100,000 samples per second?

Could this be done on the Arduino Yun?

I try to build an 4 channel analog data logger with an Arduino Uno and an Adafruit data logging shield (because of the SD socket and the RTC). It worked almost as expected (averaging 40 samples per 1/10s and write the values inclusive time stamp to the SD card). but because it is very slow I wanted to try out the NilRTOS data loggers. It looks like I have a problem with installing the libraries, but I followed the HTML tutorial... When I'm going to compile the examples, I get a lot of error messages. And i don't know how to fix it. When I'm going to compile nilFifoDataLogger.ino or nilSdLogger.ino the compiler gives me a hundred lines of error messages like the following.

Any help for me? Thank you...

Arduino: 1.6.8 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:0:

C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:33:15: error: redefinition of 'const uint8_t SD_CARD_ERROR_CMD0'

uint8_t const SD_CARD_ERROR_CMD0 = 0X1;

^

In file included from C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:28:0,

from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:

C:\Program Files\Arduino\libraries\SdFat/SdInfo.h:36:15: error: 'const uint8_t SD_CARD_ERROR_CMD0' previously defined here

uint8_t const SD_CARD_ERROR_CMD0 = 0X1;

^

In file included from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:0:

C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:35:15: error: redefinition of 'const uint8_t SD_CARD_ERROR_CMD8'

uint8_t const SD_CARD_ERROR_CMD8 = 0X2;

^

In file included from C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:28:0,

from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:

C:\Program Files\Arduino\libraries\SdFat/SdInfo.h:38:15: error: 'const uint8_t SD_CARD_ERROR_CMD8' previously defined here

uint8_t const SD_CARD_ERROR_CMD8 = 0X2;

^

In file included from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:0:

C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:37:15: error: redefinition of 'const uint8_t SD_CARD_ERROR_CMD12'

uint8_t const SD_CARD_ERROR_CMD12 = 0X3;

^

In file included from C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:28:0,

from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:

C:\Program Files\Arduino\libraries\SdFat/SdInfo.h:40:15: error: 'const uint8_t SD_CARD_ERROR_CMD12' previously defined here

uint8_t const SD_CARD_ERROR_CMD12 = 0X3;

^

In file included from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:0:

C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:39:15: error: redefinition of 'const uint8_t SD_CARD_ERROR_CMD17'

uint8_t const SD_CARD_ERROR_CMD17 = 0X4;

^

In file included from C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:28:0,

from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:

C:\Program Files\Arduino\libraries\SdFat/SdInfo.h:42:15: error: 'const uint8_t SD_CARD_ERROR_CMD17' previously defined here

uint8_t const SD_CARD_ERROR_CMD17 = 0X4;

^

In file included from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:0:

C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:41:15: error: redefinition of 'const uint8_t SD_CARD_ERROR_CMD18'

uint8_t const SD_CARD_ERROR_CMD18 = 0X5;

^

In file included from C:\Program Files\Arduino\libraries\SdFat/Sd2Card.h:28:0,

from C:\Program Files\Arduino\libraries\SdFat\Sd2Card.cpp:20:

C:\Program Files\Arduino\libraries\SdFat/SdInfo.h:44:15: error: 'const uint8_t SD_CARD_ERROR_CMD18' previously defined here

uint8_t const SD_CARD_ERROR_CMD18 = 0X5;

^

And this it just 1/10 of everything :frowning: