How to Make an Electrocardiogram (ECG)

by orlaithmcs7 in Circuits > Arduino

234 Views, 2 Favorites, 0 Comments

How to Make an Electrocardiogram (ECG)

IMG_2029.jpg
Integrated Circuit.jpg

This Instructable will teach you how to build a circuit capable of producing an electrocardiogram, or ECG. An ECG is a simple test that can be used to check the rhythm and electrical activity of a person's heart, therefore it can be used to detect abnormalities such as irregular heart rate, or arrhythmias.

Supplies

To create an ECG circuit, you will need:

  • One large breadboard
  • One small breadboard
  • Resistors
  • 1x 1.8k ohm
  • 2x 43k ohm
  • 2x 1.1k ohm
  • 3x 22k ohm
  • 1x 56k ohm
  • 2x 1.6k ohm
  • 1x 424k ohm
  • Capacitors
  • 1x 22nF
  • 1x 68nF
  • 3x 100nF
  • 5x uA741 operational amplifier
  • 2x 9-V battery
  • Multiple jumper wires
  • Arduino
  • Function generator
  • Oscilloscope
  • 3x electrodes for obtaining ECG
  • 3x sticky pads
  • Many cables, including crocodile-crocodile cables

Build the Instrumentational Amplifier (INA)

INA.jpg
INA Schematic.png
INA Output.jpg

The INA is designed to amplify the input signal by a factor of 1000. As ECGs are typically signals with very low voltage (approx. 1-5mV), the signal needs to be amplified so that it is readable.

The schematic attached should be recreated on the large breadboard. The resistors should take the values of those with the corresponding labels in the following list:

  • R1 = 1.8k ohms
  • R2 = 43k ohms
  • R3 = 1.1k ohms
  • R4 = 22k ohms

A photograph of what the final circuit should look like is also included.

Check each stage after you have built them in order to detect problems early. To test this circuit, input a low voltage input, for example a 1mV signal from the function generator to the circuit. It should be working correctly if the output signal on the oscilloscope has a peak-peak voltage of 1V. A photograph of the oscilloscope is included for reference.

Build the Low Pass Filter

Low Pass Filter.jpg
Low Pass Schematic.png
Low Pass Output.jpg

The low pass filter is designed to only pass through signals lower than the cutoff frequency of 150Hz. This is in line with the industry standard that ECG machines should record signals up to 150Hz in frequency.

The schematic attached should be recreated on the large breadboard, below the INA. The resistors and capacitors should take the values of those with the corresponding labels in the following list:

  •  R1 = 22k ohms
  • R2 = 56k ohms
  • C1 = 22 nF
  • C2 = 68 nF

A photograph of what the final circuit should look like is also included.

In order to test this circuit, run a frequency analysis using the oscilloscope. The output should show that the signal becomes attenuated from 150Hz onwards. A sample frequency response is included in the attached figures.

Notch Filter

Notch Filter.jpg
Notch Schematuc.png
Notch Output.jpg

The notch filter is designed to have a centre frequency of 60Hz. This is in order to remove the noise that comes from electrical power supplies - the noise typically has a frequency of 60Hz.

The schematic attached should be recreated on the small breadboard. The resistors and capacitors should take the values of those with the corresponding labels in the following list:

  •  R1 = 1.65k ohms
  • R2 = 424k ohms
  • R3 = 1.65k ohms
  • C1 = C2 = C3 = 100 nF

A photograph of what the final circuit should look like is also included.

In order to test this circuit, run a frequency analysis using the oscilloscope. The output should show that the signal becomes attenuated at 60Hz. A sample frequency response is included in the attached figures.

Connect the Individual Components to Make an Integrated Circuit

Integrated Circuit.jpg
Picture1.png
Picture2.png

With all of the separate filters now constructed, it's time to connect them! Firstly, connect the two separate breadboards using jumper wires. It is very important that the negative rail indicating the ground of both breadboards are connected, to ensure the grounding is consistent for the entire circuit. Next, connect the output wire of the INA to the input pin of the low-pass filter. Once this is complete, connect the output wire of the low-pass filter to the input pin of the notch filter.

Now that all circuit components are connected together, it is time to test the circuit using a simulated ECG!

Test a Simulated ECG

Picture3.jpg

An electrocardiogram signal can be simulated using a waveform generator. Select the appropriate in-built ECG waveform function using the user interface. The signal should have a low amplitude input of 1 - 5 mV and a frequency of around 1.2 Hz. Connect the generator to the input terminal of the integrated circuit. Also use a separate lead to connect the generator directly to the oscilloscope. Next, connect the output terminal, located after the notch filter, to a digital oscilloscope. Adjust the time and voltage scales to observe two signals that contains the characteristic P, QRS, and T waveform of an ECG. The input signal should appear less clear due to its low amplitude. If the circuit is operating correctly, the output signal should be amplified with a gain of approximately 1000 and the waveform should appear much sharper than the input signal.

Test a Human ECG

bjon-2019-28-12-756_f01.jpg
F2MDF8TLBDZ602E.jpg

Once you have confirmed the effectiveness of the integrated circuit using a simulated waveform, and verified it is safe to use, it is time to test the circuit on a human subject! Connect the electrodes on each of the positions as shown above. Connect separate leads from: the ground to the right ankle, the positive to the left ankle, and the negative to the right wrist.

Ensure that the patient remains still during testing. If you are testing another person, make sure you get consent before placing electrodes and performing the test. Once all electrodes have been attached, connect the output pin to an oscilloscope. Observe the output on the oscilloscope. This ECG signal may not entirely match the simulated signal, but the P, QRS, and T waveform should still be identifiable. You can now measure the frequency of the patients heartrate. To convert from Hertz to beats per minute (bpm), multiply the frequency obtained by 60, and you now have the person's heart rate in bpm.

Incorporate Arduino

Picture4.png

Now that you have obtained a human ECG signal, it's time to display it and plot it on your own computer! Create an Arduino code that will read in the analog signal and convert it to digital. You can use the function analogRead() to do this. You can the use Serial.println() to print the analog-to-digital converter (ADC) value to the serial monitor or serial plotter. The serial plotter will allow you to observe the ECG signal, with the peaks and troughs of the ECG visible. An example output can be seen below.

You can also create an automatic bpm readout in the same Arduino script. You do this by noting the values the highest peak reaches to define an upper and lower threshold. The pules interval can be recorded using the millis() function along with if and else statements. This interval is the time taken between two spikes (P wave). The formula (1.0/PulseInterval) * 60.0 * 1000 is used to find the frequency of the heartrate in bpm, and this value is then printed to the serial monitor.