Functional ECG to Plot Biosignals and BPM Readout

by jcawi in Circuits > Arduino

197 Views, 1 Favorites, 0 Comments

Functional ECG to Plot Biosignals and BPM Readout

Screen Shot 2022-05-01 at 2.27.13 PM.png

An electrocardiogram, or ECG, is a fast and simple test to show the strength and rhythm of a heart through measuring its electrical impulses. Electrodes are attached to the patient through stickers on the skin which record the electrical impulses allowing for blood flow.  An ECG requires different filters to both magnify the small biological electrical impulses, and to remove any noise causing inaccurate readings. Through building three different types of filters which underwent individual testing, then integrating them into one circuit, we achieved a stable ECG signal with little noise and accurate heart rate measurement when used on a human subject.

Supplies

  • Breadboard
  • Wires in a variety of lengths
  • Alligator clips/possible other cable adaptors
  • 5 op amps
  • 12 resistors (values vary and will be determined in steps below)
  • 5 capacitors (values vary and will be determined in steps below)
  • Function generator
  • Oscilloscope
  • Tape (not necessary, but recommended)
  • Laptop with HDMI port
  • Arduino Uno
  • 9 Volt Battery

Calculate Component Values for INA Filter

Screen Shot 2022-05-01 at 3.23.09 PM.png

The components for the INA filter should be determined by selecting a gain and then finding component values available in the laboratory to reach this gain. An a worked out example with a gain of 1000 is provided above.

Determine LTSpice Output for INA Filter

Screen Shot 2022-05-01 at 3.11.19 PM.png
F09SSH0L2NB0U1W.png

Above is the goal output in LTSpice for the INA Filter using the following schematic.

Build INA Filter Based on LTSpice Schematic

Screen Shot 2022-05-01 at 2.28.42 PM.png
Screen Shot 2022-05-01 at 2.32.40 PM.png

The INA Filter should be built on the first third of the breadboard using the component values calculated in Step 1. Three op amps should be placed and charged via 9 Volt battery connected at each side of the first op amp. The op amps should be placed bridging the gap between the top and bottom portion of the bread board as seen in the physical build above. Be sure to ground each op amp and connect the positive input into each op amp for the circuit to work appropriately. The LTSpice schematic should be used as a guideline if other component values were chosen.

Calculate Component Values for Notch Filter

Screen Shot 2022-05-01 at 3.09.14 PM.png

The components for the Notch filter should be determined by using a quality of 8 and initial input frequency of 60 Hz. An example of a worked out example is provided above. The component values should be used to create an LTSpice configuration to confirm a feasible output and then a physical circuit.

Determine LTSpice Output for Notch Filter

Screen Shot 2022-05-01 at 3.12.07 PM.png
FDH886ML2NB0U1N.png

Above is the goal output in LTSpice for the Notch Filter using the following schematic.

Build Notch Filter Based on LTSpice Schematic

Screen Shot 2022-05-01 at 2.28.08 PM.png
Screen Shot 2022-05-01 at 2.54.29 PM.png

The Notch filter should be built in the middle third of the breadboard. Separating these filters with tape may make later integration easier as the filters are easily divided. The component values were calculated in Step 4. If the specific values are not available in your lab setting, obtain the closest available value. Create the physical build by following the LTSpice schematic and the example image above. In this case, a capacitor value did not exist, so two capacitors were combined in series to mimic the desired value.

Calculate Component Values for Low Pass Filter

Screen Shot 2022-05-01 at 3.33.38 PM.png

The equations above should be used to calculate the component values for the lowpass filter. 150 Hz should be used as the cutoff frequency is the test subject is an adult or adolescent and 250 Hz should be used for children. Above is an example of a worked out calculations for the low pass filter components.

Determine LTSpice Output for Notch Filter

Screen Shot 2022-05-01 at 3.37.33 PM.png
F9DTOIXL2NB0U21.png

Above is the goal output in LTSpice for the Notch Filter using the following schematic.

Build Low Pass Filter Based on LTSpice Schematic

Screen Shot 2022-05-01 at 2.28.58 PM.png
Screen Shot 2022-05-01 at 2.55.06 PM.png

The final filter built should be the low pass filter on the last third of the breadboard. A singular op amp is required for this circuit and should be placed splitting the top and bottom of the breadboard, in line with the op amps from the INA circuit. Be sure to ground the circuit and follow the above schematics to build the lowpass filter.

Measure Magnitude for Each Filter

For each filter, using the known cutoff frequency, the magnitude needs to be calculated at varying frequencies. The Vin, Vout and frequency should be measured for each output. The magnitude is calculated by taking Vout/Vin. The values of magnitude should be plotted against frequency to form plots. The plots should be used to ensure the goal cutoff frequency was reached.

Integrate Filters to Create ECG

FQBWZC0L2NB0U1F.png

To begin to form the actual ECG, the three individual filters need to be integrated. The input of the Notch filter should be connected to the output of the INA filter via a wire. The input of the Low Pass filter should be connected to the output of the notch filter via a wire. The picture above can be used as a guide for proper connection. It is also recommended to replace the 9 Volt battery at this step with a function generator set to 10 Volts to avoid the waveform being cutoff on the oscilloscope. The overall input should be received at the input of the first op amp of the INA filter. The input should be moved from an artificial wave to a waveform created by a human subject.

Place Electrodes on Human Subject

To connect a human subject to the circuit, three electrodes need to be placed on them, one on a the left wrist and one on each ankle. The electrodes are called leads and allow for a positive voltage input, a negative voltage input, and a ground. These 3 leads will be connected into a single input on the circuit.

Connect Circuit to Arduino UNO

Screen Shot 2022-05-01 at 2.58.48 PM.png

Obtain an Arduino Uno and download the Arduino software to your laptop. An HDMI connection port is needed on the laptop to connect to the Arduino Uno. Connect the circuit to the Arduino in pins A1 and a Ground. Prior to running the code, make sure the code is uploaded to the Arduino by selecting the arrow button. Additionally, go to the 'Tools' section and change the 'Port' to the option for Arduino Uno. Both of these are common mistakes that are overlooked and can ease the troubleshooting of possible errors. Above is an example of the code that aids in the BPM measurement and ECG waveform output.

Determine BPM and Waveform Output

Screen Shot 2022-05-01 at 3.04.03 PM 1.png
Screen Shot 2022-05-01 at 3.04.11 PM.png
Screen Shot 2022-05-01 at 3.05.54 PM.png

To view the BPM select the 'Plot' option under tools, and to view the BPM, select the 'Monitor' option. The wave form should appear similar to the standard ECG waveform as seen below. Change the baud to '74880' in the baud options located on the lower left corner. If no output is seen, but there is no code error, change the baud until an option is presented. (It should normally be '74880') The BPM appears quickly in the Monitor portion but should be within the range of 60-100 bpm depending on the human subject. Above provides the goal waveform, an example of the waveform output, and of the monitor displaying BPM.