*1. Introduction to project functions
A. Project introduction
OpenECG is an open source portable multi-parameter monitor project. The portable monitor is about 122*71*20mm in size. Although it is small in size, it has many functions. The monitor integrates an ADAS1000 to realize 7-lead ECG monitoring + RESP (electrocardiogram + respiration) monitoring. It also has an expansion interface and supports cascading. Through the expansion interface, full-lead (12-lead) monitoring, SPO2, NIPB, and even CO2, EEG can be realized.
B. Theme introduction
The device is very widely applicable: postoperative rehabilitation or elderly people with heart disease who need dynamic monitoring. Portable devices can make their daily activities easier, and powerful functions can also give more comprehensive feedback. In medical treatment, flexible expansion functions can meet different monitoring needs, plug and play, making transfer monitoring more convenient. Light weight, small size, fast startup and other characteristics also provide more precious time for rescue personnel. "Portable" is always mentioned, so how small is it? It is about the thickness of a mobile phone and can be put in your pocket.

C. What is the difference?
The heart is a three-dimensional structure. In order to reflect the electrical activity of different surfaces of the heart, electrodes are placed in different parts of the human body to record and reflect the electrical activity of the heart. Certain operations are performed between different electrodes to form leads. In order to fully reflect the activity of the heart, the more leads the better in theory. At present, the 5-electrode electrocardiogram can meet most monitoring needs, and medical diagnosis will use full leads (i.e. 12 leads). However, the common home portable ECG monitors on the market can only measure one lead. This design, as a "multi-parameter monitor", is different from ordinary home ECG measuring instruments. Ordinary ECG machines can only measure ECG, while "monitoring" highlights the changes in multiple parameters (such as respiration, blood oxygen, blood pressure, etc.). After a simple investigation, there are no fully functional monitors for families on the market. Here are a few examples of common home ECG instruments:
Common home monitors on the market are roughly divided into two types: autonomous monitoring and passive monitoring;
the PC-80B model is a representative of autonomous monitoring (see the figure below). This type of monitor only supports single-lead monitoring and cannot reflect patient problems in real time, which is not friendly for long-term monitoring.

Another common type on the market - passive monitoring is more complicated. Take a product under Lepu as an example (see the figure below). Its outstanding features are small and easy to use, but its disadvantages are also very obvious: it cannot monitor autonomously, relies on the host computer, has no multiple parameters, is not suitable for monitoring, and is relatively expensive.
Compared with the above products, this design has solved the problem of balancing portability and performance, and has controlled the cost within 600, so that more families can get better monitoring quality.
D. Previous competitions
In previous competitions of LiChuang, there have been similar designs, such as the "USB Portable ECG Electrocardiogram Monitoring Automatic Analyzer" designed by senior buck-boost, the champion of the fifth LiChuang Electric Competition. This work uses optimized analog devices instead of AD8232 to achieve relatively good signal quality, but it relies on the use of the host computer. If you want to achieve mobile monitoring, you have to carry a computer with you. It belongs to the "passive monitoring type" mentioned above, and if it is used in the field of monitoring, the parameters that can be monitored are not enough, and its practicality still needs to be improved.
Similarly, in the sixth LiChuang Electric Competition, senior HolgerWang designed the "Portable Wireless ECG Device", which also belongs to the passive monitoring type. Its disadvantage is that the wireless solution is Bluetooth transmission, which has distance limitations and delay bottlenecks. It is not suitable for some scenes that require activities. This design
solves the above problems, can actively monitor, support expansion, and is portable enough.
E. Functional characteristics Stand-alone
7-lead-ECG+RESP (electrocardiogram + respiration) monitoring
Plug-and-play expansion interface, differential signal transmission
With defibrillation protection
With lead-off detection function
With interference shielding layer driver
With recording function
Real-time parameter abnormality feedback
*2. Project attributes
This project is original and independently developed by me, and I have not participated in other activities. It is the first time to be made public.
* 3. Open source agreement
GPL3.0
*4. Hardware part
0. Hardware block diagram

A. Monitoring analog front end
A.1 - Analog chip
In this design, we want to pursue both performance and portability, so we abandoned the traditional amplifier solution and used integrated devices to realize the function. The ADAS1000 series is a solution designed by ADI for the medical monitoring field. A single chip can realize 5-electrode-ECG+RESP monitoring, and the device supports cascading, which can realize full-lead (12 leads) or even 18-lead medical-grade monitoring, providing more space for subsequent updates of this design.


A.2 - Filtering Components
Considering the muscle electrical signal interference and power frequency interference caused by the user's movement during daily monitoring, this design adds an optional two-order RC filter at the front end, and adds FIR digital filtering at the program layer to ensure that the signal is not distorted while minimizing artifacts.
A.3 - Defibrillation Protection
In rescue work, electric defibrillation is a commonly used rescue method for atrial fibrillation, ventricular fibrillation, or cardiac arrest. The principle is to use pulse current to cardiovert the myocardium. However, this current will cause an instantaneous high voltage on the connected device, thereby damaging the device. If the TVS is directly connected for protection, the defibrillation effect will be poor. Therefore, this design adds a defibrillation protection resistor at the front end and uses a GDT (air discharge tube) + TVS solution to protect the circuit. While ensuring the safety of the circuit, it will not affect the defibrillation effect.
A.4 - Shielding Drive
Usually, the cable of the monitor is very long, so the antenna induction interference is more serious. In order to better solve the interference problem, this design leads out the common mode signal and amplifies it to the shielding layer to shield the interference signal.
A.5 - Electrode detachment detection
During long-term monitoring, the electrodes may become loose. The ADAS1000 used in this design has two lead detachment detection modes. The principle of DC lead detachment is to inject a small programmable DC current into each input electrode. When the electrode is properly connected, the current flows into the right leg (RLD_OUT), generating a very small voltage offset. If the electrode falls off, the current will charge the capacitor of the pin, causing the voltage at the pin to be positively biased, resulting in a large voltage change, which is detected by the comparator in each channel.
B. Main control part
Initially, due to the huge amount of calculations brought by multi-lead real-time filtering, the project planned to use DSP as the processor. In the subsequent selection, I found that most DSPs have large packages or very little information. It would be too time-consuming to learn new chips. So I later selected ST's STM32H723VGT6, which has a main frequency of 550MHz, a dual floating-point computing unit, just enough GPIO, and a HAL library that can be quickly started, which is suitable for the development of this project. (In the current program, the CPU usage is less than 10%, so there is no performance problem)

C. Display part
The monitor is different from general household products. It does not require complex graphics rendering or fine color details. Therefore, this design uses a 5-inch TFT color screen, which uses RM68120 as the main control, built-in video memory, and the main control uses analog IO to drive this screen, which simplifies the code and does not occupy too much memory resources.

Users can operate the device through a rotary encoder and two function switches. This design takes into account the impact of harsh environments (such as rainy days) and the performance occupation of the processor, and does not design a touch screen function. In actual applications, the combination of rotary encoders and switches is sufficient to meet the operation requirements. In addition, the device is equipped with an AT24C128, which can be used to store historical parameters in order to reflect the historical trend of parameters and better understand the patient's condition.
D. The battery charging IC selected for the power management part
is TI's BQ24072, which is a linear charging chip with a maximum current of 1.5A. The reason for choosing a linear charging chip is mainly because it radiates less electromagnetic interference when working and will not affect the work of the analog end.

The analog and digital ends do not share a common power supply. The analog end uses ADP151 to directly draw power from the battery to supply ADAS1000 and other analog devices, ensuring that high-frequency digital signals will not affect the analog end.


The battery uses a 3200mAh lithium-ion polymer battery.
E. Expansion interface
The expansion interface is allocated with IIC interface and UART (RS422) interface in hardware, with a theoretical rate of 10*2Mbit/s, which can meet the transmission requirements of a large number of expansion devices. (Limited by personal time, the expansion function is still in the development stage, and the software function has not been designed)
*5. Software part
0. The following instructions apply to the first generation software version. Subsequent firmware updates may modify the software algorithm structure.
A. Program structure overview
The program of this design is divided into three layers:
HAL layer (including HAL library and LL library)
BSP layer (used to abstract the operation of hardware devices, relying on the HAL layer)
APP layer (used to implement functions, relying on the BSP layer)
Among them, the APP layer also includes RTOS and GUI (RTOS uses FreeRTOS, GUI uses LiteGUI)
B. Operation process overview
Since ADAS1000 will no longer continue to trigger the DRDY port once it receives an incomplete frame of data, this project uses a timer to poll the DRDY interface to confirm whether the ADAS1000 is ready for data, instead of using an external interrupt. Once the data is ready, the device will receive a frame of data, perform preliminary processing and store it in RAM. The data capture rate is 2KHZ. Data processing and data capture are performed asynchronously, using an independent timer to drive the data processing part, with a refresh rate of 1KHZ. The display of data is also asynchronous with the previous two. It still uses an independent timer to achieve data timing refresh with a refresh rate of 50HZ. In the development of expansion, data processing should be performed on the slave, and only 50Hz finished signal is transmitted during transmission to avoid the performance and communication occupation of the host.
C. Filtering algorithm
ECG signal interference includes but is not limited to muscle electrical signal interference, power frequency interference, and device noise. In order to filter out power frequency interference, this design uses FIR low-pass filter to filter out signals above 30HZ, which can filter out most interference signals. Muscle electrical signals have the greatest interference on the baseline. The high-pass filter has the problem of long settling time at high sampling rate. This design uses a low-sampling rate FIR low-pass filter, sets the frequency at 0.1HZ, obtains the approximate baseline of the ECG, and then calculates the difference with the source ECG signal to obtain the corrected ECG. This method is simple and stable, and the response speed is faster than IIR high-pass filtering. The workflow of ECG processing is as follows:

D. ECG algorithm
ECG algorithm can be divided into HR (Heart Rate) calculation and heart abnormality signal calculation. The HR calculation method is to select a lead, use a timer to sample regularly, and compare it with the previous value. When it exceeds a certain threshold (the voltage can be converted into the threshold through a certain formula), it is recorded as a myocardial activity. HR is calculated by the interval (RR interval) of each myocardial activity. For the heart abnormality algorithm, since it is necessary to identify ST interval, T wave height, QRS wave, etc., it involves complex problems such as machine self-learning and template matching recognition, and is still in the development stage.
E. Respiration algorithm
The respiratory rate (RR) algorithm is similar to the heart rate (HR) algorithm and will not be introduced in detail here. (This algorithm is not a universal algorithm. The threshold method is currently widely used, that is, by judging the respiratory impedance and a certain threshold, to judge the exhalation and inhalation, and then calculate the rate)
*6. For the BOM list,
please see the "OpenECG_BOM.xlsx" file in the attachment area
*7. Competition LOGO verification


* 8. Demonstrate your project and record it into a video and upload it.
Please see the video area
Extra, board making and secondary development instructions.
This project takes the issue of post-plate making into consideration when designing the hardware. Therefore, all hardware components that support Jiali Chuang SMT are used, and they are placed on the same copper foil layer as much as possible. When making boards, you can use the Gerber files, BOM tables, and coordinate files provided in the attachment area for Jiali Chuang SMT proofing, but please still pay attention to checking the matching of components, especially for some expansion library components. For the problem of confusion in the model of some components during SMT proofing, please pay attention to checking and replacing.
Regarding secondary development, the funds, personnel and time for the production of this project are very tight. After the project development, the basic process from hardware design to software development was completed in just one month. At present, the hardware of this design is basically mature, but there are still gaps in the software. Some of the functions mentioned in the project have not yet been implemented in the software (such as expansion, more powerful heart rate abnormality recognition, etc.). As an open source project, its strength lies in its ability to be continuously optimized under the innovation of various open source enthusiasts. Due to academic problems, I may no longer continue to develop OpenECG in the future, but I still hope that this project can continue to develop.
Some ports can be reused as other functions to achieve more advanced functions, such as the BEEP interface, which can be reused as a timer or DAC. In subsequent development, DAC can be used to achieve more warning sound effects.
More details: https://diy.szlcsc.com/posts/d76d9cb41705430e9a54e7a5feed07a5