NOTICE: 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.
An electrocardiogram (ECG) records electrical signals during the cardiac cycle. Every time the heart beats, there is a cycle of depolarizing and hyper polarizing of myocardial cells. The depolarizing and hyper polarizing can be recorded by electrodes, and doctors read that information to learn more about how the heart is functioning. An ECG can determine a myocardial infarction, atrial or ventricular fibrillation, tachycardia, and bradycardia . After determining what the problem is from the ECG, doctors can successfully diagnose and treat the patient. Follow the steps below to learn how to make your own electrocardiogram recording device!
Step 1: Materials
- Five UA741 operational amplifiers
- Jumper wires
- DAQ board
- LabVIEW software
- Function generator
- DC power supply
- BNC cables and T-splitter
- Jumper cables
- Alligator clips
- Banana plugs
Step 2: Instrumentation Amplifier
The first stage of the circuit is an instrumentation amplifier. This amplifies the biological signal so that the different components of the ECG can be distinguished.
The circuit diagram for the instrumentation amplifier is shown above. The first stage gain of this circuit is defined as K1 = 1 + 2*R2 / R1. The second stage gain of the circuit is defined as K2 = R4 / R3. The overall gain of the instrumentation amplifier is K1 * K2. The desired gain for this project was approximately 1000, so K1 was chosen to be 31 and K2 was chosen to be 33. Resistor values for these gains are shown above in the circuit diagram. You can use the resistor values shown above, or you can modify the values to meet your desired gain.**
Once you have chosen your component values, the circuit can be constructed on the breadboard. To simplify the circuit connections on the breadboard, the negative horizontal rail on top was set as ground while the two horizontal rails on the bottom were set to be +/- 15V respectively.
The first op amp was placed on the left side of the breadboard in order to leave space for all remaining components. Attachments were added in chronological order of the pins. This makes it easier to keep track of what pieces have been added or not. Once all of the pins are complete for op amp 1, the next op amp can be placed. Again, make sure it is relatively close in order to leave space. The same chronological pin process was completed for all op amps until the instrumentation amplifier was complete.
Bypass capacitors were then added in addition to the circuit diagram in order to get rid of AC coupling in the wires. These capacitors were put in parallel with the DC voltage supply and grounded on the upper horizontal negative rail. These capacitors should be in the range of 0.1 to 1 microFarad. Each op amp has two bypass capacitors, one for pin 4 and one for pin 7. The two capacitors on each op amp must have the same value, but can vary from op amp to op amp.
In order to test the amplification, a function generator and oscilloscope were connected the input and output of the amplifier respectively. The input signal was also connected to the oscilloscope. A simple sine wave was used to determine amplification. Input the function generator output into the two input terminals of the instrumentation amplifier. Set the oscilloscope to measure the ratio of output signal to input signal. The gain of a circuit in decibels is Gain = 20 * log10(Vout / Vin). For a gain of 1000, the gain in decibels is 60dB. Using the oscilloscope, you can determine if the gain of your constructed circuit meets your specifications, or if you need to change some resistor values to improve your circuit.
Once the instrumentation amplifier is correctly assembled and functioning, you can move on to the notch filter.
**In above circuit diagram, R2 = R21 = R22, R3 = R31 = R32, R4 = R41 =R42
Step 3: Notch Filter
The purpose of the notch filter is to remove noise from the 60 Hz wall power supply. A notch filter attenuates the signal at the cutoff frequency, and passes frequencies above and below it. For this circuit, the desired cutoff frequency is 60 Hz.
The governing equations for the circuit diagram shown above are R1 = 1 /(2 * Q * w *C), R2 = 2 * Q / (w * C), and R3 = R1 * R2 / (R1 + R2), where Q is quality factor and w is 2 * pi * (cutoff frequency). A quality factor of 8 gives resistor and capacitor values in a reasonable range. The capacitor values can assumed to all be the same. Thus, you can pick a capacitor value available in your kits. The resistor values shown in the circuit above are for a cutoff frequency of 60 Hz, a quality factor of 8, and a capacitor value of 0.22 uF.
Since capacitors add in parallel, two capacitors of the chosen value C were placed in parallel to achieve a value of 2C. Also, bypass capacitors were added to the op amp.
To test the notch filter, connect the output from the function generator to the input of the notch filter. Observe the input and output of the circuit on an oscilloscope. To have an effective notch filter, you should have a gain of less than or equal to -20dB at the cutoff frequency. Since the components are not ideal, this can be difficult to achieve. The calculated resistor and capacitor values may not give you the desired gain. This will require you to make changes to the resistor and capacitor values.
To do so, focus on one component at a time. Increase and decrease the value of a single component without changing any others. Observe the effects this has on the gain of circuit. This may require a lot of patience to achieve the desired gain. Remember, you can add resistors in series to increase or decrease resistor values. The change that improved our gain the most was to increase one of the capacitors to 0.33 uF.
Step 4: Low Pass Filter
The low pass filter removes higher frequency noise that may interfere with the ECG signal. A low pass cutoff of 40 Hz is sufficient to capture ECG waveform information. However, some components of the ECG exceed 40 Hz. A 100 Hz or 150 Hz cutoff could also be used .
The low pass filter constructed is a Second Order Butterworth filter. Since the gain of our circuit is determined by the instrumentation amplifier, we want a gain of 1 within the band for the low pass filter. For a gain of 1, RA is short circuited and RB is open circuited in the circuit diagram above . In the circuit, C1 = 10 / (fc) uF, where fc is the cutoff frequency. C1 should be less than or equal to C2 * a^2 / (4 * b). For a second order Butterworth filter, a = sqrt(2) and b = 1. Plugging in values for a and b, the equation for C2 simplifies to less than or equal to C1 / 2. Then R1 = 2 / [w * (a * C2 + sqrt(a^2 *C2 ^2 - 4 *b * C1 * C2))] and R2 = 1 / (b * C1 * C2 * R1 * w^2), where w = 2 *pi * fc. Calculations for this circuit were completed in order to provide a cutoff of 40Hz. Resistor and capacitor values that meet these specifications are shown in the above circuit diagram.
The op amp was placed on the rightmost side of the breadboard since no other components will be added after it. Resistors and capacitors were added to the op amp in order to complete the circuit. Bypass capacitors were also added to the op amp. The input terminal was left empty since the input will come from the notch filter output signal. However, for testing purposes, a wire was placed at the input pin in order to be able to isolate the low pass filter and test it individually.
A sine wave from the function generator was used as input signal and observed at different frequencies. Observe both the input and output signals on an oscilloscope and determine the gain of the circuit at different frequencies. For a low pass filter, the gain at the cut off frequency should be -3db. For this circuit, the cutoff should occur at 40 Hz. Frequencies under 40Hz should have little to no attenuation in their waveform, but as the frequency increases above 40 Hz, the gain should continue to roll off.
Step 5: Assembling Circuit Stages
Once you have constructed each stage of the circuit and tested them independently, you can connect them all. The output of the instrumentation amplifier should be connected to the input of the notch filter. The output of the notch filter should be connected to the input of the low pass filter.
To test the circuit, connect function generator input to the input of the instrumentation amplifier stage. Observe the input and output of the circuit on an oscilloscope. You can test with a pre-programmed ECG wave from the function generator, or with a sine wave and observe the effects of your circuit. In the above oscilloscope image, the yellow curve is the input waveform, and the green curve is the output.
Once you have connected all your circuit stages and demonstrated that it works properly, you can connect the output of your circuit to the DAQ board and begin programming in LabVIEW.
Step 6: LabVIEW Program
The LabVIEW code is to detect the beats per meter from a simulated ECG wave at different frequencies. To program in LabVIEW you must identify all of the components first. An analog to digital converter, also known as the data acquisition (DAQ) board, must be setup and set to run continuously. The output signal from the circuit is connected to the input of the DAQ board. The waveform graph in the LabVIEW program is connected directly to the output of the DAQ assistant. The output from the DAQ data also goes to the max/min identifier. The signal then goes through a multiplication arithmetic operator. The numerical indicator of 0.8 is used to calculate the threshold value. When the signal exceeds 0.8*Maximum, a peak is detected. Anytime this value was found it was stored in the index array. The two data points are stored in the index array and are input into the subtraction arithmetic operator. The change in time was found between these two values. Then, to calculate heart rate, 60 is divided by the time difference. A numerical indicator, which is shown next to the output graph, outputs the heart rate in beats per minute (bpm) of the input signal. Once the program is setup, it should all be put inside of a continuous while loop. Different frequency inputs give different bpm values.
Step 7: Collect ECG Data
Now you can input a simulated ECG signal into your circuit, and record data in your LabVIEW program! Change the frequency and amplitude of the simulated ECG to see how that affects your recorded data. As you change frequency, you should see a change in the calculated heart rate. You have successfully designed an ECG and heart rate monitor!
Step 8: Further Improvements
The constructed device will work well for acquiring simulated ECG signals. However, if you would like to record biological signals (be sure to follow appropriate safety precautions), further modifications should be made to the circuits to improve the signal reading. A high pass filter should be added to remove DC offset and low frequency motion artifacts. The gain of the instrumentation amplifier should also be reduced by tenfold to stay within the usable range for LabVIEW and the op amps.
 S. Meek and F. Morris, “Introduction. II--basic terminology.,” BMJ, vol. 324, no. 7335, pp. 470–3, Feb. 2002.
 Chia-Hung Lin, Frequency-domain features for ECG beat discrimination using grey relational analysis-based classifier, In Computers & Mathematics with Applications, Volume 55, Issue 4, 2008, Pages 680-690, ISSN 0898-1221, https://www.sciencedirect.com/science/article/pii...
 “Second Order Filter | Second Order Low Pass Filter Design.” Basic Electronics Tutorials, 9 Sept. 2016, www.electronics-tutorials.ws/filter/second-order-...