Step counting solution based on G-sensor
1. Pedometer model features
G-sensor can detect three-axis acceleration (unit g), and only one gravitational acceleration is detected when stationary
G; When a person walks, the acceleration in the corresponding direction will be generated relative to the motion posture.
Figure 1 Schematic diagram of walking posture
As shown in Figure 1, when walking, the main movement directions are the forward direction and the vertical direction, showing periodic changes;
Vertical direction: When the foot is lifted, the center of gravity is upward, and the acceleration increases in the positive direction; when the feet touch the ground, the center of gravity moves down, and the acceleration decreases in the opposite direction;
Horizontal direction: When the foot is raised, the acceleration increases; when the foot is retracted, the acceleration decreases.
The acceleration values of the three axes are synthesized into an acceleration vector, which is basically a sinusoidal variation law when walking, as shown in Figure 2; peak and valley values are generated every time period, and the length and direction of the acceleration vector are judged by judging the length and direction of the acceleration vector. , to judge whether the peak or trough is passed, and calculate the number of steps in real time through the calculation of the peak-to-peak value and the acceleration threshold decision.
G-sensor parameters: range 2g; unit 16384 LSB/g; data update frequency 500Hz.
Figure 2 Acceleration sampling value curve
2. Step counting algorithm
In actual walking, there will be a lot of clutter interference in the acceleration detection value. It is necessary to filter and remove the interference through an algorithm, obtain a real and effective gait, and count the steps by accumulating the number of steps. It mainly includes three parts:
The pedometer algorithm processing process is divided into three parts:
Polling every 1s to determine whether a valid step is generated, divide the step counting state into one process, generate a time stamp, and save it as a step counting process record.
Stop step counting: If no valid steps are detected, it will enter the stop step counting state.
Expected steps: Valid steps are detected, but the number of steps does not exceed a certain number of steps (10 steps).
Formal step counting: if the detected valid steps exceed a certain number of steps, the step count data is effectively accumulated.
3. Other status monitoring
Fall state: the moment when the direction axis of gravitational acceleration changes in the official step counting state.
Sprinting state: In the official pedometer state, the period of the time window is significantly faster.
The normal adult running speed is 10~15km/s; the walking speed is 5~7km/s; so the running time window is about 2~3 times that of walking.