My project aims to develop a mobile IMU which logs data to an SD card at 100-200Hz. I am currently using:
- Adafruit FLORA 9 DOF sensor as the IMU (only communicates with I2C)
- Adafruit trinket pro + adafruit SD breakout for logging
The IMU and logger work fine (most of the time) but I am not getting the rate that I require. Currently I am only getting 50Hz max, and this is highly variable.
I have adapted SdFat's logging library which was initially for analog data but I am using it with the I2C sensor. I have gone through an characterized the code to try and find out why I seem to be limited to loop times of 20ms minimum (see commented code below). Getting the sensor event takes ~5ms, writing the data to the card takes ~5ms.
Other than further optimizing the SD libraries and IMU code is there anything I could do to increase this rate or may this be a fundamental limit of the SPI interface with the SD card and I2C with the sensor? Does this current rate that I am achieving seem to be near the limits of what may be possible for this hardware or are there other ways in which I can optimize my code?
Any suggestions or help much appreciated!
dataLogger_SdFat_27oct_27novMOD.ino (9.06 KB)