How the pedometer algorithm is implemented
The pedometer algorithm can be divided into four categories, one is the peak detection algorithm, the second is the transform domain algorithm, and the third is the filtering algorithm The fourth is the pattern recognition algorithm. According to the different positions of the designed pedometer on the human body, such as the wrist, waist, sole, etc., different pedometer algorithms can be selected. Take the most widely used peak detection algorithm as an example:
1, GetGetMotion Track strong>
During exercise, the user may put the device in a pocket or bag, or hold it in his hand, so the orientation of the device is uncertain. So first, by calculating the vector lengths of the three accelerations, we can obtain a sinusoidal trajectory of the walking motion.
2, peak valuedetection
We recorded the last vector length and motion direction. Determine the current acceleration direction and compare it with the last saved acceleration direction. If it is the opposite, that is, just after the peak state, enter the step counting logic to count steps, otherwise discard this paragraph. By accumulating the peak times, we can calculate the number of steps the user walks.
3. Noise Removal (Interference)
Handheld devices such as mobile phones or smart watches will There are some low-amplitude and fast twitching states, which are commonly known as hand tremors, or a user wants to simulate walking by shaking the device repeatedly for a short time. This kind of interference, we can filter by adding threshold and cadence judgment to the detection.
At present, the fastest running frequency of humans is 5HZ (of course, it is not excluded that the running frequency of humans using other equipment exceeds this frequency), that is to say, the time interval between two adjacent steps is at least greater than 0.2 seconds, as shown in the figure If the time interval between two steps is less than 0.2 seconds, the step will not be counted. This way we filter out high frequency noise, i.e. cases where the step frequency is too fast. At the same time, we compare with the last acceleration and set a certain threshold Threshold to judge whether the movement is valid (the green line in the figure), and only the valid movement can be recorded.
4, EstimatedMotion status
If the number of steps walking and running is known, Then through the body height, weight and gender, you can roughly know the person’s step length, and after improvement, it can be turned into a distance measuring and speedometer. Through the three-axis acceleration sensor, we can know the user’s movement state. In addition to step counting, you can also use the acceleration sensor, gyroscope and magnetic sensor fusion to calculate the walking track to prevent the phenomenon of wrong step counting.
Smart PedometerAlgorithmDetailed Thought
1, MotionMotionThreshold
The motion acceleration generally presents a sinusoidal change. When the motion speed increases, the maximum and minimum values increase. When high, the average should also follow the trajectory. Therefore, the motion threshold is a dynamic value, adaptive, and fast enough.
The accelerometer continuously updates the three-axis data, collects and filters, and determines the maximum and minimum values. We update the threshold once in groups of 50 samples. The average value (max+min)/2 is used as the “motion threshold”. The dynamic accuracy is divided by itself, the motion variation is divided into grades, and the current accuracy value is determined according to the size of the motion threshold.
2. StepsStepsJudgment
(1) Definition of the conditions for taking steps: The change in acceleration is positive or negative when the acceleration curve crosses above the dynamic threshold or when the acceleration curve crosses below the dynamic threshold.
(2) Use the linear shift register, dynamic threshold and dynamic precision to judge whether the individual has taken an effective step. Establish two registers, the new register and the old register; after the current data is collected, it is judged whether to move into the new register, and the move-in condition is satisfied: the acceleration change is greater than the current dynamic accuracy. Move the currently collected data into the new register, otherwise new remains unchanged. Whenever new data arrives, the value of the new register is unconditionally moved into the old register. In this way, the influence of high-frequency noise can be avoided, and the judgment accuracy can be improved.
(3) Simultaneous detection of three-axis acceleration, but as long as the acceleration of one axis changes the most, this axis can be used as the motion direction, and the other axes are ignored.
3. Specific Program
(1) Sampling filter, obtain the average value of the 3 axes, and obtain the acceleration max, min.
(2) For every 50 samples, find the peak value, and then set the threshold.
(3) Calculation precision.
(4) The average value of the sampling filter is processed and then compared with the precision (by a shift register to remove high frequency noise, making the value more accurate).
(5) Determine the dynamic threshold, compare the values, and then add 1 to the number of steps.
Declare: The above methods are derived from the program system index or shared by netizens. They are for your reference only and do not represent the research views of this website. sex and authority.