Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading ACCEL and Gyro Registers are wrong? #478

Open
gawsalyan opened this issue May 21, 2022 · 6 comments
Open

Reading ACCEL and Gyro Registers are wrong? #478

gawsalyan opened this issue May 21, 2022 · 6 comments

Comments

@gawsalyan
Copy link

gawsalyan commented May 21, 2022

Hi @kriswiner,

I find that the read operations are only performed in ACCEL_XOUT_H and GYRO_XOUT_H.
Why other Y,Z registers and _L (lower bit) registers are not used?

It seems like only ACCEL_XOUT_H register is read 6 byte and used in all? instead of ACCEL_XOUT_H, ACCEL_XOUT_L, ACCEL_YOUT_H, ACCEL_YOUT_L, ACCEL_ZOUT_H, ACCEL_ZOUT_L

Same applies to Gyro

e.g.

void readAccelData(int16_t * destination)
{
uint8_t rawData[6]; // x/y/z accel register data stored here
readBytes(MPU9250_ADDRESS, ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array
destination[0] = (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value
destination[1] = (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ;
destination[2] = (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ;
}

@gawsalyan gawsalyan changed the title Reading ACCEL and MAG Registers are wrong? Reading ACCEL and Gyro Registers are wrong? May 21, 2022
@kriswiner
Copy link
Owner

kriswiner commented May 21, 2022 via email

@gawsalyan
Copy link
Author

Hi @kriswiner,

I find that the read operations are only performed in ACCEL_XOUT_H and GYRO_XOUT_H.
Why other Y,Z registers and _L (lower bit) registers are not used?

It seems like only ACCEL_XOUT_H register is read 6 byte and used in all? instead of ACCEL_XOUT_H, ACCEL_XOUT_L, ACCEL_YOUT_H, ACCEL_YOUT_L, ACCEL_ZOUT_H, ACCEL_ZOUT_L

Same applies to Gyro

e.g.

void readAccelData(int16_t * destination)
{
uint8_t rawData[6]; // x/y/z accel register data stored here
readBytes(MPU9250_ADDRESS, ACCEL_XOUT_H, 6, &rawData[0]); // Read the six raw data registers into data array
destination[0] = (int16_t)(((int16_t)rawData[0] << 8) | rawData[1]) ; // Turn the MSB and LSB into a signed 16-bit value
destination[1] = (int16_t)(((int16_t)rawData[2] << 8) | rawData[3]) ;
destination[2] = (int16_t)(((int16_t)rawData[4] << 8) | rawData[5]) ;
}

@kriswiner
Copy link
Owner

This function:

readBytes(MPU9250_ADDRESS, ACCEL_XOUT_H, 6, &rawData[0]); **

reads six bytes, starting from the ACCEL_XOUT_H register and incrementing the register address until all six bytes for the accel are read and stored in the rawData buffer.

It does not read the same register six times. Is this what you are asking?

@gawsalyan
Copy link
Author

Yes, Thanks a lot for the clarification :)

@kriswiner
Copy link
Owner

kriswiner commented May 21, 2022 via email

@gawsalyan
Copy link
Author

Yes, Thanks again for the clarification, I didn't realize that we are reading a contiguous memory :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants