2021-04-13 12:32 AM
Hello,
I am still new to accelerometers, and I am trying to understand the logique of how to decode the raw data using the sensitivity.
In the datasheet of the LIS2DH12 accelerometer, in page 10: Mechanical characteristics, the unit of the sensitivity is (mg/digit), isn't it supposed to be the inverse ? (digit/mg)
Because when I used another accelerometer (LIS3DSH), the granularity (or the scale) of the sensitivity is less than 1 with a unit of (mg/digit).
For example, if I take the FS bit set to 10, High-resolution mode case (Measurement range = 8) from the LIS2DH12, which has a sensitivity of 4, if I take the inverse of it ( 1/4 ), I get 0.25, which is quite close to LIS3DSH's sensitivity in the case of FS bit set to 011 (Measurement range = 8) that is equal to 0.24.
So I am a little bit confused, if someone could clear this for me.
Thank you
2021-04-13 05:13 AM
Hi @ARema.1 ,
both LIS3DSH and LIS2DH12 sensitivity are expressed in milli-g / digit, so at least the two datasheet are coherent ;)
The fact is that, taking for example the FS equal to 2g and the high-resolution mode for both accelerometer, the sensitivity is (almost) equal to FS / 2^(nbits-1) in both cases, but the nominal nbits is different (-1 since you have to consider the sign bit).
For the LIS2DH12, it is 12, so the resolution is 2 g / 2^11 bits = 0.96mg/digit (almost 1 mg/digit as shown in the datasheet), while for the LIS3DSH the value is 16, i.e. 2/2^15 = 0.06 mg/digit, coherently with the other datasheet.
That is, the dataout is defined on the 12 MSbits or 16 MSbits ("left shifted").
You can also refer to the C drivers on Github for both sensors:
float_t lis2dh12_from_fs2_hr_to_mg(int16_t lsb)
{
return ( (float_t)lsb / 16.0f ) * 1.0f;
}
float_t lis3dsh_from_fs2_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.06f;
}
The calculations include the int16 casting for the two's complement conversion and the eventual bit shifts in terms of divisions.
Let me know if this can dissipate your doubts.
-Eleon