Introduction: ECG Circuit and Heart Rate Digital Waveform Monitor
In this Instructable I am going to walk you through how to filter a cardiac signal and utilize LabView to produce an ECG waveform.
An ECG signal is the electrical activity of the heart shown in a waveform consisting of a P wave, QRS complex, and a T wave. Working with LabView, a function generator, and oscilloscope, an ECG signal is acquired, amplified and filtered. This is done by creating a circuit board with an instrumentation amplifier, notch filter, and low pass filter. Specifications for each part of the circuit board include a desired gain of 1000 V/V for the instrumentation amplifier, a notch at 60 Hz for the notch filter, and a cutoff frequency of 147.05 Hz for the low pass filter.
Let's go through each component thoroughly and see if you all can recreate this cool project!
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
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 battery power and other proper isolation techniques.
Step 2: Instrumentation Amplifier Part 1
To construct the instrumentation amplifier, use the attached image. First build it in PSpice, or some other simulation program, and use the design equations to solve for resistor values based on a desired gain of 1000 with K1~K2, K1 ~ 33 and K2 ~ 33.
Stage 1: Gain = K1 = 1 + 2R2 / R1
33 = 1 + 2R2 / R1
R1 = 1.5k
R2 = 24k ~ 22k
Stage 2: Gain = K2 = R4 / R3
33 = R4 / R3
R3 = 1k
R4 = 33k
Once the resistor values have been put into the simulation model, run an AC sweep to ensure that the amplifier is producing a gain of 1000 V/V. Then, build this instrumentation amplifier on a breadboard with corresponding resistor values and three uA741 op amps.
Power your amplifier with a power supply sending 15V into the positive terminal at pin 7, and -15V into the negative at pin 4, using the Agilent Power Supply.
Input a sine wave from the Agilent Function Generator to pin 3 on the lower left op amp, and measure the output at pin 6 of the right op amp. Observe the output on the Agilent Oscilloscope and collect gain vs. frequency data for a manual AC sweep and compare to the PSpice simulation.
Step 3: Instrumentation Amplifier Part 2
Using the instrumentation amplifier constructed in the previous step the following Pspice simulation should be an idea of what you should find. Attached the Pspice simulation of the instrumentation amplifier schematic has a frequency range of 1-350 kHz and 150 points per decade.
Step 4: Notch Filter Part 1
Using the figure attached, construct a notch filter. First build the filter in PSpice according to the schematic using the design equations to solve for the resistor and capacitor values to get the filter to notch at 60 Hz. He gain is 1, quality factor (Q) is 8, cutoff frequency (w) is 60 Hz,
C = 0.068 uF
R1 = 2.4k=2 x 1.2k
R2 = 620k=150k and 470k in series
R3 = 2.1k = 2 x 1k and 100 ohms in series
Run the PSpice AC sweep simulation to ensure the notch filter behaves as you expect, keeping a constant gain at low and high frequencies, but notching to -20dB at 60Hz. Then use this model to construct the filter on a breadboard using the same resistor and capacitor values, and a uA741 op amp. Power the filter with 15V going into pin 7, and -15V at pin 4 using an Agilent Power Supply. Input a sine wave in place of V1 using the Agilent Function Generator, and measure the V2 output at pin 6. Observe the output on an Agilent Oscilloscope and collect gain vs. frequency data to create a manual AC sweep to compare to the PSpice simulation.
Step 5: Notch Filter Part 2
After constructing the notch filter a simulated output would be similar to the figure attached. This is a Pspice simulation for the notch filter schematic shown above using an AC sweep simulation from 1-100 Hz with 150 points per decade.
Step 6: Low Pass Filter Part 1
A low pass filter can be designed with the visual aid provided with this step. For a gain of K = 1, R3 is replaced by an open circuit and R4 is replaced by a short circuit. Filter coefficients for a second order Butterworth filter are a = 1.414214, and b = 1. A low pass filter should allow low frequency signals to pass through, but not high frequency signals. A literature search was performed to determine the proper cutoff frequency for an ECG signal. An acceptable range is 0.5 - 150 Hz . 147.05 Hz was selected as the cutoff frequency for our low pass filter because it worked best with our calculations and available resistors and capacitors.
Fc = 147.05
wc= 923.63 rad/sec
R3 =56k, but since K = 1 it is replaced with an open circuit
R4 =56k, but since K = 1 it is replaced by a short circuit = a wire
Power the filter with 15V going into pin 7, and -15V at pin 4 using an Agilent Power Supply. Input a sine wave in place of V1 using the Agilent Function Generator, and measure the V2 output at pin 6 on an Agilent Oscilloscope. Compare the data found to the pspice simulation.
Step 7: Low Pass Filter Part 2
After the circuit is constructed compare the data found to a Pspice simulation. Attached is a Pspice simulation for the low pass filter schematic shown above using an AC sweep simulation from 0.1Hz-2kHz with 100 points per decade.
Step 8: Total Circuit
This image shows the three stages of the circuit all on one board. The leftmost stage is the low pass filter. The second most left op amp is the notch filter. The next three op amps make up the instrumentation amplifier. The op amp all the way to the right was for a high pass filter that was not used. In order to integrate these three stages together, the output of the instrumentation amplifier was sent to the input of the notch filter and the output of the notch filter was sent to the input of the low pass filter. The output was then measured from the low pass filter and the sine wave was inputted to the instrumentation amplifier. This image does not show all of the bypass capacitors in place, however, capacitors were put from pins 4 and 7 to ground on each op amp when we tested them.
Step 9: Labview: Setup
In order to plot an ECG signal into LabView using an A/D converter, the components shown in the above figure need to be used. To begin, open Labview and start a new project. Choose the DAQ assistant component for data acquisition. A new window should open up asking for the type of data that will be coming into the DAQ. Choose input voltage and the channel that the input will be coming into. Then change the points to continuous with a window size of 2k. Hit okay and be prepared to wait up to 5 minutes for your changes to save. The program will then ask you if you want to create a loop, to which you should select yes.
Coming off the DAQ component, the data acquisition, consisting of the analog signal and sampling parameters, should go to the waveform graph component and the min/max identifier. The min/max identifier finds the max of the QRS complex. This value is multiplied by a threshold of 80% in order to allow any value 20% above and below that max to be registered as a max. The signal is sent to the peak detector and to the change in time component. The peak detector receives both the signal and the max value to determine where the max values are occuring at. With the location and values of the max points further math calculations are done to find the BPM. The last output is the numerical indicator which shows the BPM next to the graph of the waveform. Once the Labview circuit is ready a cardiac signal is input into the DAQ board. This is done by creating a cardiac waveform on the Agilent Function Generator with a frequency of 1Hz and an amplitude of 10 Vpp. The output is seen on the next step.
Step 10: LabView: Results
The output from a 10 V amplitude and 1 Hz frequency is shown as the first image. Then the input voltage is altered to 10 mV to account for gain associated with the instrumentation amplifier in the ECG circuit. This signal is sent through the ECG circuit designed in previous steps and the output from the circuit is run through LabView. The waveform from LabView is attached as the second image.
Step 11: Conclusion
The objective of this project was to design an ECG circuit capable of acquiring, amplifying and filtering an ECG signal. The assessment of each stage of our circuit showed that the instrumentation amplifier, notch filter, and low pass filter all worked as they should and produced the output that was expected. The instrumentation amplifier produced a gain of 1000, the notch filter notched at 60Hz, and the low pass filter cutoff at 147 Hz as desired for an ECG signal. The output of the circuit was also hooked up to LabView and could be visualized by the output waveforms and the produced beats per minute corresponding accurately to the input frequency. If you followed along with this Instructable, hopefully you were able to make these conclusions as well.