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

Accelerometer at 16g outputs wrong values #14

Open
PhySan0111 opened this issue Nov 12, 2020 · 2 comments
Open

Accelerometer at 16g outputs wrong values #14

PhySan0111 opened this issue Nov 12, 2020 · 2 comments

Comments

@PhySan0111
Copy link

PhySan0111 commented Nov 12, 2020

Hi all,

I used your library with some small changes. Instead of using 4g for the accelerometer, I tried to switch to 16g. So, I modified the following lines:
in the begin method used: writeRegister(LSM9DS1_ADDRESS, LSM9DS1_CTRL_REG6_XL, 0x88);//0x70 is 119 Hz, 4G, and 0x88 is 238Hz, 16G

Then in the readAcceleration methods to:

int LSM9DS1Class::readAcceleration(float& x, float& y, float& z)
{
  int16_t data[3];

  if (!readRegisters(LSM9DS1_ADDRESS, LSM9DS1_OUT_X_XL, (uint8_t*)data, sizeof(data))) {
    x = NAN;
    y = NAN;
    z = NAN;

    return 0;
  }

  x = data[0] * 16.0 / 32768.0;
  y = data[1] * 16.0 / 32768.0;
  z = data[2] * 16.0 / 32768.0;

  return 1;
}

When reading the data with the arduino faced up I read values like this:
0.02 0.03 0.68
which does not seem correct since z, should output 1.0g
After further investigation I use 24.0g for the scale and the output was correct and as expected
Am I doing some wrong? or am I the only one facing this problem?

Thanks in advance

Best regards,

@PhySan0111
Copy link
Author

There is an error.

When calculating the scale for the sensitive one cannot use SCALE/32768. This formula works others for all the others sensitivities on the accelerometer but fails for the 16G.

According to the datasheet:
image

but 16/32768 does not correspond to the sensitity value. However 24g will give that value. I have contacted ST to advise.

@ldab
Copy link

ldab commented Sep 15, 2021

for 16g:

  x = data[0] * 0.000732;
  y = data[1] * 0.000732;
  z = data[2] * 0.000732;

or 0.732 / 1000

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