This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Clearing my doubts...

I was thinking whether its feasible to use a 8-bit counter with auto-reload to capture the number of peaks detected within 100ms.

Parents Reply Children
  • meaning that i want to get the number of heartbeats per min...

  • meaning that i want to get the number of heartbeats per min...

    ... and your "heartbeat sensor" will output one peak per heartbeat ?

    In that case, counting the number of peaks within 100 ms will only give you one of two answers: One or zero -at least if you're looking at a human heart, which will only go above 240 bpm (4 beats/s) in very pathological situations.

  • Yea. One peak per heartbeat.
    You mean getting the heartbeat peaks within 100ms is too short?

    I have to get the peak within 1sec? and multiply it by 60 to get the pulse per min?

  • You mean getting the heartbeat peaks within 100ms is too short?

    Yes, way too short.

    I have to get the peak within 1sec? and multiply it by 60 to get the pulse per min?

    That would still be a very unsatisfactory approach.

    Consider a situation where you have 65 beats per minute. If you measure the number of beats in each second, you'll still only get two different values: 1 and 2. So your display would mostly be showing "60 bpm" and once every couple of seconds jump to "120 bpm".

    Even worse, if you have 55 bpm, you'll end up with 1 or 0 beats per second (and usualy, having a heart rate of 0 bpm isn't a good thing).

    You either need to count the number of beats in a much longer interval (for example, 60 seconds), which will give you a nice, steady average value but will be very slow to respond to heart rate changes.
    Or you measure the time between two heart beats, which will give you great beat-to-beat accuracy but a very unsteady number (you could output an average of this number over several beats to get a more stable output).

  • If i measure the time between 2 heartbeats, how do i convert it to bpm?

    "you could output an average of this number over several beats to get a more stable output"

    Meaning i have to repeat the cycles several more times to get a more stable output?

  • High-end equipment always measures the time between each individual beat. Then it is possible to display a frequency (after averaging) and to perform jitter analysis of the data. For example, the heart beat interval changes when you are filling the lungs. If the body isn't stressed, the heart can avoid fighting for the same space with the lung. This can be used to estimate over-training.

  • If i measure the time between 2 heartbeats, how do i convert it to bpm?

    Frequency (f) is the inverse of period (T):

    f = 1/T

    Measuring the time between two heartbeats gives you the period T in a unit of your choice (if you don't want to deal with fractional numbers or floating point just yet, I would suggest you use milliseconds at this point, but you'll need to do some fractional calculations later on).

    For example, if you measure 750 ms, you would get

    f = 1/(0.75 s) = 1.33 Hz = 80 bpm

    Meaning i have to repeat the cycles several more times to get a more stable output?

    Yes. The heartbeat has quite a bit of beat-to-beat variation, and if you don't want to see that in your application, you can average several measurements (how many depends on how stable you'd like the number and how slow of a response to changes you can accept).

  • "High-end equipment always measures the time between each individual beat. Then it is possible to display a frequency"

    You mean using a oscilloscope? If not, my sensor is a simple DIY sensor connected to an amplifier of 100 gain.

  • T = 1/f, so f = 1/T.

    When displaying the information, you might want to measure the sum of five intervals. Divide by five (gives you an average for the five intervals).

    1120ms => 1/ 1.120 => 0.89 Hz
    0.89 Hz * 60 => 53 bpm

  • The 1120ms is the average time of the time between 2 heartbeats for 5 cycles?

    If so, how can i use programming to measure the time between the 2 heartbeats?

  • Oscilloscope? You are aware that the heart beat speed in bmp is a frequency? Why would you want to use an oscilloscope to display the bmp? An oscilloscope isn't used to display a frequency (possibly to measure a frequency) but to display the shape of a curve.

    It is only for stress analysis where it would be nise with a graph to display the inter-beat variation, but that is something completely different from measuring the heart beat frequency.

  • You can use a high-speed counter and capture the time of a pulse. After you have captured enough pulses, you know (from the running counter) how long time has passed according to the counter tick frequency and number of ticks.

  • Oh. But how do you use programming to get the time between 2 heartbeats?

  • If so, how can i use programming to measure the time between the 2 heartbeats?

    You will need to set up one time to generate your "base" clock (1 millisecond ticks). Then you use either an interrupt or polling (heart rates are slow enough to allow this) to wait for the heartbeats.

  • I see... So I'm using a integrated 16-bit counter with capture... Thanks...