OSU-Geomatics / OregonState_DLM

DLM Accelerometers
GNU General Public License v3.0
2 stars 0 forks source link

Optimize Teensy Acquisition/Transmission #1

Open hokiespurs opened 8 years ago

hokiespurs commented 8 years ago

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

example:

A,1289,-0.086,0.168,0.992
B,1292,-0.051,0.133,0.996
A,1293,-0.090,0.172,0.988

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:

#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.

Serial Baud Rate

\ Note that the baud rate for the Teensy is always 12Mbps over Serial no matter what settings is set for

Serial.begin()