MPU6050 I2CDevlib Information

Hi there,

I have recently started using I2Cdevlib with my MPU6050 and would like some more information on how the library works without using it blindly.

  1. How does the Digital Motion Processing (DPM) within the chip work? What does it do?
  2. How does the interrupt work? What is it caused by? I have a heavy sketch going on in the meantime (SD card, display, heart rate sensor.etc) in the background. Can it still be used with all these modules without delaying other functions?
  3. How does the library incorporate quaternions?

I tried looking for all these answers but could not find relevant info.

Thanks!

The DMP is supposed to estimate the body orientation of the sensor, however, the folks who make the MPU6050 are not forthcoming about how it works.

If you want to learn this stuff, study the RTIMUlib library for Arduino, where all the calculations are done in open source code, and it can use a number of different sensors.

Thanks! Do you have any information on the quarternions and interrupts regarding this project?

ddesousa:
Hi there,

I have recently started using I2Cdevlib with my MPU6050 and would like some more information on how the library works without using it blindly.

  1. How does the Digital Motion Processing (DPM) within the chip work? What does it do?
  2. How does the interrupt work? What is it caused by? I have a heavy sketch going on in the meantime (SD card, display, heart rate sensor.etc) in the background. Can it still be used with all these modules without delaying other functions?
  3. How does the library incorporate quaternions?

I tried looking for all these answers but could not find relevant info.

Thanks!

The DMP is a program provided by InvenSense and is precompiled. you can find the latest version of their Development code here: Software Downloads | InvenSense Developers


Embedded MotionDriver 6.12
Embedded MotionDriver 6.12 is our first ever 9-axis solution not locked to a specific MCU.Version 6.1.2 is an update to 6.1 that includes bug fixes and new libraries. This release is supported across all ARM Mx core architectures and supports the InvenSense MPU-6000, 6050, 6500, 9150, and 9250. The release includes optimized libraries and example projects for M3 and M4 cores as well the generic ARM library for any Mx core and an additional library and project for the TI MSP430. eMD 6.1 also includes a Python client for both visualizing the sensor performance and commands for printing data. This solution will allow you to easily leverage and configure numerous features of the DMP and also benefit from dynamic features in the MPL software library. Libraries specific to IAR, Keil, and GCC are included.

  1. The DMP calculates quaternions to be used and stores them in a FIFO buffer. upon completion of each calculation a interrupt is triggered. NOTE the FIFO buffer can overflow if ignored requiring a reset and an additional wait. The Wait period between calculations can be changed. I use 10 mS duration for my projects which works well with the UNO.

2)Yes you can do all kinds of things between interrupts which makes this an ideal MPU to add to already intense projects. the disadvantage is that you need to load the MPU6050 program into the chip each time you power on. this uses a chunk of memory. The latest version of the precompiled program is larger than the one provided in the library by Jeff Rowberg and I have not been able to incorporate it to fit in my UNO

8/24/2011 by Jeff Rowberg jeff@rowberg.net
Updates should (hopefully) always be available at GitHub - jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs

  1. It spits out quaternions in the FIFO buffer I believe it is possible to generate quaternions with only the accelerometer portion of the chip but I use both the Gyro and Accelerometer with my balancing bot.

Z

Hi there,

I am using the MPU6050 and I2CDevlib library to obtain quaternion values from the sensor. This sketch is currently taking up a bit too much memory for my liking and I noticed that there is a 64 byte buffer. Since I am only using one set of data, is there anyway to go into the library and not input the other data such as acceleration and gyro?

Thanks

are you including the MPU6050_6Axis_MotionApps20.h Library to achieve the communication between your UNO and the MPU6050?

I am.

Thanks! That really helped! I only need quaternions and not the other data sets. Do you know if there is anyway to not incorporate the other data sets into the FIFO buffer to reduce flash and RAM?

ddesousa:
I am.

This is the most refined code I have that uses that library See if it will work for you :slight_smile: The library consumes a huge chunk of memory by itself.
I used it on my balancing bot
Z

MPU6050_Latest_code.ino (7.98 KB)

ddesousa:
Thanks! That really helped! I only need quaternions and not the other data sets. Do you know if there is anyway to not incorporate the other data sets into the FIFO buffer to reduce flash and RAM?

The quaternions FIFO buffer code is precompiled this is sent to the MPU6050 at startup. With this said i believe you sould discover the flags that enable what data is sent to the fifo buffer reducing the size. but this may not improve memory as it only changes what the FIFO buffer gets. Jeffs code simplified programming by defaulting most of the settings into the array of bytes. you might be able to determine which byte affects the fifo buffer contents and adjust it.

see code around line 300 of the MPU6050_6Axis_MotionApps20.h

    0x07,   0x41,   0x05,   0xF1, 0x20, 0x28, 0x30, 0x38, // CFG_8 inv_send_quaternion
    0x07,   0x7E,   0x01,   0x30,                     // CFG_16 inv_set_footer
    0x07,   0x46,   0x01,   0x9A,                     // CFG_GYRO_SOURCE inv_send_gyro
    0x07,   0x47,   0x04,   0xF1, 0x28, 0x30, 0x38,   // CFG_9 inv_send_gyro -> inv_construct3_fifo
    0x07,   0x6C,   0x04,   0xF1, 0x28, 0x30, 0x38,   // CFG_12 inv_send_accel -> inv_construct3_fifo
    0x02,   0x16,   0x02,   0x00, 0x01                // D_0_22 inv_set_fifo_rate

i'm not sure how to disable the send for the other data the configuration is here. but I know that there is code in the development package that can do this. I have not researched it thoroughly. I'm not sure this will help with your problem.
Z

Thanks for the info! Yeah, I have taken a hard look at the library code but I cant seem to find the place where I toggle what info gets sent to the buffer.

ddesousa:
Thanks for the info! Yeah, I have taken a hard look at the library code but I cant seem to find the place where I toggle what info gets sent to the buffer.

The library doesn't have the functions that the *Embedded MotionDriver 6.*12 has so you may need to dig through that to spot the trick. II remember seeing several functions that enable
FIFO features. As I tried toto create a new Arduino library using the latest 6.12 motion driver. I'm afraid it uses allot more memory. And I have delayed further with at this time. But I remember there example code for AVR processors having several more functions available to use specifically with FIFO section and configuration
Z

ddesousa:
Thanks for the info! Yeah, I have taken a hard look at the library code but I cant seem to find the place where I toggle what info gets sent to the buffer.

Found more about the enabling disabling of these features
Page 10 of 14 describes the feature. This Document is found in the motion_driver_6.12\documentation folder of the The program provided by InvenSense. you can find the latest version of their Development code here: Software Downloads | InvenSense Developers with the above mentioned/Attached below documentation.

Z

App Note 3- Motion Driver 6.12 Porting Guide.pdf (646 KB)