-
Notifications
You must be signed in to change notification settings - Fork 471
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
Comments
Is there a question here?
…On Fri, May 20, 2022 at 5:11 PM Gawsalyan Sivapalan < ***@***.***> wrote:
—
Reply to this email directly, view it on GitHub
<#478>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTDLKUKAN5Q5UNDG2MUOJTVLASZXANCNFSM5WQ6SY6Q>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Hi @kriswiner, I find that the read operations are only performed in ACCEL_XOUT_H and GYRO_XOUT_H. 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) |
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? |
Yes, Thanks a lot for the clarification :) |
Most sensors have the ability to automatically increment the register
address. For some, like many ST sensors, one has to set a bit in a control
register to allow this to happen. For Invensense (TDK) sensors, this is
done automatically.
…On Fri, May 20, 2022 at 5:21 PM Gawsalyan Sivapalan < ***@***.***> wrote:
Yes, Thanks a lot for the clarification :)
—
Reply to this email directly, view it on GitHub
<#478 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTDLKU2ORODCY3XC5QGXQ3VLAT7HANCNFSM5WQ6SY6Q>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yes, Thanks again for the clarification, I didn't realize that we are reading a contiguous memory :) |
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]) ;
}
The text was updated successfully, but these errors were encountered: