Functional ECG Circuit Design Project

by Ethan_C57 in Circuits > Electronics

608 Views, 0 Favorites, 0 Comments

Functional ECG Circuit Design Project

Full circuit.jpg

In this article I will explain how to create a working ECG circuit that will be able to appropriately measure your heartbeat. In addition, it will be able to work with an Arduino device and the necessary code will be supplied. It is recommended that you are comfortable with circuit assembly before you begin this project.

The plan for the project is to build three separate circuits: the instrumentational amplifier (INA), the notch filter, and the low pass filter. When these individual circuits are combined together they form a functioning ECG device, in which we are able to measure an individual's heartbeat. Once we are able to complete that, we will use the Arduino device and analytical software system to analyze our ECG output, calculate a BPM, and further optimize our circuit.

Supplies

supplies.jpg
capacitors.png
ting.png

This project requires a large amount of supplies, which can be a bit overwhelming if you do not have some of the components already. Circuitry components are most easily purchased online on websites such as Amazon (worldwide), DigiKey (US), SparkFun (US), Bitsbox (UK), Seeed Studio (China), and Farnell (worldwide).


The components you will need are listed below:

  • At least one breadboard
  • 12 Resistors (these values can be modified if you do not have the exact resistor values by about 5%, although it will affect your data): 4 1K Ohm, 2 1.5K Ohm, 2 10K Ohm, 1 20K Ohm, 1 33K Ohm, 1 50K Ohm, and 1 470K Ohm
  • 5 Capacitors (same as with resistors, the closer these values are to their exact capacitor value the better the output will be): 0.1uF, 0.1uF, 0.2uF, 0.0161uF, and 0.033uF.
  • 5 LM741 Op Amps
  • 1 LED light
  • Plenty of wires and alligator clips
  • 2 9V batteries
  • A function generator (for supplying an input voltage).
  • An oscilloscope (for displaying and analyzing the data)
  • 3 electrodes
  • 3 electrode stickers
  • An Arduino device with HDMI cable.
  • A laptop

We will be using a function generator and an oscilloscope to test and display our circuits at each step. Here is a YouTube video that goes through how to use both devices: https://www.youtube.com/watch?v=gWDTMJtPoQc. While the device that you are using may differ from the exact one used in the video, they all work in the same way.

Instrumentational Amplifier (INA)

ina annotated.png

In the first step, we will be creating the INA filter. This will allow us to amplify our heartbeat so we can more easily remove the random frequency noise that blocks us from analyzing the heartbeat effectively. We will need a breadboard, 6 resistors (3 1K Ohm, 2 10K Ohm, and 1 50K Ohm), 2 9V batteries, 3 LM741 op amps, and plenty of wires and alligator clips. Place these as shown in the pictures.

I recommend that for each of the following separate circuits you test to ensure a proper output is created. In this case, if a 1mV sin wave is supplied to the circuit as an input, ideally a 1V output should be displayed.

Notch Filter

idk anymore.png

In the second step, we will be creating the notch filter to the right of the INA filter. This is the first filter used to remove the random frequency noise that disturbs our desired display. We will need our breadboard, 3 resistors (2 1.5K Ohm and 1 470K Ohm), 1 LM741 op amp, 3 capacitors (2 0.1uF and 1 0.2uF), and plenty of wires and alligator clips. Place these as shown in the pictures.

When testing this part, the output approaches 0V as the frequency approaches 60 Hz, remaining a high voltage at farther away frequencies.

Low Pass Filter

low pass a.png

In the third step, we will be creating the low pass filter to the right of the notch filter, which will remove the last part of the random noise. We will need our breadboard (grab a second if it gets too crowded), 2 resistors (1 20K Ohm and 1 33K Ohm), 1 LM741 op amp, 2 capacitors (1 0.0161uF and 1 0.033uF), and plenty of wires and alligator clips. Place these as shown in the pictures. Please note the battery inputs shown are replaced with battery input into the rails in the following step.

When testing this part, the output should remain high until the frequency approaches 300 Hz, and will begin to drop as the frequency is increased pass that point.

Completing the Circuit

complete circuit annotated.png

Finally we are going to need to connect the circuits together. Place wires and alligator clips as shown below in order to connect the circuit appropriately. It is important to note the parts are changed when compared to the previous sections, as the batteries are placed into the rails on the sides instead of through wires and the inputs from the previous part are used instead of the function generator input. When this is done, we have finally completed our ECG and by applying an arbitrary input voltage a heartbeat pulse should be displayed on the oscilloscope.

Testing the Complete Circuit

jfl;asdjfa;lsf.png
The-components-of-ECG-signal.png

In order to test our circuit, we can use a functional generator to put an arbitrary voltage source into the INA circuit. This supplies the voltage throughout the entirety of the three circuits, and we can take the output voltage at the end of the low pass filter and display it in our oscilloscope. The display should be similar to the one shown above, with the yellow as the input voltage (from the function generator) and the green as the output voltage (from the circuit). We are able to see the output is amplified due to the INA and the noise is removed due to the notch and low pass filters. The output resembles a heartbeat, with the P, Q, R, S, and T segments able to be identified.

Testing With a Real Heartbeat

;afklj;adsfjdaks;fas.png

Now we are going to take a look at our own heartbeat. Using the same circuit from before, we are going to switch the input voltage from the function generator to our body.

There are plenty of things to note with this section. As with any type of testing with people, take caution when preforming the experiment. In addition, it is a necessity that the 9V batteries are utilized as they will prevent the person from being harmed if anything goes wrong. It is strongly recommended to have completed step 5 appropriately before continuing on with this step.

In order to add the input voltage from the person into the circuit, we will be using three electrodes and three electrode stickers. The electrode stickers are attached to the right ankle, left ankle, and right wrist. The ground electrode is attached to the right ankle, the positive electrode is attached to the left ankle, and the negative electrode is attached to the right wrist. Then the ground electrode is attached to the ground of the circuit, and the positive electrode attached to the input of the INA, and the negative electrode attached to the second input in the INA (not shown as it was grounded in the previous parts, is indicated by the red wire shown in the above INA step).

Using the oscilloscope in the same way as the previous part, we should see a very similar heartbeat display. This section can be very finnicky, as if the signal is too low the output may not be displayed. Double check the electrodes are functioning properly and try to use as little wires as possible to remove any signal deterioration.

Arduino

arduino basic.png

Now that we have done all the hard stuff, we can use the Arduino software to help us display our outputs better and eventually determine the BPM of the individual. First, download the Arduino software found at https://www.arduino.cc/. Then, using the HDMI cable, attach the Arduino device into the computer. Once the device is connected, download the code and copy it into the program.

We can test the Arduino first using the function generator. Creating the same arbitrary voltage input as we used before, we can plug the positive input into the A0 pin and the negative input into the ground pin of the Arduino device. Running the code, we should see the ECG graph displayed and the BPM being calculated (the upper and lower threshold values may need to be adjusted in order to produce a stable BPM). Once that is complete, we can run the input either from the function generator or from a person into our combined circuit from the previous steps and plug the positive and negative outputs into the A0 and ground pin respectively, and the same result should be obtained.

If you need help with the Arduino coding software, here is a link to their website that provides helpful examples and guides: https://www.arduino.cc/en/Tutorial/HomePage.

Downloads

Spicing Up the Arduino

arduino part 2 annotated.png

The Arduino device and software allows for plenty of easy adjustments that improves the quality of the device. We utilized the following code to make an LED light switch on when the heartbeat was in the QRS stage and turn off when it was in a different stage. We made the following adjustments to the code, which can be downloaded in the following document. We built a basic circuit, using a breadboard, a 1k Ohm resistor, a LED light, and a few wires, as shown above. Our code requires that the wiring from the Arduino to the circuit be placed in pin 2 and ground. When the circuit is ran, the LED should flicker at a relative rate to the BPM.

And now you have a fully functioning ECG circuit! There are plenty of other coding and circuitry options that can optimize the circuit that I welcome you to try, such as creating an Graphical User Interface to control the program or build additional circuit parts to create a more efficient output.