Improving SD Writing Speeds with Arduino Mega 2560

Hello, I am working on a project and am a bit stuck. I am developing a knee brace that acquires data from sensors and prints to an SD for later analysis. We are looking to collect this data at 250 Hz, and with the amount of sensors on the brace, the necessary writing speed would be approximately 18KB/s (18 float values collected per sample* 4 bytes per float * 250Hz = 18,000 bytes/second). Currently, we are only able to write to the SD at a rate of about 3.6KB/s (50Hz where we want 250Hz). We know the bottleneck of our system is at the point of SD reading because the sampled data can be stored in local memory at 250Hz, meaning the sensors are being read fast enough.

We have tried using the SdFat library to speed things up, but have not found success. Is 18KB/s writing speed an achievable goal in this project? Any input is greatly appreciated.

I worked with Bill G, @fat16lib, the author of SDFat.h a few years ago, to capture 16 bit data at 44.1KHz rate (basically a single channel of CD quality audio), so float data (same as 2 ints) at 22.05KHz should be possible.

Wow, 2013 - I need to get back to that project one of these days!

SdFat has several features to reliably log data at high rates. A Mega 2560 may be able to log at 250 Hz. This example logs four ADC values at 500 HZ. With a Due it can log at 4,000 Hz.

For fast logging you can't beat Teensy 4.1. This example can log at over 20,000 HZ.

If it's possible to collect data using DMA, Teensy can log ADC data at over one MHz.

Teensy can record quad 16-bit 44.1 kHz audio.

Edit: Teensy can record oct (8-channel) 16-bit 44.1 kHz audio.

Have you tried one of the examples from the SDfat to check the basic performance of your hardware? If the SD card does not perform with an example it would be a prime candidate for limiting your application. Not sure if Bill has included the examples he uses to measure the SD card performance with the library.

If all the hardware performs adequately with the examples, it will suggest your code needs attention.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.