Heart rate detection
Hardware
This week, we continued the test of the second-order filter and started to compile the code. The filter that worked successfully last week failed again. We carefully checked every possible cause but still found no problems. The method was to connect the signal generator to the input of the filter and the oscilloscope to the output of the filter. A sine wave signal of a certain frequency was input and it needed to check if this signal can pass through the circuit normally. We checked the circuit and the connection was good. Next, the components were checked one by one and no problems was found. Some of the components were also replaced. However, the situation didn’t improve much.In addition to the retest of filter, the compilation of the code has also begun. We plan to display the value of heart rate on the screen of the Arduino. Only in this way can the smart watch play a practical role.
Then, we simulated the filter.
The result verified that the principle of the second order filter was correct and it should work as expected. However, it did not work in fact because of some problems in hardware.
Software
This
week, we worked out the software algorithm of
the heart rate detector, which is shown below.
Illustration:
1. input
signals (100Hz) 200 samples per group
2. Smooth
the input by calculating the mean value of each four continuous samples and
storing the outcome into a new array; Find the maximum and minimum value of the
smoothed signal to obtain the threshold value by the formula:
threshold
= (maximum + minimum)/2;
3. Judge
each two adjacent samples whether they conform to that the former is lower than
the latter and the threshold value is between these two. If yes, the variable
of heart beats counters plus one and goes into the filter. If no, refill them
with next two samples.
4. After
then, a filter is applied to filter off the average heart rate which is over
200 or under 50. Also put three continuous average heart rates into an array to
calculate these differences to check if the sensor is put stably on the hand
without any unexpected situation. if these differences are smaller than the
limited value, then the display will finally show your heart rate. repeat it by
replacing the new sample to the oldest sample in the array.
For
the result of it, with the input of strobe light with different frequencies,
the output is shown below.
Figure 1: Result for 1.5 Hz strobe light
Figure 2: Result for 1 Hz strobe light
Figure 3: Result for 3 Hz strobe light
In
these three figures, the heart rate detector could accurately detect the heart
rate within restricted difference and all the outcomes are approximately
equivalent to the correct heart rate within error ±2.5 beats/min.
评论
发表评论