cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get acceleration from sensitivity of LIS2DE12?

Surya K
Associate II
Posted on June 19, 2018 at 07:40

Hi

I am using the accelerometer LIS2DE12 with MC60. Can you tell me how I can calculate the acceleration from the sensitivity being displayed?
4 REPLIES 4
Miroslav BATEK
ST Employee
Posted on June 19, 2018 at 09:59

Cast the raw value to signed variable and multiply it by sensitivity according to the selected Full Scale.

0690X0000060LJzQAM.png
Posted on June 19, 2018 at 10:04

Uh I didn't get you. Where do I get the selected FS bits from?

Sorry I'm a complete newbie  
Posted on June 19, 2018 at 10:13

In CTRL_REG4 register.

0690X0000060LJvQAM.png
Surya K
Associate II
Posted on June 29, 2018 at 10:19

Can someone tell me if the functions and calculations I am using are correct? If yes, how do I get the value of acceleration along the X-axis? If no, what am I doing wrong? Please let me know. Took 

ACCLEROMETERSENSITVITY

value as 2.

u16 Accelerometer_ReadRawData_X(void)

{

    u16 lowerByte;

    u16 upperByte;

    u16 axiesX;

    Accelerometer_ReadReg(&lowerByte, LIS2DE_OUT_X_L); // Function to read value in register LIS2DE_OUT_X_L

    Accelerometer_ReadReg(&upperByte, LIS2DE_OUT_X_H);

    axiesX = (u16)upperByte;

 

    return axiesX;

}

u16 Accelerometer_ReadSensitivity_Xaxies(void)

{

    u16 value = Accelerometer_Sensitivity(Accelerometer_ReadRawData_X());

    return value;

}

u16 Accelerometer_Sensitivity(u16 input)

{

    u16 value;

    u16 sensitivityVal;

    switch(ACCLEROMETERSENSITVITY)

   {

        case 2:

            value = 16;

            break;

        case 4:

            value = 8;

            break;

        case 8:

            value = 4;

            break;

        case 16:

            value = 2;

            break;

        default:

            value = 16;

            break;

    }

    sensitivityVal = (u16)input * 1000/(1024*value);

    return sensitivityVal;

}