2021-09-22 03:03 PM
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
Solved! Go to Solution.
2021-09-27 01:18 AM
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ò
2021-09-24 07:42 AM
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ò
2021-09-24 09:22 AM
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
2021-09-24 11:37 AM
The gyroscope output can be used to differentiate between dropping and rotating to upside down.
Cheers, Hal
2021-09-24 12:40 PM
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
2021-09-24 02:52 PM
<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
2021-09-27 01:18 AM
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ò