Skip to main content
Visitor II
September 22, 2021
Solved

Question about LSM6DS3h : why Accel Z value OUTZ_L_XL (2Ch) & (2D) become negative when module acceleration downward but not upside down.

  • September 22, 2021
  • 5 replies
  • 1616 views

I am using this chip to get the X & Y angle of the unit. First read out

OUTX_L_XL (28h) & 29h

OUTY_L_XL (2Ah) & 2Bh

OUTZ_L_XL (2Ch) &2Dh

and calculate Roll and Pitch.  

The angles works good in normal / slow moving or stable condition.

Also need to detect if device is not up side down ( where Z value is negative ).

However, if the device drop fast from high to low, Z value will suddenly become negative for that short acceleration period and so the situation consider to be an up side down.

Did anyone try that?

Is that normal? how can we solve it?

Thanks!

Martin

    This topic has been closed for replies.
    Best answer by niccolò

    Hi Martin @Community member​ ,

    ok, that's good =)

    in this case I would add a check: the device should be considered upside down only if a certain number of consecutive values are negative

    the duration of this check should depend on your application

    Niccolò

    5 replies

    ST Employee
    September 24, 2021

    Hi Martin @Community member​ ,

    what happens is expected, because you are reading only one half of the output (the most sensitive one)

    you are reading a two's complement number, if you want to get the right value, you should pick both the OUTX_L_XL (Low part) and OUTX_H_XL (High part) of the output

    the fact that the Zaxis turns negative is due to the fact that the lower half of the word changes so much that it seems negative reading only that.

    (if you just want to check the sign, you can also read only the High half of the output)

    hope this helps

    Niccolò

    MLyAuthor
    Visitor II
    September 24, 2021

    HI Niccolo,

    Oh, I did not write it clear. I did read out both high and low value of all X, Y and Z values. Then use to calculate roll and pitch.

    Thanks for the reminder.

    Martin

    niccolòAnswer
    ST Employee
    September 27, 2021

    Hi Martin @Community member​ ,

    ok, that's good =)

    in this case I would add a check: the device should be considered upside down only if a certain number of consecutive values are negative

    the duration of this check should depend on your application

    Niccolò

    Graduate
    September 24, 2021

    The gyroscope output can be used to differentiate between dropping and rotating to upside down.

    Cheers, Hal

    MLyAuthor
    Visitor II
    September 24, 2021

    Hi Hal,

    Then how to identify if it is dropping or upside down?

    Should we continuously checking X and Y tilt angles or the Gyro angles?

    Thanks!

    Martin

    Graduate
    September 24, 2021

    <Should we continuously checking X and Y tilt angles or the Gyro angles?>

    Pick a time interval for the drop event, integrate the gyro rate over that time and see if it adds up to a rotation.

    Continuous checking suggests a circular buffer for for the gyro rate.

    Cheers, Hal