Simple ECG Circuit and LabVIEW Heart Rate Program


Introduction: Simple ECG Circuit and LabVIEW Heart Rate Program

An Electrocardiogram, or further referred to as an ECG, is an extremely powerful diagnostic and monitoring system used in all medical practices. ECG’s are used to observe the electrical activity of the heart graphically to check for abnormalities in heart rate or electrical signaling.

From an ECG reading, patients’ heart rate can be determined by the time spacing between QRS complexes. Additionally, other medical conditions can be detected such as a pending heart attack by an ST segment elevation. Readings like this can be crucial to diagnosing and treating a patient properly. The P wave is showing the contraction of the atrium of the heart, the QRS curve is the ventricular contraction, and the T wave is the repolarization of the heart. Knowing even simple information such as this can diagnose patients quickly for abnormal heart function.

A standard ECG used in medical practice has seven electrodes that are placed in a mild semicircular pattern around the lower region of the heart. This placement of electrodes allows for minimal noise when recording and also allows for more consistent measurements. For our purpose of the created ECG circuit, we will only use three electrodes. The positive input electrode will be placed on the right inner wrist, the negative input electrode will be placed on the left inner wrist, and the ground electrode will be connected to the ankle. This will allow for readings to be taken across the heart with relative accuracy. With this placement of electrodes connected to an instrumentation amplifier, a low pass filter, and a notch filter, ECG waveforms should be easily distinguishable as an output signal from the created circuit.

NOTE: 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.

Step 1: Construct Instrumentation Amplifier

To construct a multistage instrumentation with a gain of 1000, or 60 dB, the following equation should be applied.


R1 is equal to all of the resistors used in the instrumentation amplifier aside from the gain resistor which will in a sense cause all the gain to be involved in the first stage of the amplifier. This was chosen to be 50.3 kΩ. To calculate the gain resistor, this value is plugged into the above equation.



After this value is calculated, the instrumentation amplifier can be constructed as the following circuit shown in this step. The OP/AMPs should be powered with positive and negative 15 volts as shown in the circuit diagram. The bypass capacitors for each OP/AMP should be placed near the OP/AMP in series with the power supply to dampen any AC signal coming from the power source to ground to prevent the OP/AMPs from getting fried and any additional noise that might contribute to the signal. Also, to test the circuits actual gain, the positive electrode node should be given an input sine wave and the negative electrode node should be connected to ground. This will allow the gain of the circuit to be accurately seen with an input signal of less than 15 mV peak to peak.

Step 2: Construct the 2nd Order Low Pass Filter

A 2nd order low pass filter was used to remove noise above the frequency of interest for the ECG signal which was 150 Hz.

The K value used in calculations for the 2nd order low pass filter is the gain. Because we do not want any gain in our filter, we chose a gain value of 1 which means the input voltage will be equal to the output voltage.


For a second-order Butterworth filter which will be used for this circuit, the a and b coefficients are defined below. a=1.414214 b=1

First, the second capacitor value is chosen to be a relatively large capacitor that is readily available in the lab and the real world.

C2=0.1 F

To calculate the first capacitor, the following relationships between it and the second capacitor is used. The K, a, and b coefficients were plugged into the equation to calculate what this value should be.



C1<=50 nF

Because the first capacitor is calculated to be less than or equal to 50 nF, the following capacitor value was chosen.

C1=33 nF

To calculate the first resistor needed for this second order low pass filter with a cut off frequency of 150 Hz, the following equation was solved using both calculated capacitor values and the coefficients K, a, and b. R1=2/[(cutoff frequency)*[aC2*sqrt([(a^2+4b(K-1))C2^2-4bC1C2])]

R1=9478 Ohm

To calculate the second resistor, the following equation was used. The cutoff frequency again is 150 Hz and the b coefficient is 1.

R2=1/[bC1C2R1(cutoff frequency)^2]

R2=35.99 kOhm
After calculating the above values for the resistors and capacitors needed for a second-order notch filter, the following circuit was created to show the active low pass filter that will be used. The OP/AMP is powered with positive and negative 15 volts as shown in the diagram. Bypass capacitors are connected to the power sources so that any AC signal that comes out of the source is diverted to ground to ensure the OP/AMP does not get fried by this signal. To test this stage of the ECG circuit, the input signal node should be connected to a sine wave and an AC sweep from 1 Hz to 200 Hz should be performed to see how the filter works.

Step 3: Construct the Notch Filter

The notch filter is an extremely important part of many circuits for measuring low frequency signals. At low frequencies, 60 Hz AC noise is extremely common as it is the frequency of the AC current running through buildings in the United States. That 60 Hz noise is inconvenient as it is in the middle of the pass band for the ECG, but a notch filter can remove specific frequencies while preserving the rest of the signal. When designing this notch filter, it is very important to have a high quality factor, Q, to ensure that the roll off of the cut-off is sharp around the point of interest. Below details the calculations used to construct an active notch filter that will be used in the ECG circuit.

First the frequency of interest, 60 Hz must be converted from Hz to rad/s.


frequency=376.99 rad/second

Next, the bandwidth of the frequencies cut should be calculated. These values are determined in a fashion that ensures that the main frequency of interest, 60 Hz, is completely cut off and only a few surrounding frequencies are slightly affected.


Bandwidth=37.699 The quality factor must be determined next. The quality factor determines how sharp the notch is and how narrow the cut-off begins. This is calculated using the bandwidth and the frequency of interest. Q=frequency/Band Width

Q = 10

A readily available capacitor value is chosen for this filter. The capacitor does not need to be large and definitely should not be too small.

C=100 nF

To calculate the first resistor used in this active notch filter, the following relationship was used involving the quality factor, the frequency of interest, and the capacitor chosen.


R1=1326.29 Ohm

The second resistor used in this filter is calculated using the following relationship.


R2=530516 Ohm

The final resistor for this filter is calculated using the previous two resistor values. It is expected to be very similar to the first resistor calculated.


R3=1323 Ohm

After all of the component values are calculated using the equations described above, the following notch filter should be constructed to accurately filter out the 60 Hz AC noise that will disrupt the ECG signal. The OP/AMP should be powered with positive and negative 15 volts as shown in the circuit below. Bypass capacitors are connected from the power sources on the OP/AMP so that any AC signal that comes from the power source is diverted to ground to ensure the OP/AMP does not get fried.To test this portion of the circuit, the input signal should be connected to a sine wave and an AC sweep should be performed from 40 Hz to 80 Hz to see the filtering of the 60 Hz signal.

Step 4: Create a LabVIEW Program to Calculate Heart Rate

LabVIEW is a useful tool for running instruments as well as collecting data. To collect ECG data, a DAQ board is used which will read input voltages at a sampling rate of 1 kHz. These input voltages are then output to a plot which is used to display the ECG recording. The data that is collected then goes through a max finder which outputs the maximum values read. These values allow for a peak threshold to be calculated at 98% of the maximums output. After, a peak detector is used to determine when the data is greater than that threshold. This data along with the time between peaks can be used to determine the heart rate. This simple calculation accurately will determine heart rate from input voltages read by the DAQ board.

Step 5: Testing!

After constructing your circuits you are ready to put them to work! First, each stage should be tested with an AC sweep of frequencies from 0.05 Hz to 200 Hz. The input voltage should be no greater than 15 mV peak to peak so that the signal is not railed by the OP/AMP limitations. Next, connect all of the circuits and run a full AC sweep again to make sure everything is functioning properly. After you are satisfied with the output of your complete circuit its time to connect yourself to it. Place the positive electrode on your right wrist and the negative electrode on your left wrist. Put the ground electrode on your ankle. Connect the output of the complete circuit to your DAQ board and run the LabVIEW program. Your ECG signal should now be visible on the waveform graph on the computer. If it is not or distorted try dropping the gain of the circuit down to about 10 by changing the gain resistor accordingly. This should allow for the signal to be read by the LabVIEW program.




    • Woodworking Contest

      Woodworking Contest
    • Casting Contest

      Casting Contest
    • Planter Challenge

      Planter Challenge

    We have a be nice policy.
    Please be positive and constructive.




    do you have the vi program? can you share it?

    I do have a few images of the full circuit assembled but those were left off of this instructable because the circuits were constructed on a breadboard and are hard to decipher. I can post a few images if you think they would be useful for other viewers though.

    My guess is Jason just wants to get an idea of the overall complexity of the design. Plus, nerds like us just think circuit boards look cool. Haha.

    Ay! First Instructable. Great work guys!