Hello,
In order to obtain a better understanding of the MPU6050, I performed a simple test. The test results were more or less as expected, with the exception of 2 strange effects. I cannot explain these effects. Hopefully someone on this forum can. I also would appreciate it, if someone could reproduce my test and let me know whether or not the same effects are observed. Thanks in advance!
Test:
I connected a MPU6050 sensor to my Arduino UNO (ADO = high => address = 0X69 instead of 0X68) The Uno was next connected to my computer by means of an USB-cable. I loaded the sketch presented below and ran it. While the sketch was running, I did not touch the MPU6050 and made sure it was as best as possible isolated from movements, shocks and vibrations . After running the sketch, I selected all raw data which was printed in the serial monitor (ctrl a), copied it (ctrl c) and pasted it (ctrl v) in an empty MS/excel file. Next, I used the convert text to column option. I first considered column B, which contains raw acceleration output data related to the x-axis. I determined the maximum (276) en minimum value (-556) as well as the average value (23.05) of the 50000 raw output values. Next, I used the countif function in excel to determine how many times every possible output value (= 16 bit integer) in the range [-556, 276] had occurred. I presented this data graphically in an x-y scatter plot. Raw output data related to ay, az, gx, gy and gz was subsequently considered in an analogue manner.
Result:
The plot related to gx (see attached jpg-image) clearly shows the ‘bell-curve’ I expected. In the plot related to ax, you can still recognise the expected ‘bell curve’, but there are also 2 strange effects:
1- Only raw output values in the min-max range which are a multiple of 4 have a non-zero number count. For example raw output values 103,105,106,107 were never found in the 50000 samples; raw values 104 and 108 were found 423 and 504 times respectively. It appears that the last 2 bits of the 16-bit output value are always low (?)
2- There are some raw values that occur significantly more than expected, yielding clear peaks in the ‘bell curve’ e.g. raw values 16, 20,24 occur 1298, 1772 and 1343 times respectively.
Some additional results / remarks:
1- Distribution of ay and az is similar to that of ax; distribution of gy and gz is similar to that of gx
2- Changing the sensor sensitivity to +/- 8g (accelgyrooo.setFullScaleAccelRange(2)) or +/-16g ‘solved’ the problem: no significant peaks and no ‘value skipping’
3- I performed the test several times: always same results
4- I performed a similar test in which the raw data was written to a SD card and the Arduino was powered by a 9v battery: same results
// raw data MPU6050
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
MPU6050 accelgyrooo (0X69);
int16_t ax, ay, az;
int16_t gx, gy, gz;
long i =0;
void setup() {
Wire.begin();
Serial.begin(38400);
Serial.println("Initializing I2C devices...");
accelgyrooo.initialize();
Serial.println("Testing device connections...");
Serial.println(accelgyrooo.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
accelgyrooo.setFullScaleAccelRange(0); // 0=> +-250deg/s ; 1=> +-500deg/s ; 2=> +-1000deg/s ; 3=> 2000deg/s
accelgyrooo.setFullScaleGyroRange(0); // 0=> +-2g ; 1=> +-4g ; 2=> +-8g ; 3=> +-16g
accelgyrooo.setXAccelOffset(-2337);
accelgyrooo.setYAccelOffset(-2437);
accelgyrooo.setZAccelOffset(1442);
accelgyrooo.setXGyroOffset(186);
accelgyrooo.setYGyroOffset(-85);
accelgyrooo.setZGyroOffset(39);
while (i<500) {
i++ ;
accelgyrooo.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
Serial.print(i); Serial.print(" ; ");
Serial.print(ax); Serial.print(" ; ");
Serial.print(ay); Serial.print(" ; ");
Serial.print(az); Serial.print(" ; ");
Serial.print(gx); Serial.print(" ; ");
Serial.print(gy); Serial.print(" ; ");
Serial.print(gz); Serial.print(" ; ");
Serial.println();
}
}
void loop() {
}

