Electrocardiogram (ECG) Circuit

by mahaja25 in Circuits > Arduino

374 Views, 1 Favorites, 0 Comments

Electrocardiogram (ECG) Circuit

ACLS-Figure-21.jpg
1651196417834.jpg

The projects aims to design a functional ECG with automated plotting of the biosignal and an automated BPM readout.

Link: https://www.instructables.com/Electrocardiogram-ECG-Circuit-2/

Introduction to an ECG:

An electrocardiogram (ECG/EKG) is an electrical recording of the heart and is used to investigate various types of heart disease (like arrhythmia) based on the beats and rhythms. Each region of the heart will retrieve a unique bipotential, which will generate different ECG waveforms, which can be used to diagnose heart conditions.

ECG measurement information is obtained by skin electrodes at specific locations on the body. The signal is characterized by six peaks and valleys labeled with letters P, Q, R, S, T, and U


Introduction to our Device:

We are biomedical engineering students that aim to design a circuit model that can amplify and filter an incoming ECG signal. Our model consists of an instrumentation amplifier, an active notch filter, and a low pass filter. We will then develop Arduino code to obtain a ECG waveform and BPM readout. We modeled the circuit in LTSpice, and then tested our components in the lab.




Supplies

  1. Breadboard
  2. Operational amplifiers (Op-amp). We utilized the uA741 op-amp
  3. Resistors of various resistances
  4. Capacitors of Various capacitances'
  5. Wires
  6. Stick-on electrodes
  7. Oscilloscope
  8. Function Generator
  9. DC Power Supply
  10. 2 9V batteries
  11. Arduino UNO
  12. LED

Designing the Instrumentation Amplifier

Capture.JPG
Capture2.JPG

The first component of the model is an instrumentation amplifier and it aims to amplify the incoming signals, which have a very low voltage. Since, the normal amplitude of an ECG signal is 1mV, we will design a amplifier with a gain of 1000 to obtain an output ECG signal between 1-2.5 V. The instrumentation amplifier is beneficial because it eliminates the need for input impedance matching, and consists of low noise, very high open loop gain and very high common-mode rejection mode.

Designing the Circuit using LTSpice

We first designed and tested our circuit in LTSpice (figure above).

Op amps 1 and 2 (U1 and U2) are non-inverting amplifiers that form the input stage and op amp 3 (U3) is a difference amplifier that forms the output stage of the instrumentation amplifier.

We also wanted to ensure that the gain of each stage was comparable (to protect the user if the system is connected to a person by preventing all the gain from happening in one place) and that we used R values in the kOhm range

We used the following calculations


Gain of Part 1 = (1+ (2 *R2) / R1)

We choose R1 = 2k Ω and R2 = 49k Ω. Hence, gain of part 1 = 50 


Gain of Part 2 = R4 / R3

We chose R4 = 20k Ω and R3 = 1k Ω. Hence, gain of part 2 = 20 


Overall Gain, Vout / (Vin2-Vin1) = Gain of Part 1 * Gain of Part 2 =

(1+(2 * R2) /R1)* (R4 / R3) = 50 * 20 = 1000

In LTSpice, we carried out a transient analysis of a sinusoidal input signal of 1 mV at 1.2 Hz to confirm a gain of 1000. An image of our results is included.

Testing the Amplifier in the Lab

In the lab, we powered the circuit via the function generator with a sinusoidal wave of amplitude 10 mV and frequency 1.2 Hz, powered the op-amps using a 9V DC power supply and observed the output signal on an oscilloscope

Results:

  1. LTSpice Simulation

An image of our results was uploaded and a output voltage of 1.0 V was observed for an input voltage of 1 mV, indicating a gain of 1000.


Designing a Notch Filter

capture 2.JPG
Capture.JPG
Capture3.JPG

Next, we designed a notch filter. The purpose of this component is to attenuate signals with a frequency of 60 Hz, which is the frequency of AC line voltage interference. Removing signals at 60 Hz will help remove distortion of ECG signals. The filter only attenuates the signal at 60 Hz. Input frequencies < 60 Hz and > 60 Hz pass unattenuated (magnitude = approx 1)

Designing A Notch Filter in LTSpice

We designed a twin-T notch filter with a cutoff frequency of 60 Hz, order 2 and gain 1. We combined an op-amp with resistive and capacitive components. Additionally, we chose the Quality factor, Q to be 8 (we aimed it to be < 10). A Q value of 8 provides an acceptable filtering output while keeping the component values in a feasible range.

The first image represents the designed circuit and the second image represents the equations and calculations that we utilized.

Testing our Circuit in LTSpice

Once modeled in LTSpice as shown in Figure 1, an AC sweep of a sinusoidal input signal of 0.001 V is performed from 0.1 Hz - 100k Hz to confirm a notch at 60 Hz. The third image represents our theoretical output. Observe a dip at 60 Hz, indicating the signal has been attenuated at 60 Hz

Testing our Circuit in the lab

In the lab, we powered the circuit via the function generator with a sinusoidal wave of amplitude 1 V and frequency 1.2 Hz, powered the op-amps using a 9V DC power supply and observed the output signal on an oscilloscope

Remark:

  1. When we tested the circuit in the lab, we observed that the cutoff frequency was 60 Hz. The slight variation in simulation results when compared to the theoretical results is likely due to rounding done when calculating the resistive and capacitive components of this circuit. To bring it closer to the desired cutoff frequency of 60 Hz, we increased the value of R2 to 459 kΩ. In the lab, we connected 390kΩ, 47kΩ and 22kΩ in series.




Designing an Active Low Pass Filter

cap1.JPG
cap2.JPG
cap3.JPG

This is the third component of the full ECG model. The ECG signal consists of multiple waveforms with their own frequency. We want to capture all these waveforms but eliminate any high frequency noise. The American Heart Association recommends an upper-frequency cutoff of at least 150 Hz to accurately measure routine durations and amplitudes in adults. Hence this filter has a cutoff frequency of 150 Hz and will attenuate any signals > 150 Hz. 

Designing our Active Low Pass Filter in LTSpice

We aimed to design a low pass filter with a cutoff frequency, fc = 150 Hz and gain, K = 1. Additionally, the values of the filter coefficient a = 1.414214 b = 1. The second figure represents the appropriate equations and calculations used.

Testing our Circuit in LTSpice

Once modeled in LTSpice as shown in Figure 1, an AC sweep of a sinusoidal input signal of 0.001 V is performed from 0.1 Hz - 100k Hz to confirm that the filter only attenuates signal > 150 Hz. The third image represents our theoretical output.

Testing our Circuit in the lab

In the lab, we powered the circuit via the function generator with a sinusoidal wave of amplitude 1 V and frequency 1.2 Hz, powered the op-amps using a 9V DC power supply and observed the output signal on an oscilloscope

Remark:

When we tested the circuit in the lab, we observed that the cutoff frequency was around 190 Hz, much higher than the required cutoff frequency. To bring it closer to the desired cutoff frequency of 60 Hz, we increased the value of To decrease the cutoff, we will increase R3 to be 24k ohm. This gave us a cutoff frequency of 150 Hz, as predicted.



Testing the Entire Circuit to Record a Human ECG

cap4.JPG

Before testing the circuit on a human, we recommend testing it using a cardiac waveform on the function generator. This is a safety measure and will also help confirm if the circuit is working appropriately. The circuit was tested using a cardiac waveform on the function generator at a frequency of 1.2 Hz and with a magnitude of 12.7 mV. 

We recommend following all safety precautions before testing on a human. Ensure all sources are grounded and ensured that the powers supply being used for the op amps limited the current at 0.015 mA

Electrode Lead Positions

There are many acceptable lead configurations, but we chose to place the positive electrode on the left ankle, the negative electrode on the right wrist and the ground electrode on the right ankle.

Result:

The results should be a clean ECG signal through the circuit. The QRS complex, P wave and T wave are clearly visible. The heart rate should be reasonable. Figure represents the output obtained. The HR (heart rate) can be calculated by finding the frequency between 2 waves using an oscilloscope. We observed a BPM of 78.

Testing the Circuit With an Arduino UNO

F7DEFB4D1987450A990CC92A0C8FF461.png
arduino bpm 207.JPG
  1. Connect the electrodes to the human as in the previous output.
  2. Download the Arduino app and write down appropriate code to print an ECG waveform and get a BPM readout. Detect the heart beat's leading and trailing edge and print out the BPM.
  3. Ensure the Baud Rate of the program is same as Arduino.
  4. Read the input on analog pin 0
  5. Convert the analog reading (which goes from a reading from 0-1023) to a voltage (0-5V)
  6. Print out the value you read
  7. Adjust the threshold levels based on the signal inputs to obtain an appropriate ECG waveform

Results:

  1. We observed a clean ECG with distinguishable P, QRS interval and T wave.
  2. The BPM obtained was 72, which closely matches the BPM obtained via the oscilloscope

Future Additions:

We added an LED that lights up with each QRS peak in the signal