Skip to main content
Gk.1
Associate III
January 23, 2021
Solved

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

  • January 23, 2021
  • 4 replies
  • 2506 views

..

This topic has been closed for replies.
Best answer by Eleon BORLINI

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

4 replies

Andrew Neil
Super User
January 23, 2021

Isn't that in the LIS2DW12 datasheet?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Eleon BORLINI
Eleon BORLINIBest answer
ST Employee
January 28, 2021

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
March 24, 2023

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
March 24, 2023

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