cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12: access LIS2DH12 in historical order?

mchahn
Senior

I want to let the LIS2DH12 FIFO fill and wrap freely and then at a point in time access the history (LIS2DH12 contents) in a particular manner.  I want to first read the newest 15 samples (in any order) and then read the oldest 15 (in any order).  I need to compare the average of the older 15 to the average of the newer 15.  Can this be done?

Background ...

I am designing a camera and I'm using a sensor that doesn't have anti-shake.  I've included an LIS2DH12 on the PCB.  The theory is that I can look through the acceleration data and detect shake (motion jerks).  If I see the new readings average is significantly different from the old average then I will know a jerk has happened.  I will keep taking captures from the sensor until I see that there were no jerks during the capture. 

I tried just averaging the acceleration vector magnitude (sum of squares) across all samples and use a threshold as a jerk detection.  Unfortunately I couldn't find a threshold that correlated with jerks.  I think the info was swamped by the gravity numbers.

Can anyone suggest another way to detect jerks?  This is an interesting challenge but I've not been up to the challenge so far.

1 ACCEPTED SOLUTION

Accepted Solutions
mchahn
Senior

I've got a solution I'm pretty happy with.  If anyone cares, this is what I'm doing ...

I'm running the FIFO in stream mode.  After I capture a picture I'm reading the output regs 32 times to get all the FIFO contents which represent the acceleration during the capturing.  I get the max and min values for each axis.  I then calculate the difference between the max and min (peak-to-peak values) and I compare this peak-to-peak value against a threshold.

View solution in original post

1 REPLY 1
mchahn
Senior

I've got a solution I'm pretty happy with.  If anyone cares, this is what I'm doing ...

I'm running the FIFO in stream mode.  After I capture a picture I'm reading the output regs 32 times to get all the FIFO contents which represent the acceleration during the capturing.  I get the max and min values for each axis.  I then calculate the difference between the max and min (peak-to-peak values) and I compare this peak-to-peak value against a threshold.