Electrocardiogram (ECG) Circuit

Introduction: Electrocardiogram (ECG) 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.

We are two students in Biomedical Engineering and after taking our first circuits class, we were quite excited and decided to use the basics we learned to do something useful: display an ECG and read heart rate. This would be the most complex circuit we've built yet!

Some background on an ECG:

Many electrical devices are used to measure and record biological activity in the human body. One such device is the electrocardiogram, which measures the electrical signals produced by the heart. These signals give objective information about the structure and function of the heart. The ECG was first developed in 1887 and gave physicians a new way to diagnose heart complications. ECGs can detect heart rhythm, heart rate, heart attacks, inadequate blood and oxygen supply to the heart, and structural abnormalities. Using simple circuit design, an ECG can be made that could monitor all of these things.

Step 1: Materials

Building the circuit

Basic materials needed to build the circuit are shown in pictures. They include:

  • Resistors
  • Capacitors
  • Wires
  • Stick-on electrodes
    • These are only needed if you decide to try the circuit on a real person.

Software used includes:

  • LabVIEW 2016
  • CircuitLab or PSpice for simulations to check values
  • Excel
    • This is highly recommended in case you need to change any characteristics of your circuit. You may also need to play with the numbers until you find resistor and capacitor values that are readily available. Pen-and-paper calculations discouraged for this one! We have attached our spreadsheet calculations to give an idea.

Testing the circuit

You will also need some larger electronic equipment:

  • DC Power supply
  • DAQ board to interface the circuit to LabVIEW
  • Function generator to test circuit
  • Oscilloscope to test circuit

Step 2: Instrumentation Amplifier

Why we need it:

We will build an instrumentation amplifier in order to amplify the small amplitude measured from the body. Using two amplifiers in our first stage will allow us to cancel out the noise created by the body (which will be the same at both electrodes). We will use two stages of about equal gain -- this protects the user if the system is connected to a person by preventing all the gain from happening in one place. Since the normal amplitude of an ECG signal is between 0.1 and 5 mV, we want the gain of the instrumentation amplifier to be about 100. An acceptable tolerance on the gain is 10%.

How to build it:

Using these specifications and the equations seen in the table (attached pictures), we found our resistor values to be R1= 1.8 kiloOhms, R2=8.2 kiloOhms, R3 = 1.5 kiloOhms, and R4 = 15 kiloOhms. K1 is the gain of the first stage (OA1 and OA2), and K2 is the gain of the second stage (OA3). Equal capacitance bypass capacitors are used on the power supplies of the operational amplifiers to remove noise.

How to test it:

Any signal that is fed into the instrumentation amplifier should be amplified by 100. Using dB=20log(Vout/Vin) this means a ratio of 40 dB. You can simulate this in PSpice or CircuitLab, or test the physical device, or both!

The oscilloscope image attached shows a gain of 1000. For a real ECG, this is too high!

Step 3: Notch Filter

Why we need it:

We will use a notch filter to remove the 60 Hz noise present in all power supplies in the United States.

How to build it:

We will set the quality factor Q to be 8, which will provide an acceptable filtering output while keeping component values in a feasible range. We also set the capacitor value to be 0.1 μF so that calculations affect the resistors only . The resistor values calculated and used can be seen in the table (in pictures) or below

  • Q = w/B
    • set Q to 8 (or choose your own based on your own need)
  • w = 2*pi*f
    • use f = 60 Hz
  • C
    • set to 0.1 uF (or choose your own value from available capacitors)
  • R1 = 1/(2*Q*w*C)
    • Calculate. Our value is 1.66 kohm
  • R2 = 2*Q/(w*C)
    • Calculate. Our value is 424.4 kohm
  • R3 = R1*R2/(R1+R2)
    • Calculate. Our value is 1.65 kohm

How to test it:

The notch filter should pass all frequencies unchanged except for those around 60 Hz. This can be checked with an AC sweep. A filter with a gain of -20 dB at 60 Hz is considered good. You can simulate this in PSpice or CircuitLab, or test the physical device, or both!

This kind of notch filter may generate a good notch in the simulated AC sweep, but a physical test showed that our original values generated a notch at a lower frequency than intended. To fix this, we bumped up R2 by about 25 kohm.

The oscilloscope image shows the filter greatly reduces the input signal magnitude at 60 Hz. The graph shows an AC sweep for a high quality notch filter.

Step 4: Low-pass Filter

Why we need it:

The last stage of the device is an active low-pass filter. The ECG signal is made of many different waveforms, which each have their own frequency. We want to capture all these, without any high-frequency noise. The standard cutoff frequency for ECG monitors of 150 Hz is selected. (Higher cutoffs are sometimes chosen to monitor for specific heart problems, but for our project, we will use a normal cutoff.)

If you would like to make a simpler circuit, you could also use a passive low-pass filter. This will not include an op amp, and will consist of just a resistor in series with a capacitor. The output voltage will be measured across the capacitor.

How to build it:

We will design it as a Second order Butterworth filter, which has coefficients a and b equal to 1.414214 and 1, respectively. Setting the gain to 1 makes the operational amplifier into a voltage follower. The equations and values chosen are shown in the table (in pictures) and below.

  • w=2*pi*f
    • set f = 150 Hz
  • C2 = 10/f
    • Calculate. Our value is 0.067 uF
  • C1 <= C2*(a^2)/(4b)
    • Calculate. Our value is 0.033 uF
  • R1 = 2/(w*(aC2+sqrt(a^2*C2^2-4b*C1*C2)))
    • Calculate. Our value is 18.836 kohm
  • R2 = 1/(b*C1*C2*R1*w^2)
    • Calculate. Our value is 26.634 kohm

How to test it:

The filter should pass frequencies below the cutoff unchanged. This can be tested using an AC sweep. You can simulate this in PSpice or CircuitLab, or test the physical device, or both!

The oscilloscope image shows the filter's response at 100 Hz, 150 Hz, and 155 Hz. Our physical circuit had a cutoff closer to 155 Hz, shown by the -3 dB ratio.

Step 5: High-pass Filter

Why we need it:

The high-pass filter is used so that frequencies below a certain cut-off value are not recorded, allowing a clean signal to be passed through. The cut-off frequency is chosen to be 0.5 Hz (a standard value for ECG monitors).

How to build it:

The resistor and capacitor values needed to achieve this are seen below. Our actual resistance used was 318.2 kohm.

  • R = 1/(2*pi*f*C)
    • set f = 0.5 Hz, and C = 1 uF
    • Calculate R. Our value is 318.310 kohm

How to test it:

The filter should pass frequencies above the cutoff unchanged. This can be tested using an AC sweep. You can simulate this in PSpice or CircuitLab, or test the physical device, or both!

Step 6: Setting Up LabVIEW

The flowchart lays out the design concept of the LabVIEW portion of the project which records the signal at a high sampling rate and displays the heart rate (BPM) and ECG. Our LabView circuit contains the following components: DAQ assistant, index array, arithmetic operators, peak detection, numerical indicators, waveform graph, change in time, max/min identifier, and number constants. The DAQ assistant is set to take continuous samples at a rate of 1 kHz, with the number of samples changed between 3,000 and 5,000 samples for peak detection and signal clarity purposes.

Mouse over the different components in the circuit diagram to read where in LabVIEW to find them!

Step 7: Collecting Data

Now that the circuit has been assembled, data can be collected to see if it works! Send a simulated ECG through the circuit at 1 Hz. The result should be a clean ECG signal where the QRS complex, P wave, and T wave can be clearly seen. The heart rate should also be displaying 60 beats per minute (bpm). To further test the circuit and the LabVIEW setup, change the frequency to 1.5 Hz and 0.5 Hz. The heart rate should change to be 90 bpm and 30 bpm respectively.

For slower heart rates to accurately be displayed you may need to adjust the DAQ settings to show more waves per graph. This can be done by increasing the number of samples.

If you choose to test the device on a human be sure the power supply you are using for the op amps limits the current at 0.015 mA! There are several acceptable lead configurations but we chose to place the positive electrode on the left ankle, the negative electrode on the right wrist, and the ground electrode on the right ankle as seen in the attached picture.

Using some basic circuitry concepts and our knowledge of the human heart we have shown you how to create a fun and useful device. We hope you've enjoyed our tutorial!

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Super-Size Speed Challenge

      Super-Size Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020

    4 Discussions


    2 months ago

    schematics are unclear.
    It shows a positive feedback loops for OpAmps. BIG no-no for stable circuits unless you want oscillating circuits.


    Question 7 months ago on Step 2

    How do we get all the register valuues?


    Question 1 year ago

    Is there any way to get the excel spreadsheet mentioned in the article? Great article. Thank you.