1

I'm currently using the MPU-6050 accelerometer to receive the acceleration and angular velocity data. I'm trying to process the data for my experiment but I can't understand the exact meaning of it. I have threee questions about the situation. I append the arduino code below.

First, I happen to know that the AcX value of the code below means how much the sensor is inclined along the x axis. Is there other way to get acceleration directly? or Do I have to use formula(v = v_0 + a*t)?

Second, for the gyro sensor, I can't understand the meaning of the value. Does it sends the angular velocity or angular acceleration and if it is one of these, what's the limit?

Third, according to code, it receives data in the form of 2^14(14bit) but sometimes it sends value way over the limit. How can I translate raw data to rather regular unit like degree and rad?

Thank you

const int MPU_addr=0x68;  // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);  // PWR_MGMT_1 register
  Wire.write(0);     // set to zero (wakes up the MPU-6050)
  Wire.endTransmission(true);
  Serial.begin(9600);
  Serial.println("CLEARDATA");
  Serial.println("LABEL,TIME,AcX,AcY,AcZ,GyX,GyY,GyZ");
}

void loop(){
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);  // starting with register 0x3B (ACCEL_XOUT_H)
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);  // request a total of 14 registers
  
  // deviding the 16bit input??
  AcX=Wire.read()<<8|Wire.read();  // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)    
  AcY=Wire.read()<<8|Wire.read();  // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
  AcZ=Wire.read()<<8|Wire.read();  // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
  GyX=Wire.read()<<8|Wire.read();  // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
  GyY=Wire.read()<<8|Wire.read();  // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
  GyZ=Wire.read()<<8|Wire.read();  // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)

  //Serial.print("AcX = "); 
  Serial.print(AcX);
  Serial.println(",");
  //Serial.print(",");
  //Serial.print(" | AcY = "); 
  //Serial.print(AcY); Serial.print(",");
  //Serial.print(" | AcZ = ");
  //Serial.print(AcZ); Serial.print(",");
  //Serial.print(" | GyX = "); 
  //Serial.println(GyX); 
  //Serial.print(" | GyY = "); 
  Serial.println(GyY); //Serial.print(",");
  //Serial.print(" | GyZ = "); 
  //Serial.println(GyZ);
  delay(200);
}
1
  • Doesn't the datasheet answer these questions? Jul 24 at 10:27
1

Is there other way to get acceleration directly? or Do I have to use formula(v = v_0 + a*t)?

The code appears to be currently retrieving the raw X, Y & Z acceleration and storing it in AcX, AcY & AcZ. The equation "v = v_0 + a*t" appears to be deriving velocity. So the question is confusing.

...for the gyro sensor, I can't understand the meaning of the value. Does it sends the angular velocity or angular acceleration

The accelerometer sensors measure acceleration. As the last question ultimately asked for angles, the gyroscope is not needed. However, on page 12 in the MPU-6050 specifications the dimensions of the gyroscope is given in degrees per second or angular velocity. Likely the mechanism within the chip depends on the Coriolis effect

...and if it is one of these, what's the limit?

On the same page the MPU-6050 chip specification shows a table containing values such as GYROSCOPE SENSITIVITY & Full-Scale Range. Consider reading these and other values regarding the gyroscope.

...according to code, it receives data in the form of 2^14(14bit) but sometimes it sends value way over the limit.

The code retrieves a high 8 bit and low 8 bit value for each axis of the accelerometer and the gyroscope. This makes a 16 bit value. Not a 14 bit value.

How can I translate raw data to rather regular unit like degree and rad?

  1. To obtain an angle in degrees only the accelerometer is required.
  2. Consider calibrating the accelerator for offset and magnitude errors before using the raw values.
  3. Consider constraining the problem such that the accelerometer is only rotated around the Z-axis.
  4. The angle can be found by taking the inverse tangent of the ratio of the calibrated X acceleration and calibrated Y acceleration.

Other considerations:

  • If angles are desired in 3 dimensional space consider using commonly referred to values such as pitch, roll & yaw. In which case many situate the accelerometer such to use these equations:

enter image description here

The above equations, a discussion and some example code can be found here.

  • So far, all the equations discussed use trigonometry and can go to infinity (unusable results) given certain inputs. The mathematical equivalent of gimbal lock if you will. To avoid this consider using quaternions. This mathematical method of representing rotation in 3 dimensional space does not suffer the above problem, is easier for computers to calculate and is used extensively in computer graphics.
10
  • Re “All the sensors measure acceleration”: gyroscopes measures angular velocity, not angular acceleration. The unit used in the datasheet for gyro data is degrees per second. Jul 24 at 12:47
  • That's interesting. I can't imagine how mechanically such a device is made. If you and I are both correct, then the MPU-6050 must be doing some type of integration to get velocity (i.e. to get a constant value for a MPU-6050 gyroscope situated at the center of an operating 33 & 1/3 RPM phonograph record player).
    – st2000
    Jul 24 at 13:41
  • Ah, never mind, I see how it's done: Coriolis effect. Learn something new everyday.
    – st2000
    Jul 24 at 13:50
  • FYI, for anyone reading this, looking at the answer and scratching their head ... I changed the answer to match what @EdgarBonet was commenting on. Thank Edgar!
    – st2000
    Jul 24 at 14:28
  • 1
    Curiosity is a good thing! I have only worked with a couple of IMUs. But have found they report acceleration (and, of course, angular velocity). Keep in mind deriving position from acceleration is very difficult. Deriving position is not ordinarily done with only acceleration data. The difficulty comes when dealing with the accumulated errors. The only exception I am aware of is gaming. Here, since you are in a virtual world, ending up half way across the living room, as long as you don't hit anything, isn't that big of a deal.
    – st2000
    Jul 25 at 18:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.