ECG Circuit (PSpice, LabVIEW, Breadboard)

Introduction: ECG Circuit (PSpice, LabVIEW, Breadboard)

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.

This instructable is a guided way to simulated, build, and test a circuit that takes in, filters, and amplifies ECG signals. You will need basic knowledge of circuits and and few instruments to implement the entirety of this instructable.

Electrocardiography (ECG or EKG) is a painless, non-invasive test that records the electrical activity of the heart and is used to gain insight on the state of the patient’s heart. To successfully simulate an ECG reading, input cardiac signals need to be amplified (instrumentation amplifier) and filtered (notch and low pass filters). These components were created physically and on a circuit simulator. To ensure that each component is correctly amplifying or filtering signal, an AC sweep can be performed using PSpice and experimentally. After successfully testing each component individually, a cardiac signal can be inputted through a completed circuit consisting of the instrumentation amplifier, notch filter, and low pass filter. After, a human ECG signal may be inputted through the ECG and LabVIEW. Both the simulated waveform and human cardiac signal may be ran through LabVIEW in order to count beats per minute (BPM) of the input signal. Overall, an input cardiac signal and human signal should be able to be successfully amplified and filtered, simulating an ECG using circuit skills to design, modify, and test an instrumentation amplifier, notch filter, and low pass filter circuit.

Step 1: Simulate Circuit on Computer

You can use whatever software you have available to simulate the circuit we will be creating. I used PSpice so that is what I'll be explaining the details for but the component values (resistors, capacitors, etc.) and the main take aways are all the same so feel free to use something else (such as

Calculate component values:

  1. First is to determine values for the instrumentation amplifier (see picture). The values in the picture were determined by having a desired gain of 1000. Which means that whatever the input voltage you supply this part of the circuit will 'amplify' this by the gain value. For example if you provide 1V as I did the output should be 1000V. There are two parts to this instrumentation amplifier, so the gain is split among them noted as K1 and K2. See the included picture, we want the gains to be close (that's why equation 2 in picture), equations 2 and 3 in the picture are found with nodal analysis, and then the resistor values can be calculated (see picture).
  2. The resistor values for the notch filter were determined by setting the quality factor, Q, to 8 and due to the fact we knew we had plenty of 0.022uF capacitors available, we then moved forward in calculations using these two conditions. See the picture with equations 5 - 10 to calculate the values. Or use R1 = 753.575Ω, R2 = 192195Ω, R3= 750.643Ω, which is what we did!
  3. The low pass filter is to remove noise above a certain frequency which we found online that for ECG is good to use a cutoff frequency fo, of 250 Hz. From this frequency and equations 11-15 (check the picture) calculate resistor values for your low pass filter. Treat R3 as an open circuit and R4 as a short circuit in order to get a gain of K = 1. We calculated R1 = 15,300 ohms, R2 = 25,600 ohms, C1 = 0.022 uF, C2 = 0.047 uF.

Open and Build on PSpice:

With all these values, Start PSpice - Open 'OrCAD Capture CIS', if a pop up for Cadence Project Choices opens select 'Allegro PCB Design CIS L', open file -> new project, type a clever name for it, select create project using analog or mixed A/D, select 'create a blank project', see picture for the file organization of your project, within each page is where you will compile the components (resistors, capacitors, etc.) to build the part of your circuit you want. On each page you will click on part in the tool bar at the top and click part to open a list of parts which is where you search for resistors, capacitors, operational amplifiers, and power sources. Also in the Place drop down you will find ground and wire which you will need to use. Now design each of your pages as seen in the included pictures using the values you calculated.

Run AC Sweeps to ensure the filtering and amplifying is actually happening as you expect!

I added two figures for the simulation of these. Notice the notching at 60 Hz and filtering out the high frequencies. Note the line colors and labeled trace expressions, I also ran the whole circuit together so you should get an idea of what you should be expecting!

For the sweeps select PSpice, click PSpice, New Simulation Profile, change to AC Sweep and set the desired frequencies for start, stop, and the increment value. Under the PSpice menu I also selected markers, advanced, and picked voltage dB and put the marker on where I wanted to measure output this helps later so you don't have to manually add a trace alter. Then go pack to the PSpice menu button again and select Run or just press F11. When the simulator opens, if needed: click trace, add trace, and then select the appropriate trace expression such as V(U6:OUT) if you wanted to measure the voltage output at pin OUT of the opamp U6.

Instrumentation Amplifier: Use the uA741 for all three of the amplifiers and take note the amplifiers in the pictures are referenced according to their respective label (U4, U5, U6). Run your AC sweep on PSpice to compute the frequency response of the circuit with the one voltage input so that the voltage output should be equal to the gain (1000) in this case.

Notch Filter: Use a one voltage AC power source as seen in the picture and the operational amplifier uA741 and make sure to power every op amp you use (powered with 15V DC). Run the AC sweep, I recommend 30 to 100 Hz by 10 Hz increments to ensure the notch at 60 Hz that would filter out electrical signals.

Low Pass Filter: Use the uA741 operational amplifier (see the figure as ours was labeled U1), and supply the circuit a one volt AC power. Power the op amps with a DC 15 volts and measure the output for the AC sweep at pin 6 of U1 which connects with the wire seen in the picture. The AC sweep is used to compute the frequency response of the circuit and with the one voltage input you set, the voltage output should be equal to the gain- 1.

Step 2: Build the Physical Circuit on a Breadboard

This can be challenging but I have full faith in you! Use the values and schematics you created and tested (you hopefully know they work thanks to the circuit simulator) to build this on a breadboard. Make sure to only apply power (1 Vp-p by a function generator) to the beginning not at every stage if testing entire circuit, for testing entire circuit connect each part (instrumentation amplifier to notch filter to low pass), make sure to to supply V+ and V- (15V) to every op amp, and you can test individual stages by measure output at varying frequencies with the oscilloscope to make sure things like it filtering are working. You can use the build-in cardiac waveform on the function generator when you test the entire circuit together and you will then see the QRS waveform as expected. With a little frustration and persistence you should be able to physically build this!

We also added a band capacitor of 0.1uF in parallel to the op amp powers not pictured in PSpice.

Here are some tips when building the individual components:

For the instrumentation amplifier, if you are having difficulty locating the source of the error, check each individual output of the three op-amps. Additionally, ensure you are supplying the power source and input correctly. The power source should be connected to pin 4 and 7, and the voltage input and output to pins 3 of the first stage op-amps.

For the notch filter, some adjustments to resistor values had to be made in order to get the filter to filter out at a frequency of 60 Hz. If the filtering occurs higher than 60 Hz, increasing one of the resistors (we adjusted 2) will help bring the filter frequency down (opposite to increase).

For the low-pass filter, ensuring simple resistor values (resistors you already have) will decrease error significantly!

Step 3: LabVIEW to Plot ECG Waveform and Calculate Heart Rate (Beats Per Minute)

On LabVIEW you will create a block diagram and a user interface which is the part that will display the ECG waveform on a graph as a function of time and display a digital heart rate number. I attached a picture of what to build on labVIEW you can use the search bar to find the needed components. Be patient with this and you can also use the help to read about each piece.

Make sure to use the physical DAQ to connect your circuit to the computer. On the DAQ assistant change your sampling to continuous and 4k.

Here is some advice on building the diagram:

  • DAQ Assistant connection is coming out of “data” and “stop”.
  • DAQ Assistant to “waveform in” on the min max.
  • Right click, create, and choose constant for the number seen in the picture.
  • Right click, select item, dt, this is to change t0 to dt
  • Peak detection has connections at "signal in", "threshold", and "width"
  • Connect to "array" and the constants to "index"
  • Make sure physical DAQ board pin (i.e. analog 8) is the pin you select in the DAQ Assistant (see picture)

The included video '' is of a computer showing the VI User interface of LabVIEW displaying the changing ECG waveform and beats per minute based on the input (listen as it's announced what the frequency is changed to).

Test your design by sending a 1Hz frequency input and it have a clean waveform (see the picture to compare to) but you should be able to read 60 beats per minute!

What you have made can also be used to read a human ECG signal just for fun as this is NOT a medical device. You have to still be careful though with the current supplied to the design. Attached surface electrodes: positive to the left ankle, negative to the right wrist, and attach ground to the right ankle. Run your labVIEW and you should see the waveform appear on the graph and the beats per minute also pop up in the digital display box.

Congratulations!! I hope you were able to complete this and enjoyed your time learning something new!

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge