• API
• FAQ
• Tools
• Archive
daily pastebin goal
37%
SHARE
TWEET

# Untitled

a guest Jan 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //Adding these comment to describe how knock detection works.
2.
3. //- First we find average x, y and z accelerometer values for when base unit is in its stable position after calibration.
4. //- This is the average over (1) second after the filter has been closed.
5. //- Once average found, we check the tilt of the base unit (we also do some additional calculations to map the xyz to a theoretical flat surface).
6. //- If base accel xyz value are 0 on any one of the three axis, we use the 'Flat Base' algorithm.
7. //- If no 0s on all axes, base is tilted on all three axis so we use the 'Tilted Base' algorithm.
8. //- Flat base algorithm: 1. Checks if accel readings on any axes are greater than a threshold (noisefloor).
9. //- Flat base algorithm: 2. If greater than threshold, start storing data to array until we read mutiple noisefloor values again.
10. //- Flat base algorithm: 3. Process this data set- Check it's time-length, average magnitude of x and y compared to z,
11. //and also the size of x,y. If very short time, assume false positive. if long time but z is greater than x,y by 1.2x
12. //then assume FP. If long time and z is less, assume knocked. If long time, z is less than x,y by 1.2x but x or y is greater
13. //than a hard value, assume knocked.
14. //- Tilted base algorithm: 1. Check if accel readings on any axes are greater than a threshold (noisefloor) like the above.
15. //- Tilted base algorithm: 2. If greater than threshold, assume a disturbance may have started and check data to know when disturbance has stopped (until noiselfoor is reached again).
16. //- Tilted base algorithm: 3. If we are not able to return to the same readings as we started after 1 second, assume base has been knocked.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top