1966 views|3 replies

280

Posts

7

Resources
The OP
 

【Running posture training shoes】No.005-Posture recognition and step frequency calculation [Copy link]

 

The previous article introduced the sensor production process and primary data processing designed by myself . This article introduces the most brain-burning part of this work, which is also the core algorithm part: posture recognition and cadence calculation .

First, let me introduce the design idea. I set up 4 pressure sensors on the sole of the foot, numbered as 0, 1, 2, and 3, as shown in the figure below. When walking or running, the order in which these four points reach the maximum pressure point is different, and this order represents different foot postures. For example, when walking with your toes turned inside out, points 0 and 1 reach the maximum pressure earlier than points 2 and 3; when running, if the forefoot touches the ground first, points 1 and 3 will reach the maximum value first, and vice versa, if the heel touches the ground first, points 0 and 2 will reach the maximum value first. As long as this order is calculated, the posture can be identified. Then, the amplitude and duration of the maximum value of each point can be used to further analyze the rationality of the posture.

Figure 1, coordinates of four pressure points on the sole of the foot

From the actual waveform, the overall pattern is relatively regular, and each waveform detail has small fluctuations, as shown in the figure below. It is easy to identify the position of the maximum value by eye, but it is still difficult to implement it with a simple algorithm with low power consumption in the microcontroller program.

Figure 2: The waveform to be analyzed is collected

After repeated experiments, I finally found a way. During the test, I found that there is always a channel whose waveform is more typical than other waveforms, and the periodic pattern is more obvious. The reason is that there is always a point on the sole of each person's foot that is the main force point, and the shape will be prominent. I defined this channel as a typical analysis channel and made it configurable so that it can be changed in actual applications. By analyzing this channel, the period is defined. Another rule I found is that the negative waveform of this sensor I made is more regular than the positive one, and the negative data is used in subsequent calculations.

The method for obtaining the cycle is as follows: take 3 sampling points for continuous sliding window comparison. Judgment condition 1: if the value of the middle point is smaller than the previous and next values, it is considered to be an extreme point; judgment condition 2: record two consecutive extreme points and judge whether the latter reaches 60% of the previous one (this is obtained by actual measurement and can be changed). If it reaches, it is considered to be an effective maximum point. Otherwise, it cannot be reached, it is considered to be an interference value and discarded. Using these two judgment conditions, the first and second points may be interference values, and the latter ones can be automatically identified correctly. The actual measurement accuracy is very high, and there are no missed points. Calculate the number of sampling points between the two extreme points, and multiply it by the sampling time to get the cycle of each step. The code is as follows.

Figure 3, cycle code

With this cycle, the rest is easy. The first thing you can get is the step frequency. Divide 1 minute by the cycle to get the number of steps per minute. The second thing you can get is the pressure sequence. Let me explain this in detail.

The original sampling frequency is 100Hz. After 10-point average filtering, the interval between each sampling point is 0.1 seconds. I use a 32-bit variable to count the sampling point number after filtering. If it overflows, it will take more than 16 years, which is enough to meet the needs of each test. Starting from the identification of the first valid extreme value (minimum value) of the typical channel, the four channels will continuously calculate the extreme value and the sampling point number where the extreme value appears, until the next valid extreme value of the typical channel appears, and then the calculated data will be transferred and the cache will be initialized to start the next round of calculation. The transferred sampling point number is the original value of the posture. I need to convert it into the order value of the coordinate point, that is, to sort the four numbers, and get the order of the corner marks of each number after sorting. It took a lot of brain cells here, and finally found a solution on the Internet. The principle is actually very simple, that is, before sorting the array, make a sequence number array, and sort the original array using the bubble method. At each step of sorting, the sequence number array is also converted synchronously. After sorting, the content of the sequence number array is the corner mark sequence number of the original array. The code is as follows.

Figure 4, gesture recognition code

If you use an array to express the posture directly, the operation is too cumbersome. I abstracted and simplified the result and expressed it in hexadecimal using a 16-bit number to achieve the purpose of simplification. For example, if the posture sequence is: 0->2->3->1, it is expressed by 0x0231. For the posture sequence obtained continuously, 0->2->3->1->0->2->3->1->0->2->3->1->0, any 4 consecutive ones represent the same posture, so for the posture value: 0x0231<=>0x2310<=>0x3102<=>0x1023 are equivalent and can be defined as posture 'a'. In this way, each posture can be expressed with one character, which is much simpler in transmission and use.

The following two pictures are the effects after actual operation, the left one is the real-time waveform, and the right one is the calculation result. The accuracy and stability of posture recognition and cadence calculation are quite good, basically meeting the actual requirements.

Figure 5, calculation results

Figure 6, calculation results

To sum up, the most difficult part of this design has been completed, and we will study functions such as Bluetooth transmission and self-generation later.

Latest reply

The gait recognition of the original poster is somewhat similar to the running elf. However, the self-generation of this one is really amazing. I look forward to the follow-up.   Details Published on 2021-6-21 09:22
 
 

1w

Posts

25

Resources
2
 

How to generate electricity by yourself?

 
 
 

1942

Posts

2

Resources
3
 

The idea is very good. Does self-generation convert potential energy into electrical energy? I'm curious how it can be achieved.

 
 
 

2w

Posts

74

Resources
4
 

The gait recognition of the original poster is somewhat similar to the running elf. However, the self-generation of this one is really amazing. I look forward to the follow-up.

Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
Personal signature

加油!在电子行业默默贡献自己的力量!:)

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list