Introduction: Automated ECG- BME 305 Final Project Extra Credit
An electrocardiogram (ECG or EKG) is used to measure the electrical signals produced by a beating heart and it plays a large role in the diagnosis and prognosis of cardiovascular disease. Some of the information gained from an ECG includes the rhythm of the patient’s heartbeats as well as the strength of the beat. Each ECG waveform is generated by an iteration of the cardiac cycle. Data is collected through electrode placed on the skin of the patient. The signal is then amplified and noise is filtered out in order to properly analyze the data present. Using the data that is collected researchers are able to not only diagnose cardiovascular diseases, but the ECG has also played a large role in increasing the understanding and recognition of more obscure diseases. The implementation of ECG has greatly improved the treatment of conditions such as arrhythmia and ischemia .
This Instructable is for simulating a virtual ECG device and therefore all that is required to conduct this experiment is a working computer. The software used to the following simulations is LTspice XVII and it can be downloaded from the internet.
Step 1: Step 1: Instrumentation Amplifier
The first component of the circuit is an instrumentation amplifier. As the name suggests, the instrumentation amplifier is used increase the magnitude of the signal. An ECG signal that is not amplified or filtered is roughly 5 mV in amplitude. In order to filter the signal, it needs to be amplified. A reasonable gain for this circuit would have to be large in order for the bioelectrical signal to be filtered appropriately. Therefore, the gain of this circuit will be about 1000. The general form of an instrumentation amplifier is included in the images for this step . In addition the equations for the gain of the circuit, the values that were calculated for each component are shown in the second image .
The gain is negative because the voltage is supplied to the inverting pin of the operational amplifier. The values shown in the second image were found by setting the values of R1, R2, R3, and gain as desired values and then solving for final value R4. The third image for this step is the simulated circuit in LTspice, complete with accurate values.
In order to test the circuit, both as a whole and as individual components, an alternating current (AC) analysis should be run. This form of analysis looks at the magnitude of the signal as the frequencies change. Therefore, the analysis type of AC analysis sweep should be a decade because it sets the x-axis scaling and is more conducive for accurately reading the results. Per decade, there should be 100 data points. This will accurately convey the trends in the data without overworking the program, ensuring efficiency. The start and stop frequency values should encompass both cut off frequencies. Therefore, a reasonable starting frequency is 0.01 Hz and a reasonable stopping frequency is 1kHz. For the instrumentation amplifier, the input function is a sine wave with a magnitude of 5 mV. 5 mV corresponds with the standard amplitude of an ECG signal . A sine wave mimics the changing aspects of an ECG signal. All of these analysis settings, except for the input voltage, is the same for each component.
The final image is the frequency response plot for the instrumentation amplifier. This shows that the instrumentation amplifier is able to increase the magnitude of the input signal by about 1000. The desired gain for the instrumentation amplifier was 1000. The gain of the simulated instrumentation amplifier is 999.6, found using the equation shown in the second photo. The percent error between the desired gain and the experimental gain is 0.04%. This is an acceptable amount of percent error.
Step 2: Step 2: Notch Filter
The next component used in the ECG circuit is an active filter. An active filter is just a filter that requires power in order to function. For this assignment, the best active filter to be used is a notch filter. A notch filter is used to remove signal at a single frequency or a very narrow range of frequencies. In the case of this circuit, the frequency to be removed with a notch filter is 60 Hz. 60 Hz is the frequency that powerlines operate at and therefore is a large source of noise with devices. Powerline noise distorts biomedical signals and reduce the quality of the data . The general form of the notch filter used for this circuit is shown in the first photo for this step. The active component of the notch filter is the buffer that is attached. The buffer is used to isolate the signal after the notch filter. Since the buffer is part of the filter and it needs power to operate, the notch filter is the active filter component of this circuit.
The equation for the resistive and capacitor components of the notch filter is shown in the second photo . In the equation, fN is the frequency to be removed, which is 60 Hz. As will the instrumentation amplifier, either the resistor or capacitor value can be set to any value and the other value calculated by the equation shown in the second photo. For this filter, C was assigned a value of 1 µF and the rest of the values were found based on that value. The value of the capacitor was decided based on convenience. The table in the second photo displays the values of 2R, R, 2C, and C that were used.
The third image for this step is the final notch filter circuit with accurate values. Using that circuit, AC Sweep analysis was run using 5V. 5V corresponds with the voltage after amplification. The rest of the analysis parameters are the same as what was stated in the instrumentation amplifier step. The frequency response plot is shown in the final photo. Using the values and equations in the second photo, the actual frequency for the notch filter is 61.2 Hz. The desired value for the notch filter was 60 Hz. Using the percent error equation, there is a 2% error between the simulated filter and the theoretical filter. This is an acceptable amount of error.
Step 3: Step 3: Low Pass Filter
The last type of part used in this circuit is the passive filter. As previously mentioned, a passive filter is a filter that does not require a power source in order to be operational. For an ECG, both a high pass and a low pass filter are needed to properly remove noise from the signal. The first type of passive filter to be added to the circuit is a low pass filter. As the name suggests, this first allows signal below the cutoff frequency to pass . For the low pass filter, the cut off frequency should be upper limit of the range of signal. As previously mentioned, the upper range of the ECG signal is 150 Hz . By setting an upper limit, noise from other signals is not used in signal acquisition.
The equation for the cut off frequency is f = 1 / (2 * pi * R * C). As with the previous circuit components, the values for R and C can be found by plugging in the frequency and setting one of the component values . For the low pass filter, the capacitor was set of 1 µF and the desired cut off frequency is 150 Hz. Using the cut off frequency equation, the value for the resistor component is calculated to be 1 kΩ. The first image for this step is a complete low pass filter schematic.
The same parameters defined for the notch filter are used for the AC Sweep Analysis of the low pass filter, shown in the second image. For this component, the desired cutoff frequency is 150Hz and using Equation 3, the simulated cut off frequency is 159 Hz. This has a percent error of 6%. The percent error for this component is higher than preferred but the components were chosen for ease of translation to a physical circuit. This is clearly a low pass filter, based on the frequency response plot in the second image, as only the signal below the cutoff frequency is able to pass at 5 V, and as the frequency approached the cut off frequency, the voltage decreases.
Step 4: Step 4: High Pass Filter
The second passive component for the ECG circuit is the high pass filter. A high pass filter is a filter that allows any frequency greater than the cutoff frequency to go through. For this component, the cutoff frequency will be 0.05 Hz. Once again 0.05 Hz is the lower end of the range of ECG signals . Even though the value is so small, there still needs to be a high pass filter in order to filter out any voltage offset in the signal. Therefore, the high pass filter is still necessary within the circuit design, even though the cutoff frequency is so small.
The equation for the cutoff frequency is the same as the low pass cut off filter, f = 1 / (2 * pi * R * C). The resistor value was set to 50 kΩ and the desired cut off frequency is 0.05 Hz . Using that information, the capacitor value was calculated to 63 µF. The first image for this step is the high pass filter with the appropriate values.
The AC Sweep Analysis is the second filter. Like the low pass filter, as the frequency of the signal approaches the cut off frequency, the output voltage decreases. For the high pass filter, the desired cut off frequency is 0.05 Hz and the simulated cutoff frequency is 0.0505 Hz. This value was calculated use the low pass cut off frequency equation. The percent error for this component is 1%. This is an acceptable percent error.
Step 5: Step 5: Full Circuit
The entire circuit is constructed by connecting the four components, the instrumentation amplifier, the notch filter, the low pass filter, and the high pass filter, in series. The full circuit diagram is shown in the first image for this step.
The simulated response shown in the second figure acts as it was expected to base on the types of components used for this circuit. The circuit that is designed is filters out noise at both the lower and upper limits of ECG signal as well as successfully filtering out noise from powerlines. The low pass filter successfully removes of the signal below the cut off frequency. As shown in the Frequency response plot, at 0.01 Hz, the signal is passed through at 1 V, a value that is 5 times less than the desired output. As the frequency increases the output voltage also increases until reaching its peaks at 0.1 Hz. The peak is around 5 V, which is aligned with a gain of 1000 for the instrumentation amplifier. The signal decreases from 5 V starting at 10 Hz. By the time the frequency is 60 Hz, there is no signal being outputted by the circuit. This was the purpose of the notch filter and its meant to counteract the interference of the power lines. After the frequency surpasses 60 Hz, the voltage once again begins to increase with frequency. Finally, once the frequency reaches 110 Hz the signal reaches as secondary peak of roughly 2 V. From there, the output decreases because of the low pass filter.
Step 6: Conclusion
The purpose of this assignment was to simulate an automated ECG capable of accurately recording the cardiac cycle. In order to do this, the analog signal that would have been taken from a patient needed to be amplified and then filtered to only include the ECG signal. This was accomplished by first using an instrumentation amplifier to increase the magnitude of the signal roughly 1000 times. Then the noise of powerlines needed to be removed from the signal as well as noise from above and below the designated frequency range of an ECG. This meant incorporating an active notch filter as well as passive high and low pass filters. Even though the final product for this assignment was a simulated circuit, there was still some acceptable error, taking into consideration the standard values for resistive and capacitive components normally available. Over all the system performed as expected and would able to be transitioned into a physical circuit rather easily.
Step 7: Resources
 X.-L. Yang, G.-Z. Liu, Y.-H. Tong, H. Yan, Z. Xu, Q. Chen, X. Liu, H.-H. Zhang, H.-B. Wang, and S.-H. Tan, “The history, hotspots, and trends of electrocardiogram,” Journal of geriatric cardiology : JGC, Jul-2015. [Online]. Available: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4554... [Accessed: 01-Dec-2020].
 L. G. Tereshchenko and M. E. Josephson, “Frequency content and characteristics of ventricular conduction,” Journal of electrocardiology, 2015. [Online]. Available: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4624... [Accessed: 01-Dec-2020].
 “Differential Amplifier - The Voltage Subtractor,” Basic Electronics Tutorials, 17-Mar-2020. [Online]. Available: https://www.electronics-tutorials.ws/opamp/opamp_... [Accessed: 01-Dec-2020].
 C.-H. Chen, S.-G. Pan, and P. Kinget, “ECG Measurement System,” Columbia University.
 S. Akwei-Sekyere, “Powerline noise elimination in biomedical signals via blind source separation and wavelet analysis,” PeerJ, 02-Jul-2015. [Online]. Available: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4493... [Accessed: 01-Dec-2020].
 “Band Stop Filters are called Reject Filters,” Basic Electronics Tutorials, 29-Jun-2020. [Online]. Available: https://www.electronics-tutorials.ws/filter/band-... [Accessed: 01-Dec-2020].
 “Low Pass Filter - Passive RC Filter Tutorial,” Basic Electronics Tutorials, 01-May-2020. [Online]. Available: https://www.electronics-tutorials.ws/filter/filte... [Accessed: 01-Dec-2020].
 “High Pass Filter - Passive RC Filter Tutorial,” Basic Electronics Tutorials, 05-Mar-2019. [Online]. Available: https://www.electronics-tutorials.ws/filter/filter_3.html. [Accessed: 01-Dec-2020].