ECG With Op-Amps and Arduino
by kat_livingston in Circuits > Arduino
2321 Views, 2 Favorites, 0 Comments
ECG With Op-Amps and Arduino
An electrocardiogram visualizes the electrical activity of the heart as a means of determining if there are any complications present. Electrocardiograms typically use twelve electrodes around the body to record the activity of the heart as seen in the figure. A 3-stage ECG measurement device should be created with the following specifications: differential amplifier with a gain of 1000, a notch filter to eliminate power line signal, and a low pass to ensure it falls in the typical ECG recording range.
Supplies
1) Arduino IDE
2) Agilent 33220 A function generator
3) Agilent E3531A DC power supply
4) Agilent DSO6014A oscilloscope
5) 5 UA741 OP Amps
6) Resistors (Values Specified in Procedure)
7) Capacitors (Values Specified in Procedure)
8) Connecting Wires
9) ECG Electrodes (3 pieces)
Understanding UA 741 Ports
Ports:
1: This port will not be used for this project.
2: Inverting Input that will be used to connect components.
3: Non-inverting Input that will be used to connect components.
4: -V is the negative port of the input voltage supplied by the Agilent
5: This port will not be used for this project.
6: Output that will be used to measure the signal produced.
7: +V is the positive port of the input voltage supplied by the Agilent
8: This port will not be used for this project.
Differential Amplifier Construction
Based on the schematic, a differential amplifier with a gain of 1,000 should be constructed. Use the following gain equation to determine component values: Gain = (1 + (2*R2/R1))(R4/R3)
Resistors:
R₁ = 1.8 kOhm
R₂ = 21.6 kOhm
R₃ = 8.2 kOhm
R₄ = 328 kOhm
Construct the Model in both LTSpice and on a Circuit board to test results.
Testing of Differential Amplifier
Testing of LTSpice Model:
The LTSpice schematic was simulated using an AC sweep analysis. This analysis utilized a decade sweep with 1,000 points per decade. Additionally, the analysis had a start frequency of 1 mHz and a stop frequency of 1 MHz. The resulting waveform is displayed to the left.
Testing of Physical Circuit Design:
Testing the physical circuit merely involved observing a 1000 or 60 dB gain when comparing the output and input signals. Therefore, a singular input signal with a peak to peak amplitude of 20 mV and frequency of 1 Hz was passed through the circuit using an Agilent 33220A function generator. The OP Amps, which required additional DC power sources, were powered accordingly using the Agilent E3531A DC power supply with an input voltage of +/- 15 V. The resulting output signals were visualized and scaled accordingly using the Agilent DSO6014A oscilloscope as seen in the image on the right.
Notice that there is a 60.1 dB proving that the construction was successful and there is a gain of 1,000.
Notch Filter Construction
Power lines produce frequencies of approximately 60 Hz in the United States. This output creates noise in ECG measurement devices. Therefore, the notch filter is design to remove/reject that frequency from the recording. We are also informed in the project that the gain should be at a maximum 10.
The following equations should be used to determine the component values:
f_0 = 60 Hz
w_0 = 2*pi*f_0
Q = w_0 / B
Q = 10
R1 = 1/(2*Q*w_0*C)
R2 = 2Q/(w_0*C)
R3 = (R1*R2)/(R1+R2)
Resistors:
R₁ = 530.5 kOhm
R₂ = 530.5 kOhm
R₃ = 1.3 kOhm
Capacitors:
Ca = 0.1 microF
Cb = 0.1 microF
2C = 02 microF
Construct the Model in both LTSpice and on a Circuit board to test results.
Testing of Notch Filter
Testing of LTSpice Model:
This schematic was simulated in LTSpice in order to ensure the correct construction by utilizing an AC decade sweep analysis. This analysis has a start frequency of 1 Hz and a stop frequency of 100 Hz with 1,000 points per decade. The resulting waveform is displayed on the left.
Testing of Physical Circuit Design:
To test the notch filter an AC sweep was performed using the Agilent Function generator to produce a sinusoidal input signal (1.0 Vpp) from 20 to 80 Hz. To generate a clear frequency response, the input frequency was incremented by 10 outside the range of 55 to 65 Hz, which was incremented by 1. The resulting output was measured using the Agilent oscilloscope, while the OP Amp used in the circuit was again powered by the Agilent DC generator as explain in step 3. The resulting waveform is seen to the right.
Notice that there is a dip in the recorded values around 60 Hz. This displays the the power line signals are not received by the device proving the design to be successful.
Active Low Pass Filter
ECG measurement devices typically record signals between 0.5 Hz and 150 Hz. Therefore, a low pass filter can be incorporated into the design to remove all frequencies above 150 Hz.
The following equations should be used to determine the component values:
fc = 150 Hz
wc = 2*pi*fc
a = 1.414214, b = 1, k = 1
C2 = 10/fc
C1 = (C2 * (a^2 + 4b + (k-1))/4b
R1 = 2 / [wc * ((a*C2) + sqrt[(a^2 + (4b*(k-1)) )] * (C2)^2 - (4b * C1 * C2)) )
R2 = 1 / (b*C1*C2*R1*(wc^2)
Resistors:
R₁ = 22.5 kOhm
R₂ = 22.5 kOhm
Capacitors:
C1 = 0.0333 microF
C2 = 0.0667 microF
Construct the Model in both LTSpice and on a Circuit board to test results.
Testing of Active Low Pass
Testing of LTSpice Model:
Similarly to step 5, the low pass filter was simulated in LTSpice using an AC sweep analysis from 1Hz to 1 kHz. This sweep is a decade sweep with 1,000 points per decade. The resulting waveform is seen on the left.
Testing of Physical Circuit Design:
An AC sweep was again performed on the circuit using the agilent function generator, with the OP Amp being powered by the Agilent DC power generator, and the output signal being measured by the Agilent oscilloscope. The input frequency used had a Vpp of 2.0 V, with a frequency sweep from 90 to 160 Hz. Again, the frequencies were incremented by 10 except within the range of 145 to 155 where it was incremented by 1.
Notice that as the frequency approaches the cutoff, there is a downward trend. This displays the low pass had the correct cutoff frequency.
Arduino Code
The above Arduino code was written as a means of visualizing the device output with a computer monitor. Coding for the Arduino was performed using proprietary software from Arduino (Ver 1.8.16) to convert the analog output from the circuit into a digital input signal using the built in serial plotter while also performing real-time calculations of heart rate using the built in serial monitor. The arduino and written code was tested using a simulated ECG input from the Agilent function generator within the heart rate range from 60 - 120 BPM.
Testing Full Device Construction
The first image displays testing of the circuit board. The finalized analog circuit was similarly put through an AC sweep using the same devices to generate the input signal, power the OP amps, and measure the output signal. The frequency sweep was performed from 10 to 160 Hz, with increments of 10. In order to visualize the notch pass filter’s response however, increments of 1 were used between the range of 55 to 65 Hz.
Additionally, the device was tested with electrodes to produce the second figure. The combined circuit was then used to measure the ECG waveform of a human subject. The resulting ECG wave had a maximum amplitude of 590 mV, with a recorded R to R interval of approximately 850 ms. This corresponds to a subject heart rate of around 70.59 beats per minute. A notable observation of this ECG waveform is that the QRS complex and T waves are clearly visible. However, there is the presence of noise in the form of constant oscillations with an amplitude of approximately 0.25 V and the P wave was difficult to clearly identify (although still present) due to this noise.
The third image displays the LTSpice simulation with an AC sweep analysis was performed to sweep from 1 Hz to 1 kHz with 1,000 points per decade. Both the simulated and experimental outputs demonstrated the characteristics of the component circuits: a gain of 1000 (+60 dB), notch filtered attenuation at 60 Hz, and low pass filtered attenuation past 150 Hz.
Conclusion/Discussion
Overall, the design specifications were to build a functional ECG device and plot the QRS output. To measure the effectiveness of the device, three aspects were analyzed. The first portion analyzed was to determine if the device produced the needed gain of 1,000 as explained in the methods. Step 3 display both the simulation of the LTSpice and the circuit board model. The inputted amplitude was 20 mV meaning that a gain of 1,000 would produce an output to input ratio of 60 dB. Based on the oscilloscope response to this stage as seen in step 3, the ration was 60.1 dB proving that a 1,000 gain was produced. Since this criteria was fully completed, the next criteria of eliminating noise should be analyzed. Step 5 displays a drop in the gain when it is plotted against frequency. This drop occurs at a frequency of approximately 60 Hz meaning that this testing was successful. Finally, the low pass filter with a cutoff frequency of 150 Hz was tested. Step 7 displays the trend desired. However, step 9 displays a lot of noise present in the recordings. Therefore, moving forward into future experiments this should be closer analyzed. Additionally, the arduino code proved to be very successful in transferring the output signal without disruption, containing little error if any.