Fast serial port to SD card data logger

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Fast serial port to SD card data logger

Post by fat16lib »

I have posted a program that can log data from a serial port to an SD card using the Data Logging Shield.

This program can log data at 57,600 baud when used with a 328 Arduino and at 115,200 baud when used with a Mega Arduino.

The logger uses a new serial library that allows large RX and TX buffers and has better error checking than the standard Arduino HardwareSerial driver. This allows data overrun errors to be detected so you can be sure data is not being lost.

The data logging program, the new SerialPort library, and a modified version of the SdFat SD library are posted as SerialLoggerBeta20120108.zip here http://code.google.com/p/beta-lib/downloads/list.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Fast serial port to SD card data logger

Post by adafruit »

nice! would it not work to just bump up the buffers on the hardware serial object to 256 bytes?

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: Fast serial port to SD card data logger

Post by fat16lib »

SD cards have occasional write times of over 100 milliseconds for single block write mode so you need a lot of buffering to go fast.

The other option is to create a large contiguous empty file and write it using multi-block mode. This requires raw SD writes.

User avatar
fat16lib
 
Posts: 595
Joined: Wed Dec 24, 2008 1:54 pm

Re: Fast serial port to SD card data logger

Post by fat16lib »

Here is more detail on buffering:

I use a 1024 byte RX buffer on a 328 Arduino that provides 174 milliseconds of buffering at 57,600 baud and a 4096 byte RX buffer on the Mega that provides 347 milliseconds at 115,200 baud. A few SD cards may fail on 328 Arduinos since the SD spec allows occasional write times of 250 milliseconds. My experience is most SD cards can log sustained data at 57,600 baud on a 328 Arduino.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”