# How to Build an ECG and Heart Rate Digital Monitor

754

3

## Introduction: How to Build an ECG and Heart Rate Digital Monitor

An electrocardiogram (ECG) measures the electrical activity of the heartbeat to show how fast the heart is beating as well as its rhythm. There is an electrical impulse, also known as a wave, that travels through the heart to make the heart muscle pump out blood with each beat. The right and left atria create the first P wave, and the right and left bottom ventricles make the QRS complex. The final T wave is from the electrical recovery to a resting state. Doctors use ECG signals to diagnose heart conditions, so it's important to get clear images.

The goal of this instructable is to acquire and filter an electrocardiogram (ECG) signal by combining an instrumentation amplifier, notch filter, and low-pass filter in a circuit. Then the signals will go through an A/D converter into LabView to produce a real-time graph and heartbeat in BPM.

"This is not a medical device. This is for educational purposes only using simulated signals. If using this circuit for real ECG measurements, please ensure the circuit and the circuit-to-instrument connections are utilizing proper isolation techniques."

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: Design an Instrumentation Amplifier

To build an instrumentation amplifier, we need 3 op amps and 4 different resistors. An instrumentation amplifier increases the gain of the output wave. For this design, we aimed for a gain of 1000V to get a good signal. Use the following equations to calculate the appropriate resistors where K1 and K2 are the gain.

Stage 1: K1 = 1 + (2R2/R1)

Stage 2: K2 = -(R4/R3)

For this design, R1 = 20.02Ω, R2 = R4 = 10kΩ, R3 = 10Ω were used.

## Step 2: Design a Notch Filter

Secondly, we must build a notch filter using an op amp, resistors, and capacitors. The purpose of this component is to filter out noise at 60 Hz. We want to filter exactly at 60 Hz, so everything below and above this frequency will pass, but the amplitude of the waveform will be lowest at 60 Hz. To determine the parameters of the filter, we used a gain of 1 and a quality factor of 8. Use the equations below to calculate the appropriate resistor values. Q is the quality factor, w = 2*pi*f, f is the center frequency (Hz), B is the bandwidth (rad/sec), and wc1 and wc2 are the cutoff frequencies (rad/sec).

R1 = 1/(2QwC)

R2 = 2Q/(wC)

R3 = (R1+R2)/(R1+R2)

Q = w/B

B = wc2 - wc1

## Step 3: Design a Low-pass Filter

The purpose of this component is to filter out frequencies above a certain cutoff frequency (wc), essentially not allowing them to pass through. We decided to filter at 250 Hz frequency in order to avoid cutting too close to the average frequency used to measure an ECG signal (150 Hz). To calculate the values we will use for this component, we will use the following equations:

C1 <= C2(a^2 + 4b(k-1)) / 4b

C2 = 10/cutoff frequency (Hz)

R1 = 2 / (wc (a*C2 + (a^2 + 4b(k-1)C2^2 - 4b*C1*C2)^(1/2))

R2 = 1 / (b*C1*C2*R1*wc^2)

We will set the gain as 1, so R3 becomes an open circuit (no resistor) and R4 becomes a short circuit (just a wire).

## Step 4: Test the Circuit

An AC sweep is performed for each component to determine the efficacy of the filter. The AC sweep measures the magnitude of the component at different frequencies. You expect to see different shapes depending on the component. The importance of the AC sweep is to make sure that the circuit is functioning properly once built. To perform this test in the lab, simply record the Vout/Vin at a range of frequencies. For the instrumentation amplifier we tested from 50 to 1000 Hz to get a wide range. For the notch filter, we tested from 10 to 90 Hz to get a good idea of how the component reacts around 60 Hz. For the low pass filter, we tested from 50 to 500 Hz to understand how the circuit reacts when it is meant to be passing and when it is meant to be stopping.

## Step 5: ECG Circuit on LabView

Next, you want to create a block diagram in LabView that simulates an ECG signal through an A/D converter and then plots the signal on the computer. We began by setting the parameters of our DAQ board signal by determining what average heart rate we were expecting; we chose 60 beats per minute. Then using a frequency of 1kHz, we were able to determine that we needed to display roughly 3 seconds to acquire 2-3 ECG peaks in the waveform plot. We displayed 4 seconds to ensure we capture enough ECG peaks. The block diagram will read the incoming signal and use peak detection to determine how often a full heart beat is occurring.

## Step 6: ECG and Heart Rate

Using the code from the block diagram, the ECG will appear in the waveform box, and the beats per minute will be displayed next to it. You now have a working heart rate monitor! To challenge yourself even more, try using your circuit and electrodes to display your real-time heart rate!