I'm trying to create an IMU unit using MPU-6050 unit.
I've got 100k data records, and this is the result:
It seems to me that's a kind of offset in gx. Why?
Why I'm getting this kind of drifting in acz?
This is the setup code:
void setup_mpu_6050_registers(){
//Activate the MPU-6050
//Start communicating with the MPU-6050
Wire.beginTransmission(0x68);
//Send the requested starting register
Wire.write(0x6B);
//Set the requested starting register
Wire.write(0x00);
//End the transmission
Wire.endTransmission();
//Configure the accelerometer (+/-8g)
//Start communicating with the MPU-6050
Wire.beginTransmission(0x68);
//Send the requested starting register
Wire.write(0x1C);
//Set the requested starting register
Wire.write(0x10);
//End the transmission
Wire.endTransmission();
//Configure the gyro (500dps full scale)
//Start communicating with the MPU-6050
Wire.beginTransmission(0x68);
//Send the requested starting register
Wire.write(0x1B);
//Set the requested starting register
Wire.write(0x08);
//End the transmission
Wire.endTransmission();
}
And this is the reading code:
void read_mpu_6050_data(){
//Read the raw gyro and accelerometer data
//Start communicating with the MPU-6050
Wire.beginTransmission(0x68);
//Send the requested starting register
Wire.write(0x3B);
//End the transmission
Wire.endTransmission();
//Request 14 bytes from the MPU-6050
Wire.requestFrom(0x68,14);
//Wait until all the bytes are received
while(Wire.available() < 14);
//Following statements left shift 8 bits, then bitwise OR.
//Turns two 8-bit values into one 16-bit value
myData.msecs = millis();
myData.acc_x = Wire.read()<<8|Wire.read();
myData.acc_y = Wire.read()<<8|Wire.read();
myData.acc_z = Wire.read()<<8|Wire.read();
myData.temp = Wire.read()<<8|Wire.read();
myData.gyro_x = Wire.read()<<8|Wire.read();
myData.gyro_y = Wire.read()<<8|Wire.read();
myData.gyro_z = Wire.read()<<8|Wire.read();
}
The structure that stores data is:
struct datastore {
long msecs;
int acc_x, acc_y, acc_z;
int temp;
int gyro_x, gyro_y, gyro_z;
};
Then I save data in the card:
logFile.write((const uint8_t *)&myData, sizeof(myData));

