1

I'm using a heart rate sensor along with an Arduino for a project of mine. I have to determine whether the heartbeat is following a particular pattern (eg: when when heartbeat regularizes a lot after a period of increased or largely varying, I need to trigger an alarm to show that it has regularized).

Can anyone give me suggestions on how I can go about doing this? Are there any libraries or software for doing basic statistical analysis on data like this?

2
  • I think you might be better looking at 'generic' C or C++ libraries for stats and then porting them to an Arduino. Not sure how complete the Maths lib is on Arduinso though Commented Jan 20, 2017 at 13:49
  • Seems like you only need to calculate the BMP, or beat per minute. Measure the time between e.g. 5 beats. Then divide 300000 (5*60*1000) by this time in milliseconds. You use the average of 5 beats to get a more stable number.
    – Gerben
    Commented Jan 20, 2017 at 15:48

1 Answer 1

1

This Arduino topic is an over-simplification and not very robust, but it presents in code the basic principle of threshold detection and the subtraction of adjacent pulse times (period). BPM = 60.0 / period in seconds.

If you want something that would work under a larger range of conditions, you can add the three primary missing features used by medical instrumentation.

  1. Automated zeroing, which can be accomplished with an analog filter and pull-up or with a digital high pass filter that attenuates frequencies below 0.3 Hz. This can be done with a series capacitor leading to the analog input being sampled, with a pull up resistor to V+ and another resistor to ground to center the Voltage to an appropriate positive steady state value.
  2. Attenuation of frequencies above those representing a pulse to avoid false triggers from high frequency noise, cross-talk, or transients, which can be accomplished with an analog filter or with a higher sample rate and a digital low pass filter that attenuates frequencies above 100 Hz 1.
  3. Dynamic range compression, which detects the trend in pulse amplitude and continuously adapts the trigger threshold accordingly to avoid false indication of beats or the missing of weaker but legitimate beats.

To do the filtering digitally, you may want to read up on DSP (digital signal processing). There are several great books on it, and you can search for simple algorithms for both low pass filters and high pass filters in GitHub or elsewhere in the open source community.


[1] Wikipedia's article on low pass filters

1
  • Great answer! I would add that the first thing to do is to get a few sample waveforms from the same hardware setup in order to test the algorithms and choose the parameters (e.g. cutoff frequencies) on the computer, before porting to the Arduino. Commented Jan 29, 2017 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.