ECG Circuit (using Breadboard, LTSpice, and Arduino)

by egrivett in Circuits > Electronics

1863 Views, 1 Favorites, 0 Comments

ECG Circuit (using Breadboard, LTSpice, and Arduino)

circuit.png
all together.JPG
flowchart.JPG

About 6.2 million adults in the United States have heart failure, which cost the nation an estimated $30.7 billion in 2012 [1]. With such a large impact on the ever-growing population and economy, cardiology is a target area of research and treatment in the U.S. healthcare system. The risk factors for heart failure include diabetes, high blood pressure, obesity, and smoking. These can be prevented by managing insulin, exercising, a balanced and healthy diet, and physical activity. However, when these prevention methods are surpassed by the progression of the disease, an electrocardiogram (ECG) can be used to evaluate the heart’s electrical activity and ultimately determine the best route for treatment. For example, ECGs can determine the heart's overall health after treatment for a condition such as a heart attack (myocardial infarction, or MI) [2].

The placement of leads (electrodes that graphical map the heart's electric activity) is extremely important for an accurate ECG output. For our design project, we will focus on limb leads and how the placement of +, -, and ground affects signal inversion. It is of utmost importance to reduce artifacts since the heart’s electrical signal has very little output, so it can easily be combined with other signals of identical frequency to create artifacts [5]. 

The simulated ECG will contain three different components: an instrumentation amplifier, a low-pass filter, and a notch filter to attenuate noise sources in this project. The instrumentation amplifier increases small differential signals and has a high input impedance while outputs a low input impedance [6]. A low-pass filter passes any signal that has a frequency less than the cut-off frequency, while a notch passes most frequencies but attenuates frequencies in a very specific range to very low levels [7]. When analyzing ECG input signals, an interference noise occurs around 60Hz, the same as AC frequency; consequently, our design includes a notch filter to filter out that signal. 


References:

[1] https://www.cdc.gov/heartdisease/heart_failure.htm 

[2] https://www.hopkinsmedicine.org/health/treatment-tests-and-therapies/electrocardiogram

[3] https://elentra.healthsci.queensu.ca/assets/modules/ECG/normal_ecg.html 

[4] https://litfl.com/ecg-limb-lead-reversal-ecg-library/ 

[5] https://www.primemedicaltraining.com/12-lead-ecg-placement/ 

[6] https://www.electronics-tutorials.ws/filter/filter_2.html

[7] https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=3880 

Supplies

Agilent E3631A DC Power Supply

Agilent 33220A Function Generator

Agilent DSO6014A Oscilloscope

ECG Electrodes

Arduino UNO

Laptop with Arduino Program

Breadboard with connecting wires

Required resistors (with values as shown in LTSpice schematic below)

Required capacitors (with values as shown in LTSpice schematic below)

LM741 Op-Amps

BNC to BNC cables

T-adaptor

BNC to grabber cables

Alligator clips

LED Lightbulb

2x 9V batteries

Create Schematic of Instrumentation Amplifier Stage

amplifier.JPG
amplifier calc.png
amplifier results.jpg

This instrumentation amplifier is designed to increase the quiet ECG signal, making it easier to read on the oscilloscope/Arduino.

First, determine how much you would want to amplify the ECG signal. For the example shown above, we used a gain of 100. Then, using the equation in the example, calculate the correct four resistor values necessary and available to you to achieve that gain. Simulate the circuit in LTSpice (you can use the circuit shown above, replacing the resistor values with your calculations).

Then, using these resistor values and three LM741 op-amps, build the circuit onto a breadboard. Utilize the function generator to produce a sine wave with a 1mV at 1.2 Hz input, a power supply to provide the op-amps with 15V and -15V, and an oscilloscope to visualize and test the results. The resulting plot should look similar to the one above, with the output being an amplified version of the input.

Create LTSpice Schematic of Notch Filter

notch.JPG
notch calc.png
notch results.png

Because there is typically noise at 60 Hz due to powerline interference and muscle contractions, the notch filter is designed to filter out any signal response at 60 Hz.

First, knowing that we wanted a center frequency of 60 Hz, and in this example, we chose a quality factor of 8. Knowing these numbers, use the equation shown above to calculate the correct three resistor values and two capacitor values necessary and available to you to achieve that center frequency and Q factor. Simulate the circuit in LTSpice (you can use the circuit shown above, replacing the resistor values with your own calculations).

Then, using these resistor and capacitor values and one LM741 op-amp, build the circuit onto a breadboard. Utilize the function generator to produce a sine wave with a 1V at 1.2 Hz input, a power supply to provide the op-amp with 15V and -15V, and an oscilloscope to visualize and test the results. Increase the input on the function generator from 1.2 Hz to 1k Hz to truly record the results. After capturing this data, the resulting magnitude response plot should look similar to the one above, with a large dip in the magnitude of the output at 60 Hz.

Create LTSpice Schematic of Low-Pass Filter

low pass.JPG
low pass calc.png
low pass results.png

To filter out the rest of the noise and to focus solely on the ECG signal, the low-pass filter is designed to only let in signals below 150 Hz.

First, knowing that we wanted a cutoff frequency of 150 Hz and a gain of 1, use the equation shown above to calculate the correct two resistor values and two capacitor values necessary and available to you to achieve that cutoff frequency and gain. Simulate the circuit in LTSpice (you can use the circuit shown above, replacing the resistor values with your own calculations).

Then, using these resistor and capacitor values and one LM741 op-amp, build the circuit onto a breadboard. Utilize the function generator to produce a sine wave with a 1V at 1.2 Hz input, a power supply to provide the op-amp with 15V and -15V, and an oscilloscope to visualize and test the results. Increase the input on the function generator from 1.2 Hz to 1k Hz to truly record the results. After capturing this data, the resulting magnitude response plot should look similar to the one above, with an exponential decrease in the output's magnitude after 150 Hz.

Build Final Circuit Onto Breadboard

all together.JPG
circuit.png

Once each component is tested separately, connect the instrumentation amplifier, notch filter, and low-pass filter into a singular circuit as shown in the LTSpice schematic and breadboard above.

Test Full Circuit With Human Subject and Oscilliscope

oscilliscope.jpg

Once each component has been connected, replace the 15 V and -15 V power supply with two 9 V batteries (for safety purposes). Have the human test subject place the ECG tab electrodes onto the inside of each ankle and the inside of the right wrist. Connect the right wrist to the circuit to the first instrumentation amplifier input and the left ankle to the second amplifier input. The right ankle should be grounded. Connect the output to the oscilloscope as before and adjust the settings to show a clear ECG signal and record the results. The output should look similar to the example above.

Create Arduino Code to Model Subject's ECG Signal and BPM

Ensure that the correct and most updated Arduino program is downloaded onto the chosen laptop device. Develop your own or use the code attached below to correct display the ECG signal and BPM of the subject onto the device. The code has additional code to turn on an LED light bulb during each QRS complex that has been properly commented.

Downloads

Implement Arduino Into Device and Test Code

arduino output.jpg
bpm output.png

Once a clear and stable signal is achieved through the oscilloscope, we can use the Arduino to visualize the results. Connect the Arduino Uno to the laptop and the circuit through the A0 and ground pins. Place the LED lightbulb into pin 13 and ground. Upload and run the program and click on "Serial Plotter" to observe the results. To obtain a more accurate BPM, note a more accurate upper and lower threshold that the QRS complex hits every time without being exposed to the extra noise and adjust the code accordingly. Click on "Serial Monitor" to observe the measured BPM. The results should be similar to the examples above. If there are any problems, continue to adjust the code or electrodes accordingly.