Development of Electrocardiogram Signal Generator for Fibrillation Detector

. Fibrillation is one of the abnormalities in the heart where it beats irregularly, which can cause sudden death. Fortunately, these abnormalities can be detected using an electrocardiogram (ECG) fibrillation detector. An ECG can be detected as biopotential body signal that arises as a result of electrical activity of the heart muscle represented by the electrical signals consisting of P, Q, R, S and T waves that carry information about someone’s heart condition through graph pattern. However, a test in humans with the potential for fibrillation is needed to determine whether the fibrillation detector works correctly. Testing this way is ineffective because we cannot predict when and where a person will experience fibrillation. On the other hand, a site called PhysioNet provides various medical records from patients, including ECG signals of normal heartbeats, atrial fibrillations, and ventricular fibrillations. Because of the ineffectiveness of testing a fibrillation detector directly on a living person, this study focused on research to develop an ECG signal generator using microcontroller Arduino Due for reconstructing the heart signal in normal and fibrillated heart conditions collected from the PhysioNet database. The research focused on obtaining an R-peak value and RR interval time that resembled a heart ECG wave. This study compared the reconstructed signal with references from PhysioNet and measured the peak level of R and RR interval time using an oscilloscope to calculate the accuracy of the ECG signal generator. The generated ECG signal during Atrial Fibrillation and Normal Sinus Rhythm has an overall accuracy of 88.65% for the R-peak level and 97.24% for the RR-Interval time. While Ventricular Fibrillation has been reproduced by achieving amplitude errors of less than 5.63% and 10.22% during first and second samples, respectively.


Introduction
Cardiovascular diseases (CVDs) are one of the primary causes of death in the world [1].Based on statistics from World Health Organization (WHO), every year CVD causes 17.3 million deaths, and it is predicted to grow by 2030 [2].CVD can occur due to various factors and conditions, one of the causes is fibrillation.Fibrillation which is desynchronized heart contractions, often occurs during a heart attack and cardiac surgery [3].According to the location of the occurrence, fibrillation can be classified into two, that is Atrial Fibrillation (AF) and Ventricular Fibrillation (VF) [4].
generator by reconstructing signals from the PhysioNet database was proposed.PhysioBank currently includes more than 50 collections of cardiopulmonary, neural, and other biomedical signals from healthy subjects and patients with various conditions of major public health implications, including atrial fibrillation and ventricular fibrillation.This research is expected to ease the testing process of a fibrillation detector device which will help to produce accurate results and ultimately minimize the death rate caused by CVDs.

Method
The general proposed system can be seen in Fig. 1.This research focuses on developing an ECG signal Generator.The ECG signal generator consists of three main parts: input, processor, and output.A button is used as an input interface for the user to select the desired heart condition out of six options available to be generated.Each time the user pushes the button, the output ECG signal will change to the next condition depending on the current state, either Atrial Fibrillation, Ventricular Fibrillation or Normal Sinus Rhythm.If the user pushes the button and the current state cannot be increased anymore, the state will start from the beginning.The six conditions will change according to Fig. 1.By default, or if the button is not pushed, the program will generate the first heart condition from the list, Atrial Fibrillation (a).Each condition can be found on a PhysioNet feature called PhysioBank ATM to view a graph and detailed data of an ECG signal.An example of selecting a database from the PhysioBank ATM feature is shown in Fig. 2.
The six ECG digital signals collected from PhysioNet are stored directly in the microcontroller program as a list of array numbers, with each value ranging from 0 to 4095 (12-bit).Based on the block diagram of the system, then the ECG signal generator specifications was designed with hardware that met the desired requirements, which can be seen in Fig. 3, while the flowchart of the ECG signal generator algorithm is shown in Fig. 4. The three LED lights will help indicate to the user which signal is being generated.
The microcontroller Arduino Due then generates the selected signal using the builtin Digital to Analog Converter (DAC) of the microcontroller.At this stage, the analog output signal imitates the ECG wave.However, this signal is still strong enough and is not readable by the heart rate sensor from the fibrillation detector.Therefore, a signal conditioning circuit is placed after the DAC signal to scale down and adjust the output signal in the millivolt (mV) range so that it can be used by the next device, which in this case is AD8232.The signal conditioning circuit is made with a gain of 2/222, using two resistors with values of a 220 kΩ resistor for R1 and 2 kΩ for R2.The configuration can be seen in Fig. 5.
The signal output from the ECG signal generator will be connected to AD8232, a heart rate sensor that will act as a fibrillation detector in this system.AD8232 also acts as an amplifier so the ECG signal can be readable by a common commercialized microcontroller.In order to measure whether the system works correctly, both data from ECG signal generator and AD8232 will be displayed to an oscilloscope on Channel 1 and Channel 2, respectively.Both channels will help to monitor the output signals before and after detections.Moreover, the accuracy of the ECG signal generator will be measured through oscilloscope Channel 2 by compare it with the reference signal from PhysioNet.

Results
In this section, we will discuss how the ECG Signal Generator was evaluated by finding the accuracy of R-peak and RR-Interval from the generated signals.By reading the output data from AD8232 using the oscilloscope on Channel 2, the signal was saved into a picture that consisted of voltage level in the first ten seconds of the signal.It will later be compared to the same signal constructed from the PhysioNet website, specifically from the feature called PhysioBank ATM, to view the graph and detailed data of an ECG signal database.
The reference signal on every evaluation will appear on white background with grid values of 0.2 s/DIV on the horizontal axis and 0.5 mV/DIV on the vertical axis.In contrast, the output signal will appear on black background with grids of 800 ms/DIV on the horizontal axis and 1 V/DIV on the vertical axis.Both signals have a resolution of 12-bit.To find the accuracy of the R-peak level, during the first 10 seconds voltage level of each R-peak (Vout) was written into a table and the error was calculated by finding its difference with the R-peak reference (Vref) from the PhysioNet website.On the PhysioNet website, the voltage level is still raw and not amplified yet by a heart sensor, so the voltage level for each R-peak reference needs to be amplified by 1100 times to match the characteristic of AD8232 output.For that reason, the value of every Vref on the following tables is the value after amplification.The error then will be converted into a percentage scale to find the average of it.
For the accuracy analysis of RR-Interval (RRI) time, each interval time was written in a table when two nearest R-peaks (RRI out) arise in the exact first ten seconds signal as mentioned before.Error-values were measured by finding their difference with the RR-Interval reference (RRI ref) from the PhysioNet website.The errors were then converted into a percentage scale to find the average of it.
All steps described above will be repeated on every heart condition in Table 1, except for Ventricular Fibrillation (a) and (b) because the R-peak does not occur due to the characteristic of ventricular fibrillation.Therefore, the signal is measured by finding the error five times every two seconds on these two through oscilloscope Channel 2 and comparing it with the reference signal from PhysioNet.

Atrial Fibrillation Signal (a) Evaluation
The first ECG signal to be reconstructed is Atrial Fibrillation (a).In Fig. 6, the first graph shown is a reference signal taken from the PhysioNet website, under the PhysioBank ATM feature with input MIT-BIH Atrial Fibrillation Database (AFDB) and record number 08215 signal ECG2, while the second graph is the output signal taken from the oscilloscope Channel 2. On these two graphs, it appears that R-peak, when the signal noticeably spikes high on the positive y-axis, occurs 12 times on both signals.
Each voltage level of R-peaks can be seen on Table 2 and the interval time between the two nearest R-peaks (RRI) can be seen on Table 3. From Table 2, the Vref is the Rpeak value on the reference signal while Vout from the output signal.It can be concluded that the R-peak value from the generated ECG signal has an average error of 0.091V (13.23%), with the largest error of 0.15V (20%) during the R-peak number 1.
From Table 3, RRIref is the RR-Interval time on the reference signal, while RRIout is from the output signal.It can be concluded that the RR-Interval time from the generated signal has an average error of 0.018s (2.34%), with the largest error of 0.19s (2.39%) during the RRI number 6.In addition, fibrillation can be seen during RRI number 5, which has a longer interval time than the rest.

Atrial Fibrillation Signal (b) Evaluation
The second ECG signal to be reconstructed is Atrial Fibrillation Signal (b).In Fig. 7, the first graph shown is a reference signal taken from the PhysioNet website, under the feature called PhysioBank ATM with input MIT-BIH Atrial Fibrillation Database (AFDB) and record number 06995 signal ECG1, while the second graph is the output signal taken from the oscilloscope Channel 2. On these two graphs, it appears that Rpeak, when the signal noticeably spikes high on the positive y-axis, occurs 16 times on both signals.
Each voltage level of R-peaks can be seen on Table 4, and the interval time between the two nearest R-peaks (RRI) can be seen on Table 5.From Table 4, Vref is the Rpeak value on the reference signal while Vout from the output signal.It can be concluded that the R-peak value from the generated ECG signal has an average error of 0.059V (8.01%), with the most significant error of 0.159V (18.77%) during the R-peak number 13.From Table 5, RRIref is the RR-Interval time on the reference signal, while RRIout is from the output signal.It can be concluded that the RR-Interval time from the generated signal has an average error of 0.016s (2.36%), with the most significant error of 0.015s (2.4%).Even though no obvious fibrillation occurred in the table, data from RRI number 6 and 7 is an example of subtle fibrillation, in which the interval changes from 0.552s to 0.76s.

Ventricular Fibrillation Signal (a)
The third ECG signal to be reconstructed is Ventricular Fibrillation Signal (a).In Fig. 8, the first graph shown is a reference signal taken from the PhysioNet website, under the feature called PhysioBank ATM with input MIT-BIH Malignant Ventricular Arrhythmia Database (VFDB) and record number 418 signal ECG1, while the second graph is the output signal taken from the oscilloscope Channel 2. These two graphs show that R-peak does not occur due to the characteristic of ventricular fibrillation.Therefore, the signal is measured by finding the error five times every two seconds, which can be seen on Table 6.
From Table 6, Vref is the R-peak value on the reference signal while Vout from the output signal.It can be concluded that the amplitude from the generated ECG signal has an average error of 0.016V (5.63%), with the largest error of 0.036V (9.09%) on the first timestamp.

Ventricular Fibrillation Signal (b)
The fourth ECG signal to be reconstructed is Ventricular Fibrillation Signal (a).In Fig. 9, the first graph shown is a reference signal taken from the PhysioNet website, under the feature called PhysioBank ATM with input MIT-BIH Malignant Ventricular Arrhythmia Database (VFDB) and record number 419 signal ECG1, while the second graph is the output signal taken from the oscilloscope Channel 2. These two graphs show that R-peak does not occur due to the characteristic of ventricular fibrillation.Therefore, the signal is measured by finding the error five times every two seconds, which can be seen in Table 7.
From Table 7, Vref is the R-peak value on the reference signal while Vout from the output signal.It can be concluded that the amplitude from the generated ECG signal has an average error of 0.032V (10.22%), with the largest error of 0.132V (23.08%) on the first timestamp.Based on the research that has been done, the device has a high RRI accuracy, that is reaching 97.24%.This level of accuracy indicates that the designed ECG signal generator has been successful.This is according to the results of the signal time that is issued according to the reference signal time.In addition, the Arduino Due used in this research is able to produce accurate and stable timings.

Conclusion and Future work
The ECG signal generator has been successfully developed using Arduino Due with 12-bit DAC resolution and signal conditioning circuit with a gain value of 2/222.the output of the system is used to represent the condition of the heart when experiencing atrial fibrillation, ventricular fibrillation, or normal sinus rhythm.The ECG signal generated during Atrial Fibrillation and Normal Sinus Rhythm has an overall accuracy of 88.65% for the R-peak level and 97.24% for the RR-Interval time.Meanwhile, ventricular fibrillation is characterized by not having an R-peak.The designed system has been shown to reproduce ventricular fibrillation signals by achieving an amplitude error of less than 5.63% during ventricular fibrillation (a) and 10.22% during ventricular fibrillation (b).
There are several ways to improve the ECG signal generator designed for future work.For example, reducing and minimizing noise in the output signal caused by the system will improve the quality of the resulting ECG signal.This will greatly help improve the accuracy of the signal generated and facilitate the early detection process when fibrillation occurs in sufferers.In addition, the DAC module with high resolution must also be considered, so that the output signal resembles the original signal from the human heart.

Table 1 .
List Of Heart Conditions To Be Generated

Table 2 .
R-Peak Voltage Measurement on the Atrial Fibrillation Signal (a)

Table 3 .
RR-Interval (RRI) Time Measurement on the Atrial Fibrillation Signal (a)

Table 4 .
R-Peak Voltage Measurement on the Atrial Fibrillation Signal (b)

Table 5 .
RR-Interval (RRI) Time Measurement on the Atrial Fibrillation Signal (b)

Table 11 .
RR-Interval (RRI) Time Measurement on the Normal Sinus Rhythm Signal (b)

Table 12 .
Accuracy Evaluation of the Overall System