ECG Design for Automated Plotting of a Biosignal and BPM Readout Using an Arduino Microcontroller

by sathveka in Circuits > Sensors

423 Views, 0 Favorites, 0 Comments

ECG Design for Automated Plotting of a Biosignal and BPM Readout Using an Arduino Microcontroller

Screen Shot 2022-05-01 at 10.26.51 AM.png

An electrocardiogram (ECG) is a simple procedure used to record the electrical signal from the heart and check for various heart conditions. Patients may obtain ECGs to check for arrythmias, see how an implanted pacemaker is working, or to determine the overall health of their heart before any surgical procedures. The procedure involves placing up to 12 electrodes (sticky patches with wires that can connect to a monitor) on distinct spots of a patient’s chest and limbs to record the electrical signals that make the heart beat. A computer then records this information and generates a digital plot of the observed waveform. The observed ECG signals are comprised of the superposition of various action potentials from the heart beating. Electrodes are used to convert these ionic signals into electric ones that can later be displayed and used for analysis. However, due to the size of the signals and various noises, ECGs require filtering and amplification to achieve stable, high-quality signals.

Supplies

You will need LTSpice, access to a variety of resistors and capacitors, LM741 op amps, and an Arduino microcontroller.

Instrumentation Amplifier

Screen Shot 2022-04-30 at 11.09.30 AM.png
Screen Shot 2022-04-30 at 11.11.07 AM.png
Screen Shot 2022-04-30 at 11.12.43 AM.png
Screen Shot 2022-04-30 at 11.14.44 AM.png

Since ECG signals have amplitudes in the mere 1 mV range, amplification is required to increase the signal amplitude for further processing and display. To tackle this, you will need to construct an instrumentation amplifier. In this case, a gain of 1000 was chosen. The instrumentation amplifier was designed based on the circuit model shown in Figure 1. Based on the requirement that the circuit must be powered with 9 V before testing on a human subject, resistor values were chosen to achieve a gain as close to 1000 as possible, as seen in Table 1. In lab, the INA circuit was built using experimental resistor values that provided as close a match as possible to the theoretical values, as well as three LM741 op-amps. The INA circuit was simulated with an AC sweep for a sine wave input with AC amplitude of 1 V. The theoretical gain was achieved, as the output was equal to 1 V, whereas the input voltage was 0.001 V. To test the gain of the circuit in lab, an input sinusoidal signal with an amplitude of 10 mV and frequency of 1k Hz was sent through the function generator and the output and input amplitudes were displayed on the scope. Based on these results, it is evident that the experimental gain was equal to Vout/Vin = 23.6 V/0.034 V = 694.12, which generates a 30.59% error in comparison to the desired gain of a 1000.

Notch Filter

Screen Shot 2022-04-30 at 11.15.52 AM.png
Screen Shot 2022-04-30 at 11.17.20 AM.png
Screen Shot 2022-04-30 at 11.18.05 AM.png
Screen Shot 2022-04-30 at 11.27.26 AM.png

Next, to reduce any 60 Hz powerline noise in the signal measurement, you will need to build a notch filter to attenuate this frequency. The notch filter was designed based on the schematic attached. Using the following equations, a Q factor of 10, and a chosen capacitor of 100 nF, the following theoretical component values were calculated, as seen in the attached table. In lab, the notch filter was built using experimental resistor values that provided as close a match as possible to the theoretical values, as well as a LM741 op amp. The notch was simulated with an AC sweep for a sine wave input with AC amplitude of 1 V. It is evident that the design requirements were met, since the magnitude plot exemplified notch filter behavior, with an attenuation of frequencies centered on 60 Hz. To test whether the circuit successfully attenuated the 60 Hz artifact, the same input signal used in the INA was sent through the function generator and the output and input amplitudes were displayed on the scope over a range of frequencies. These amplitudes were inputted into Excel, and a magnitude plot was generated. In lab, it is evident that the attenuated of frequencies centered on 60.8 Hz, which generates a 1.33% error in comparison to the desired value of 60 Hz.

Low-pass Filter

Screen Shot 2022-04-30 at 11.25.45 AM.png
Screen Shot 2022-04-30 at 11.26.41 AM.png
Screen Shot 2022-04-30 at 11.27.43 AM.png
Screen Shot 2022-04-30 at 11.28.50 AM.png

Next, to reduce high frequency noise components, you will need to build a low-pass filter. Based on the currently implemented AHA guidelines, it is recommended that low pass filtering in ECG must be designed with cutoffs of 150 Hz for adolescents and adults. The filter was designed based on the circuit model attached. Using the provided equations and a gain of 1, the following theoretical component values were chosen, as seen in Table 3, where K represents gain, and a and b are filter coefficients with values of 1.414214 and 1, respectively. Since a gain of 1 was chosen, R3 can be replaced by an open circuit, and R4 can be replaced by a short circuit. The low-pass filter was built using the theoretical resistor values in LTSpice and simulated with an AC sweep for a sine wave input with AC amplitude of 1 V. It is evident that the design requirements were met, since the magnitude plot showed a cutoff frequency that was close to the desired value of 150 Hz. To determine whether the low-pass circuit constructed in lab would exemplify similar behavior, the same input signal used in the INA was sent through the function generator and the output and input amplitudes were displayed on the scope over a range of frequencies. These amplitudes were inputted into Excel, and a magnitude plot was generated. The experimental cut-off frequency was calculated to be 170.55 Hz, generating a 13.7% error from the desired value of 150 Hz.

Testing on a Human Subject

Screen Shot 2022-05-01 at 10.18.11 AM.png

To validate the filtering and amplification abilities of your designed circuit, you would need to test it on a human subject by placing electrode leads and using that signal as an input into the circuit and outputting the waveform onto the oscilloscope. Three electrodes were placed on the subject, with the left ankle as the positive input, the right wrist as the negative input, and the right ankle as ground (Lead II configuration). This waveform had a clear QRS complex, though this complex was slightly wider than normal. An inverted T wave can be seen following nearly all the QRS complexes, but no P wave was noticeable. The elongation of the QRS complex may have resulted from the settings of the oscilloscope. Changing the view of the signal may have resulted in a complex that looked like the expected width of the complex. If you have access to a higher quality monitor, this waveform would appear much more stable, with clear definition of all peaks.

BPM Readout Using an Arduino Microcontroller

Screen Shot 2022-05-01 at 10.25.25 AM.png
Screen Shot 2022-05-01 at 10.25.39 AM.png

Finally, to obtain a digital plot and readout, you will need to use an Arduino microcontroller and the attached code. In this case a simulated cardiac waveform was configured on the function generator and used as an input, since using the participant as the input resulted in wild fluctuation of the output signal. The resulting waveform from the function generator input showed periodic waveform that displays in the expected ECG form. A P wave, and QRS complex are easily identified, with the QRS complex having the expected width. The T wave, while in generally the correct location and shape, was slightly more erratic than expected, but stayed consistent from waveform to waveform. Similarly, using the Arduino code, the BPM readout was obtained. This was exactly as expected, with the BPM staying consistent at 72. Because the function generator was used with values that would theoretically result in a BPM of 72, this readout is exactly as expected, meaning both the code and the circuit function as expected.