Arduino_LSM9DS1 icon indicating copy to clipboard operation
Arduino_LSM9DS1 copied to clipboard

Accelerometer at 16g outputs wrong values

Open PhySan0111 opened this issue 5 years ago • 2 comments

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 avatar Nov 12 '20 14:11 PhySan0111

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.

PhySan0111 avatar Nov 12 '20 16:11 PhySan0111

for 16g:

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

or 0.732 / 1000

ldab avatar Sep 15 '21 15:09 ldab