How may I detect dormancy by using MMA8451Q?
The problem is due to regular vertical 1G acceleration, but the body is not always "right" oriented.
So in common case I always have certain non zero values on all 3 axes, even when the body does not move.
I Alexander,
As a matter of fact, the computation of measured Acceleration vector magnitude (Vx^2 + Vy^2 + Vz^2) is implemented in our FXLS8471Q accelerometer device. This feature is named "Acceleration Vector-Magnitude" detection, see description in datasheet §8.9.
You can program detection threshold and the device will raise an interrupt whenever it is reached. You can only have one threshold but this may still be enough to detect dormancy (you cannot stay in free fall condition forever).
There could also be another way to overcome this limitation by feeding the x/y/z reference values registers that will be subtracted to the measured vector prior to the magnitude computation.
At last, FXLS8471Q pinout is pretty close to MMA8451Q so you may want to give it a try.
Regards, Jacques.
Mille mercis, Jacques
One improvement - we may exclude heave square root, by referencing to R^2
(1 - 2*eps) < R^2 < (1 + 2*eps)
The strait forward solution is to compare resulting acceleration (i.e. geometrical sum over all of axes) to the 1G
Let
Vx, Vy and Vz are proper values of axes X, Y and Z accordingly.
Thus
R^2 = Vx^2 + Vy^2 + Vz^2 , where R is resulting acceleration
Now if
(1 - eps) < |R| < (1 + eps), where eps is a tolerance,
then we may conclude our body does not experience additional acceleration.
The problem is heavy calculation:
R = sqrt( Vx*Vx + Vy*Vy + Vz*Vz )
- 3 multiplication
- 1 square root
One improvement - we may exclude heave square root, by referencing to R^2
(1 - 2*eps) < R^2 < (1 + 2*eps)