# XBeats: A Real-Time Electrocardiogram Monitoring and Analysis System
## 4 Prototype Implementation
### Data Acquisition and Logging  
The prototype of the proposed ECG patch is powered by the SimpleLink 32-bit Arm MCU (CC2652R), which runs as the central processor. The CC2652R chip is capable of handling real-time operations needed for critical safety systems. The MCU features an ultra-low power sensor controller powered by an Arm Cortex-M0 processor that offloads simple tasks like sensors readings of the main MCU. These features make the selected MCU well-suited for high data acquisition applications. Moreover, the ECG patch utilizes a specialized medical AFE to take electrical signals from the heart and digitize them. The ADS1298 chip is integrated into the patch to digitize the acquired ECG signals, and it comes with a 24-bit status word that reflects the status of the electrodes (i.e., probably attached, whether connected or not). Moreover, it offers two sampling modes, namely, high-resolution mode and low power mode. Furthermore, we use the Wilson Center Terminal (WCT) to determine the central terminal needed to perform a standard 12-lead ECG test [2, 3]. The ADS1298 chip internally generates the WCT voltage through three integrated low-noise amplifiers that route the signals from the Right Arm (RA), Left Arm (LA), and Left Leg (LL) leads to calculate the WCT voltage. The equivalent voltage for the WCT is calculated using the following equation: (RA + LA + LL)/3. Similarly, the Right Leg (RL) electrode is driven internally by the RL Driver (RLD) on the ADS1298 chip. In XBeats, the RLD is derived as the average of RA, LA, and LL, which has the same level as the WCT voltage. To that extent, the RLD common-mode voltage is set to (AVDD + AVSS)/2, where AVDD is the analog voltage supply, and the AVSS is the analog ground supply. Therefore, the WCT is buffered internally and routed to the RLD. On the other hand, the RLD improves the common-mode rejection (CMR) and reverses the common-mode interference in the ECG circuit due to the power lines interface and other sources. Lastly, we use a digital notch filter of 50 Hz or 60 Hz to compensate for the common-mode rejection. We use the proprietary Texas Instruments Real-Time Operating System (TI-RTOS) in our proposed platform to operate the ECG patch. TI-RTOS provides tools for managing and scheduling tasks using application layer functions. The combination of TI-RTOS and ultra-low-power MCU supports longer battery life and makes applications more adaptable for real-time monitoring systems and wearable devices. The ECG hardware firmware encapsulates the operations conducted by the MCU into tasks using the scheduling APIs  
Figure 4: Hardware Prototype. of the onboard RTOS. Data acquisition, logging, and transmission are encapsulated in separate tasks. Each task is ranked based on a pre-configured priority. The data acquisition task is set to receive the highest priority in the firmware operating on the hardware. While the data logging task has the second-highest priority after the data acquisition task, then the data transmission task. The data acquisition task in the XBeats platform runs at a sampling rate ranging between 250 to 500 SPS. In the case of the 250 SPS, the acquisition task captures one sample every four milliseconds (250 samples/1000 ms = 4 ms). The data acquisition task itself requires 1 ms to capture each sample. Therefore, the remaining time available for other tasks (e.g., compression, logging, and transmission) to operate after each sample acquisition equals 3 ms (4 ms \(-\) 1 ms). This period is down to 1 ms at 500 SPS. However, in the proposed platform we process samples in batches every 1 s, in which we execute logging and transmission tasks. This means we have a total of 750 ms available for these two tasks when the sampling rate is 250. In comparison, at the 500 rates, a total of 500 ms is available for running these tasks. This setup is a stringent time constraint in our system, and the data logging and transmission tasks will have to be completed during this time interval.