I have an IMU sensor that outputs gyro data at 3200 Hz and accelerometer data at 1600 Hz. I need to log it to an SD card (or maybe output the data to serial port) at this rate. My current experiments with the Arduino have only produced ~300 Hz sample rate over a serial port at 230,400 baud (the max my computer port will go to) so I turned to using an SD card on a logger shield instead.
I'm logging time using micros() (4 bytes) and six uint16_t values (12 bytes) for a total of 16 bytes per sample.
I've only used Arduino a handful of times, so I'm relatively ignorant of the options. Questions:
Is using an Arduino Uno (or Mega) appropriate for logging at these data rates?
If so, are there specific ways I should look at optimizing the data collection speeds?
If not, are there other microcontrollers that would be more suitable?
Priority is easy of use - just needs to be a simple, fast data logger. Thanks in advance for any help!
The only reason I can see to log data that rapidly is to analyze it later, on a larger, faster machine.
So why not collect the data on a faster machine and analyze it in place? The Raspberry Pi has at least 200 fold throughput compared to the Arduino and is about the same size.
The sensor data will eventually be used real-time at these rates on a faster FPGA based control system, but it is not currently developed. I'm trying to do preliminary testing/characterization of the sensor to the extent possible and had a box of Arduinos readily available.
Is it feasible to collect data on an Arduino at this rate or should I look into other microcontrollers? I've seen some different libraries optimized for speed but wanted to get a feel for feasibility before I put a lot of time into implementation. Thanks!
Is it feasible to collect data on an Arduino at this rate or should I look into other microcontrollers?
Probably not. I don't think the SD card routines are much faster than the serial port at its fastest, and they are singly buffered so data loss could be a problem.
Incidentally, with some effort you can do much better than 300 samples/second at 230,400 baud, which would be 23,040 bytes/second. Assuming 16 byte data blocks (all 16 of which are most likely not needed), the throughput should be at best about 1440 blocks/second.
Thank you for the input, as a pure speed test I was able to get a 4 byte timestamp to write to the SD card file at ~1800 Hz and to the serial port ~2000 Hz, but it looks like it's pretty much maxed out (and this doesn't include sampling/writing the IMU data yet).
I'll start looking into other microcontroller options for faster logging.