cancel
Showing results for 
Search instead for 
Did you mean: 

IIS2DLPC accelerometer data conversion

Myles
Associate

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Federica Bossi
ST Employee

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

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

2 REPLIES 2
Federica Bossi
ST Employee

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

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

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