Using LowLatencyLogger and MPU6050 to get DMP Data

Hi,

So I''m trying to get DMP data (Linear Real World Accel) from the MPU6050 accelerometer and gyro, and I've got a program that appears to work. I've searched the forums and haven't found anyone else who's done this.

I used the LowLatencyLogger (SdFat) example posted here using MPU6050 raw data values:
http://forum.arduino.cc/index.php?topic=326182.0

And have used the Jeff Rowberg MPU6050_DMP6 example for DMP.

Now it seems to work although I think I have a small issue.

Note: The DMP spits out the data at 100Hz, which is fast enough for me.
LowLatencyLogger can usually do about 500Hz.

Basically the LowLatencyLogger has this line:

//Interval between data records in microseconds.
const uint32_t LOG_INTERVAL_USEC = 10000;

I've set it 10000 microseconds. Now if i set this higher than 10k microseconds then I will get a 'FIFO Overflow' Error becuase I am not reading data from the DMP fast enough.

If I set this lower than 10k microseconds than the SdFat logData() function will through an error at me

 error("LOG_INTERVAL_USEC too small");

It feels like because of this, the code is a bit precarious, but I'm looking for advice on how to adjust this to make it safe.

Note: After a few more tests, it seems that sometimes the error("LOG_INTERVAL_USEC too small") will still show up, but other times not.

Also: another thing that happens sometimes is that after an amount of time say 15 seconds the DMP data just comes through as random numbers (junk data). Not sure if this is caused by the same thing though.

I have attached my code if anyone would like to have a look at it. Thanks.

Edit: I'm using Arduino Uno.

MPU6050RawLowLatencyLogger_MOD_DMP.zip (7.17 KB)

Hi,
The code you gave does not compile.

Error.

MPU6050RawLowLatencyLogger_MOD_DMP.ino:226:41: error: a function-definition is not allowed here before '{' token

could someone please tell me why this won't compile ?