Jump to content
I2Cdevlib Forums

Efficiently reading raw data?


Recommended Posts

Hi,

How do you just read MPU6050_RA_ACCEL_XOUT_H and get all 6 register values for void MPU6050::getMotion6(.....) ?

Thank you in advance.

 

 

details

------------------------------------------------------------------------------------------

how I would implement getMotion6()    (see https://github.com/Snowda/MPU9250/blob/master/MPU9250.cpp)

{

  uint8_t msb = readRegister(MPU9250_ACCEL_XOUT_H);

  uint8_t lsb = readRegister(MPU9250_ACCEL_XOUT_L);

  *ax = (((int16_t)msb) << 8) | lsb;

 

  msb = readRegister(MPU9250_ACCEL_YOUT_H);

  lsb = readRegister(MPU9250_ACCEL_YOUT_L);

  *ay = (((int16_t)msb) << 8) | lsb;

 

 //repeat for az gx gy gz

.

.

.

}

 

 

 

 

 

 

the way he implemented getMotion6()  that I couldn't understand.  (see https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.cpp)

{


    I2Cdev::readBytes(devAddr, MPU6050_RA_ACCEL_XOUT_H, 14, buffer);

    *ax = (((int16_t)buffer[0]) << 8) | buffer[1];

    *ay = (((int16_t)buffer[2]) << 8) | buffer[3];

    *az = (((int16_t)buffer[4]) << 8) | buffer[5];

    *gx = (((int16_t)buffer[8]) << 8) | buffer[9];

    *gy = (((int16_t)buffer[10]) << 8) | buffer[11];

    *gz = (((int16_t)buffer[12]) << 8) | buffer[13];


}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...