Skip to main content
Visitor II
May 14, 2018
Question

Accelerometer Reading Issue

  • May 14, 2018
  • 3 replies
  • 2851 views
Posted on May 14, 2018 at 15:01

Hi There,

I am using the STM Accelerometer(LIS2DE12) with STM(stm32l432kb) controller.

While getting the readings from the Accelerometer it gives the random value continuously. Even it shows false value at steady position.

Here some how I am facing problem and need some idea and suggestion to solve this issue. If some one has the document , relevant data and sample code for it please let me know and help me.

Thanks

    This topic has been closed for replies.

    3 replies

    ST Employee
    May 14, 2018
    Posted on May 14, 2018 at 16:56

    Are you able successfully to read the WHO_AM_I register?

    K_P_DAuthor
    Visitor II
    May 15, 2018
    Posted on May 15, 2018 at 11:33

    Yes Miroslav B, I am getting 0x33 after reading the WHO_AM_I register....

    ST Employee
    May 15, 2018
    Posted on May 15, 2018 at 22:10

    OK, good.

    So please share your sensor configuration, and the data which you read.

    K_P_DAuthor
    Visitor II
    May 21, 2018
    Posted on May 21, 2018 at 15:13

    Hi

    Batek.Miroslav

    I getting the output now i have configure the register with below details:-

    (Reg_Add,Loaded_value)

    (0x1E, 0x10) // CTRL_REG0 register

    (0x20,0x9F) // CTRL_REG1 register

    (0x23, 0x00)// CTRL_REG4 register

    (0x24, 0x00) // CTRL_REG5 register

    (0x2E, 0x00) // FIFO_CTRL_REG register

    while (1)

    {

    MemAdd = 0x29; // 0x29 address for the X-Axis

    HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_x, 1, 1000);

    MemAdd = 0x2B; // 0x2B address for the Y-Axis

    HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_y, 1, 1000);

    MemAdd = 0x2D; // 0x2D address for the Z-Axis

    HAL_I2C_Mem_Read(&hi2c3, ACC_ADDRMR, MemAdd, I2C_MEMADD_SIZE_8BIT, (uint8_t *)&rx_data_z, 1, 1000);

    HAL_Delay(100);

    }

    In the output i am getting the value but it not showing the constant value. It shows 0, 255, 254 at steady position in X and Y-Axis. In Z-Axis it shows 64(or 63,62) constantly. But yes when we move it, it shows the change value as per the movement.

    So here I am little bit confused for my output that it is okay or not.

    Is it so? or am I wrong?

    All correction will be helpful and welcome.

    Best regards.

    Sachin

    ST Employee
    May 22, 2018
    Posted on May 22, 2018 at 21:00

    Your measurement is correct.

    To get the acceleration value in g unit, you have to firts convert the raw data into signed value and then multiply it by sensitivity defined in datasheet.

    0690X0000060KstQAE.png

    So in your case for X, Y axis: 0 ... 0g, 255 ... -16mg, 254 ... -32 mg (basicaly noise). for Z axis 64 ... 1024 mg (gravity).

    K_P_DAuthor
    Visitor II
    May 23, 2018
    Posted on May 23, 2018 at 14:34

    Hi

    Batek.Miroslav

    ,

    For sure, that's all I need! ...

    All the answers are really useful.

    Many Thanks for your kind response.

    I am trying to get speed(velocity) using

    Accelerometer(LIS2DE12) this for my hobbyist project. I have searched a lotfor that, it would be great if you can give a suggestion from your experience.

    Thanks &Regards

    Sachin

    ST Employee
    May 23, 2018
    Posted on May 23, 2018 at 21:21

    Velocity is integral of the

    https://en.wikipedia.org/wiki/Acceleration

     so you have to integrate the acceleration in discrete domain, for example like this:

    velocity = velocity + acceleration * (1.0f / data_rate_Hz);

    The accleration must be in m/s2, it means multiply the acceleration in g by 9.81m/s2.