Hi,
I'm having trouble following how to properly setup free fall detection on the LIS2DH12. I'd like to generate an interrupt when the device goes from rest to free falling for a couple feet. The duration of the fall would be approximately 200ms. I'm a bit confused by how the combination of the INT1_CFG, INT1_THS and INT1_DURATION registers affect free-fall detection. Some questions:
- INT1_CFG - what are the differences in high vs low interrupt enabling? If low is enabled, does it wait for the current reading to drop below INT1_THS threshold value for INT1_DURATION? Conversely if high is enabled, does it wait for the current reading to rise above INT1_THS threshold value for INT1_DURATION?
- A free-fall algorithm would typically detect three states, (1) Resting (+/- 1g on one or more axis, depending on how the chip is oriented) to initial acceleration (+/- N acceleration increase on the axis, or axes, of fall direction), (2) Initial acceleration to free fall (acceleration on axis (or axes) of fall direction is ~ 0g), (3) Free fall to impact (+/- N acceleration increase on axis, or axes, of fall direction). If doing this algorithm manually, I would use a vector magnitude calculation (sqrt(x^2 + y^2 + z^2) for the three axis and compare to various thresholds. The benefit of the vector magnitude is that it abstracts away the need to know the exact orientation of the chip to know what exact axis, or axes) to monitor in a fall event. Is the chip capable of doing a calculation similar to this to detect free fall? Perhaps it is related to the and/or setting in INT1_CFG?
- Is the closest I can get to such an algorithm described above to set the chip to OR the x, y, and z axis interrup events and set an event for when any axis goes above 1g for a certain duration to find when the initial acceleration event from rest occurred?
- If my chip is oriented in a way that I am standing upright and it measures -1g on the z-axis at rest, would a threshold value of 350mg be treated as exceeding -1350mg in the Z-axis when I make my initial acceleration increase towards free fall?
Any example c code implementations of free fall would be greatly appreciated also.
Thank you!