a guest Jan 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- //Adding these comment to describe how knock detection works.
- //- First we find average x, y and z accelerometer values for when base unit is in its stable position after calibration.
- //- This is the average over (1) second after the filter has been closed.
- //- 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).
- //- If base accel xyz value are 0 on any one of the three axis, we use the 'Flat Base' algorithm.
- //- If no 0s on all axes, base is tilted on all three axis so we use the 'Tilted Base' algorithm.
- //- Flat base algorithm: 1. Checks if accel readings on any axes are greater than a threshold (noisefloor).
- //- Flat base algorithm: 2. If greater than threshold, start storing data to array until we read mutiple noisefloor values again.
- //- Flat base algorithm: 3. Process this data set- Check it's time-length, average magnitude of x and y compared to z,
- //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
- //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
- //than a hard value, assume knocked.
- //- Tilted base algorithm: 1. Check if accel readings on any axes are greater than a threshold (noisefloor) like the above.
- //- 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).
- //- 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