The current methodology outputting data as a csv ascii file using the MMA8452Q Sparkfun library to communicate with two sensors is unable to keep up at the 800Hz data rate. Two potential optimization methods should be considered.
Serial Compression
Current output is a csv ascii formatted file
sensor ID, time(ms), X acceleration, Y acceleration, Z acceleration
synchronization is depicted as true if "C" and "D" are capital letters, and false if "c" and "d" are lower case
The size of each component is:
SensorID: 2 bit
Synchronization: 1 bit
MMA8452Q Acceleration X: 12 bit
MMA8452Q Acceleration Y: 12 bit
MMA8452Q Acceleration Z: 12 bit
Teensy Time: 32 bit
These could be compressed and written with Serial.write()
Sensor Reading
The current method to read data from each accelerometer is to use the Sparkfun Library:
#include <Wire.h> // Must include Wire library for I2C
#include <SparkFun_MMA8452Q.h> // Includes the SFE_MMA8452Q library
void setup() {
MMA8452Q accelA(0x1C);
}
void loop() {
if (accelA.available())
{
accelA.read(); // updates accelA.x,y,z,cx,cy,cz
}
}
This method handles all the register reading and bit shifting, but contains the unnecessary overhead of converting each 12 bit value to a float. This could be replaced using a custom script to read the registers and send the data over serial in a compressed was more effificently.
The current methodology outputting data as a csv ascii file using the MMA8452Q Sparkfun library to communicate with two sensors is unable to keep up at the 800Hz data rate. Two potential optimization methods should be considered.
Serial Compression
Current output is a csv ascii formatted file
example:
The size of each component is:
These could be compressed and written with Serial.write()
Sensor Reading
The current method to read data from each accelerometer is to use the Sparkfun Library:
This method handles all the register reading and bit shifting, but contains the unnecessary overhead of converting each 12 bit value to a float. This could be replaced using a custom script to read the registers and send the data over serial in a compressed was more effificently.
Serial Baud Rate
\ Note that the baud rate for the Teensy is always 12Mbps over Serial no matter what settings is set for