How to Calculate Heart Rate from Ppg Signal

PPG Signal Heart Rate Calculator

Frequency at which the sensor captures data points per second.
The number of data points (samples) between two consecutive systolic peaks.

Heart Rate Result

function calculatePPG() { var fs = parseFloat(document.getElementById('samplingRate').value); var N = parseFloat(document.getElementById('sampleInterval').value); var resultDiv = document.getElementById('ppgResult'); var bpmOutput = document.getElementById('bpmOutput'); var timeOutput = document.getElementById('timeOutput'); if (isNaN(fs) || isNaN(N) || fs <= 0 || N <= 0) { alert("Please enter valid positive numbers for sampling rate and sample count."); return; } // Calculation Logic: // 1. Calculate Peak-to-Peak Interval (PPI) in seconds: T = N / fs // 2. Calculate Heart Rate (BPM): BPM = 60 / T // Simplified: BPM = (60 * fs) / N var ppiSeconds = N / fs; var bpm = (60 * fs) / N; bpmOutput.innerHTML = Math.round(bpm * 100) / 100 + " BPM"; timeOutput.innerHTML = "Inter-beat Interval: " + (Math.round(ppiSeconds * 1000)) + " ms"; resultDiv.style.display = "block"; }

Understanding PPG Heart Rate Calculation

Photoplethysmography (PPG) is an optical technique used to detect blood volume changes in the microvascular bed of tissue. To calculate the heart rate from a raw PPG signal, you must identify the rhythmic peaks caused by the cardiac cycle.

The Mathematical Formula

The core of heart rate estimation from digital signals relies on the relationship between the sampling frequency and the distance between detected peaks. The formula is:

BPM = (60 × Sampling Rate in Hz) / Number of Samples between Peaks

Step-by-Step Calculation Guide

  1. Identify the Sampling Rate ($f_s$): This is defined by your hardware (e.g., an Arduino or MAX30102 sensor). A common $f_s$ is 100Hz.
  2. Detect the Peaks: Process the PPG waveform and identify the "Systolic Peaks" (the highest points of the wave).
  3. Count Samples ($N$): Count how many data points exist between Peak A and Peak B.
  4. Convert to Time: Divide the samples ($N$) by the frequency ($f_s$) to get the Inter-beat Interval (IBI) in seconds.
  5. Final Calculation: Divide 60 by the IBI to get your Beats Per Minute.

Realistic Example

If your sensor is recording at 50Hz and you measure 40 samples between two pulses:

  • Interval = 40 / 50 = 0.8 seconds.
  • BPM = 60 / 0.8 = 75 BPM.
Pro Tip: In real-world applications, PPG signals are often "noisy" due to motion artifacts. Engineers typically apply a Bandpass Filter (0.5Hz to 4Hz) and a Moving Average Filter before attempting to count peaks to ensure accuracy.

Leave a Comment