Skip to main content
Explorer
July 19, 2023
Solved

IIS2DLPC accelerometer data conversion

  • July 19, 2023
  • 1 reply
  • 1292 views

Hi:

According to the IIS2DLPC datasheet and STMems_Standard_C_drivers are as follows

https://github.com/STMicroelectronics/iis2dlpc-pid/blob/cb5a10d963790fbe8863d4fd9449f8e00ed3cb8a/iis2dlpc_reg.c

 

Myles_0-1689730271516.png

According to the IIS2DLPC datasheet, it seems that the iis2dlpc_reg.c needs to be corrected, such as the red text comment?

float_t iis2dlpc_from_fs2_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.061f;
//return ((float_t)lsb) * 0.244f;
}

float_t iis2dlpc_from_fs4_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.122f;
//return ((float_t)lsb) * 0.488f;
}

float_t iis2dlpc_from_fs8_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.244f;
//return ((float_t)lsb) * 0.976f;
}

float_t iis2dlpc_from_fs16_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.488f;
//return ((float_t)lsb) * 1.952f;
}

float_t iis2dlpc_from_fs2_lp1_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.061f;
//return ((float_t)lsb) * 0.976f;
}

float_t iis2dlpc_from_fs4_lp1_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.122f;
//return ((float_t)lsb) * 1.952f;
}

float_t iis2dlpc_from_fs8_lp1_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.244f;
//return ((float_t)lsb) * 3.904f;
}

float_t iis2dlpc_from_fs16_lp1_to_mg(int16_t lsb)
{
return ((float_t)lsb) * 0.488f;
//return ((float_t)lsb) * 7.808f;
}

thanks

 

    This topic has been closed for replies.
    Best answer by Federica Bossi

    Hi @Myles ,

    Welcome to ST Community!

    Drivers are correct. The coefficient values reported in the PID are considering the sensitivity and the shift of 2/4 bit to have data in right giustified according to the resolution, as written in Datasheet (pg 20 Table 11):

    FedericaBossi_0-1689841970532.png

    Data are always represented in 16 bit and they need to be shift by 2 or 4 according to the power mode (es: in High Performance mode, FS=2g you need to divide 0.244 by 4 = 0.061).

    If my reply answered your question, please click on Accept as Solution at the bottom of this post. This will help other users with the same issue to find the answer faster

    1 reply

    Technical Moderator
    July 20, 2023

    Hi @Myles ,

    Welcome to ST Community!

    Drivers are correct. The coefficient values reported in the PID are considering the sensitivity and the shift of 2/4 bit to have data in right giustified according to the resolution, as written in Datasheet (pg 20 Table 11):

    FedericaBossi_0-1689841970532.png

    Data are always represented in 16 bit and they need to be shift by 2 or 4 according to the power mode (es: in High Performance mode, FS=2g you need to divide 0.244 by 4 = 0.061).

    If my reply answered your question, please click on Accept as Solution at the bottom of this post. This will help other users with the same issue to find the answer faster

    MylesAuthor
    Explorer
    July 21, 2023

    I figured it out, thanks for clearing up my doubts!