cancel
Showing results for 
Search instead for 
Did you mean: 

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

MLy
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

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ò

View solution in original post

6 REPLIES 6
niccolò
ST Employee

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ò

MLy
Associate II

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

raptorhal2
Lead

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

Cheers, Hal

MLy
Associate II

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

raptorhal2
Lead

<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

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ò