cancel
Showing results for 
Search instead for 
Did you mean: 

Hii...i need to know the conversion method for the raw accelerometer data into mg for LIS2DW12 sensor...just the conversion formula

Gk.1
Associate II
 
1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @Gk.1​ ,

you can of course find the LSB-to-physical-unit conversion formula on the datasheet or on the app note.

You can refer to the C drivers on Github, and in particular the lis2dw12_reg.c:

float_t lis2dw12_from_fs2_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.061f;
}

-Eleon

View solution in original post

4 REPLIES 4
Andrew Neil
Evangelist

Isn't that in the LIS2DW12 datasheet?

Eleon BORLINI
ST Employee

Hi @Gk.1​ ,

you can of course find the LSB-to-physical-unit conversion formula on the datasheet or on the app note.

You can refer to the C drivers on Github, and in particular the lis2dw12_reg.c:

float_t lis2dw12_from_fs2_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.061f;
}

-Eleon

NEche.1
Associate

Hello @Eleon BORLINI​,

I'm not sure where the value 0.061 come from. I can't find it in the datasheet or app note. What I can find are these values (in the datasheet):

0693W00000aJfTVQA0.pngAnd these others from the app note(which are the same):

0693W00000aJfTaQAK.png 

Perhaps in the C driver there's some scaling? Could you please explain further, perhaps I'm missing something?

C driver:

/**
  * @defgroup    LIS2DW12_Sensitivity
  * @brief       These functions convert raw-data into engineering units.
  * @{
  *
  */
 
float_t lis2dw12_from_fs2_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.061f;
}
 
float_t lis2dw12_from_fs4_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.122f;
}
 
float_t lis2dw12_from_fs8_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.244f;
}
 
float_t lis2dw12_from_fs16_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.488f;
}
 
float_t lis2dw12_from_fs2_lp1_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.061f;
}
 
float_t lis2dw12_from_fs4_lp1_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.122f;
}
 
float_t lis2dw12_from_fs8_lp1_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.244f;
}
 
float_t lis2dw12_from_fs16_lp1_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.488f;
}

Eleon BORLINI
ST Employee

Hi @NEche.1​ ,

since the data in the Github formulas, to convert from 16-bit to 14-bit you have to divide for 2^2 = 4, i.e. a shift left of two positions.

This is the same as:

float_t lis2dw12_from_fs2_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.244f / 4;
}

-Eleon