Is anyone familiar with MPU6050? I got it running on Baby-O


I am trying to see if anyone is familiar with the lovely MPU6050 3-axis 16-bit accelerometer and gyroscope (real 16-bit, not 13-bit hiding in 16bits :):)). A cool guy, Jeff Rowberg, made some wonderful demo code to get up and running on the Arduino UNO, and I struggled for 16+ hours to get it running on the Baby-O. What can I say, I’m a newb, I didn’t even know how to properly program the baby orangutan.

[size=85](for reference, the key is to change the IC2Dev library to account CPU_FREQ = “20…” instead of “16…” AND (this stumped me for ages) change where it says TWBR = “16000 / khz” to “CPU_FREQ/ TWI” because for some reason at one point it properly defines TWBR to be related to CPU_FREQ, but then in another point it redefines TWBR to be based on some static integers. The second TWBR would mess up I2C communication.)[/size]

I’m asking if anyone is familiar with the MPU6050 because I’m trying to optimize the settings for my tilt-sensing application.

The questions I have, which relate to Jeff Rowberg’s code:,
which according to the 'net is fairly typically used if anyone wants to run this sensor with the DMP calculations.

  1. When I do the demo code for pitch/roll/yaw, I notice the values are only given to 2 decimal digits. I’m a bit confused, because I don’t see them being truncated anywhere. I only need them to two decimal points, but i was hoping to ensure it wasn’t that I was killing the data early. 2) I want to have my Accelerometer set to +/-2g. All my trawling has taught me that these are the relevant things:
    define MPU6050_ACCEL_FS_2 0x00 //I think this sets the range to +/– 2g.
    define MPU6050_ACONFIG_AFS_SEL_BIT 0 //I changed this from 4, to 0, because I think 0 corresponds with +/– 2g
    define MPU6050_ACONFIG_AFS_SEL_LENGTH 5 //This was 2, but I don’t understand what it does to the code, except that it doesn’t seem to harm output. ???

So I’m not totally clear when SEL_LENGTH does, and I don’t understand if it’s AFS_SEL_BIT that determines the range, or FS_2, or both. It seems there are also some things that I could optimize to reduce the sampling rate, since I don’t need more than a sample a second, but it might be beyond me.

So i thought among the curious Pololu people, someone had tried running the MPU6050, or at least would want to know the quick dirty details to use the baby-O in the Arduino IDE along with the MPU6050

I got a response from Jeff Rowberg, which largely sort of nulls the point of this thread. However, I am still curious if anyone here has tried out the MPU6050 on an orangutan.

“Wow, I really need to set up a forum on i2cdevlib. :–)
Typically you don’t want to change any of the #defined values, but instead effect different behavior with class methods and different parameters. The ACCEL_FS_2 is the value which represents +/– 2g, correct. The AFS_SEL_BIT is the bitfield position in the config register. Changing this will have undesirable results. The AFS_SEL_LENGTH is the number of bits which the AFS_SEL field takes. The register map from InvenSense says this field is 2 bits wide, hence the value 2. Changing this will also have undesirable results. You are probably really looking for the “setFullScaleAccelRange()” method. However, the power-on value of the module is already +/– 2g, so this is probably unnecessary.
Incidentally, the data from the DMP is calculated internally on the module, and I’m not sure that setting the full scale accel range even has an effect on how it works. If you’re using the DMP6 example sketch, the 2-decimal-place rounding is due to the AVR’s handling (or possibly the Serial.print() function’s handling) of float variables. The original data from the DMP is coming across as four quaternion elements, represented as signed ints in the range of [-16384, 16384] and then scaled to floats in the range of [-1.0, 1.0]. These values are computed into angles (no idea exactly how, I just found some code that worked). Any precision loss is going to happen there, if at all.
I hope this helps!”