This calculator helps you determine your heart rate from an electrocardiogram (ECG) strip. Understanding your heart rate is crucial for assessing cardiovascular health.
function calculateHeartRate() {
var rToRInterval = parseFloat(document.getElementById("rToRInterval").value);
var ecgPaperSpeed = parseFloat(document.getElementById("ecgPaperSpeed").value);
var resultDiv = document.getElementById("result");
resultDiv.innerHTML = ""; // Clear previous results
if (isNaN(rToRInterval) || isNaN(ecgPaperSpeed) || rToRInterval <= 0 || ecgPaperSpeed <= 0) {
resultDiv.innerHTML = "Please enter valid positive numbers for R-R interval and ECG paper speed.";
return;
}
// Formula for Heart Rate (BPM) using R-R interval and paper speed:
// Heart Rate (BPM) = 60 / R-R Interval (in seconds)
// If R-R interval is given in small boxes and paper speed is 25mm/sec (each small box is 0.04 sec):
// Heart Rate (BPM) = 1500 / Number of small boxes between R waves
// If R-R interval is given in large boxes and paper speed is 25mm/sec (each large box is 0.20 sec):
// Heart Rate (BPM) = 300 / Number of large boxes between R waves
// We are using the direct R-R interval in seconds for a more general approach.
var heartRate = 60 / rToRInterval;
resultDiv.innerHTML = "