1

I'm trying to create an IMU unit using MPU-6050 unit.

I've got 100k data records, and this is the result:

Gyro x,y,z readings

It seems to me that's a kind of offset in gx. Why?

Accel x,y,z

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)); 
Mauro Assis
  • 111
  • 2
  • where do the graphs come from? ... how is the data in the graphs selected? ... maybe you are graphing an incorrect parameter – jsotola Oct 08 '20 at 22:12
  • 1
    The graphs were made based on data saved on a CSV file in a SD card connected to arduino. – Mauro Assis Oct 09 '20 at 15:40
  • I changed the question including the data structure that's is used to store data and the code that save it. – Mauro Assis Oct 09 '20 at 18:03
  • The graphs show values much larger than can be stored in an int. Could you show a line from your CSV file? – ocrdu Oct 17 '20 at 11:09

0 Answers0