With the progress of society and the development of science and technology, people's health concepts, health methods and approaches have undergone profound changes. China is a high-incidence area for cardiovascular and cerebrovascular diseases. However, most hospitals have few ECG monitoring devices, which are not easy to move and are costly, and cannot meet the market demand. In order to meet the demand for ECG monitoring equipment and reduce medical costs, an ECG detection system combined with a PC is needed. The bus interface connecting the computer to the peripherals has many forms, among which the PCI and ISA buses are troublesome to plug and unplug, and the expansion slots are limited; the RS232 serial bus has a slow transmission speed and a small number of serial ports with the host. In recent years, the USB bus interface has emerged. It has significant advantages such as hot plugging, plug and play, convenient system expansion and configuration, and efficient data transmission. It overcomes the defects of the traditional bus interface. The ECG monitoring system designed in this article also adopts this method.
1 Hardware Circuit Design
1.1 Overall hardware structure
The overall hardware structure of the ECG detection system designed in this paper is shown in Figure 1, which includes lead circuit, filter amplifier circuit, microcontroller, Flash memory, power conversion circuit and USB interface circuit. The ECG signal is collected from the human body through electrodes, enters the A/D of the microcontroller after the lead circuit and filter amplifier circuit, and then is processed by the microcontroller and stored in the Flash, thus completing the acquisition of the ECG signal. The system can communicate with the PC through the USB interface circuit, and transfer the ECG data stored in the Flash to the PC in file format, thereby realizing the unlimited storage function of the data. At the same time, the ECG waveform can be displayed on the screen through VC software programming. The power conversion circuit is powered by a 9V battery, which is compact and easy to carry.
1.2 USB interface circuit
This article uses Philips' PDI-USBD12. PDI-USBD12 is a cost-effective USB device that fully complies with the USB1.1 specification. It is usually used as a high-speed universal parallel interface in microcontroller systems to communicate with microcontrollers and supports local DMA transfers. In addition, PDIUSBD12 integrates many features, including SoftConnetTM, GoodLinkTM, programmable clock output, low-frequency crystal oscillator, and termination register set. All of these features save a lot of cost for the system and make it easy to apply USB functions to peripherals.
Figure 2 is the USB interface circuit. The USB interface uses a 4-wire cable. The two wires D+ and D- are used to send signals, and the two wires VDD and GND provide power to the device. The XTAL1 and XTAL2 pins of PDIUSBD12 are connected to an external 6M crystal oscillator. The data line and control line are respectively connected to the I/O port of the microcontroller. The commands and data are sent through SPCE061 to control the USB interface chip PDIUSBD12, realizing fast and efficient data transmission.
1.3 Single-Chip Microcomputer System
This article uses the 16-bit SPCE061 microcontroller launched by Lingyang Company, which has a wide power supply voltage range (2.4~3.6V), a maximum CPU speed of 49.125MHz, 8-channel 10-bit ADC (the maximum A/D conversion speed is 96kbps), 2k RAM, 32k Flash, 32 I/O interfaces, etc. The Flash uses Lingyang Company's 512k*8-bit SPR4096, with an operating voltage of 2.25~2.75V, which has good mutual transmission capability with SPCE061.
1.4 Amplification and filtering circuit
The amplifier and filter circuit is shown in Figure 3. The preamplifier uses the AD620 from ANALOG DEVICES, which is a very cost-effective instrument amplifier with a maximum input offset voltage of 50uV, an input offset drift of 0.6uV per degree, a common film rejection ratio of 120dB (G=10), and a maximum supply current of only 1.3mA. The amplifier uses the low-power and low-noise TLC2254, with a supply current of 35uA per channel and a noise of 19nV/Hz (1kHz), which is very suitable for portable devices. Since most ECG signals are between 0.5 and 150Hz, filtering is required. A 0.48-159Hz bandpass filter is added to the TLC2254. For the power frequency 50Hz interference, in order to reduce hardware design and consider the problem of reducing power consumption, software filtering will be used. After Chebyshev secondary filtering and smoothing filtering, the effect is relatively ideal. Since the ECG signal has negative values, and the A/D range of the Lingyang microcontroller is 0-3.3V, the signal must be boosted. Here, the LM385 -1.2V precision reference voltage source is used and added to the signal, so that the values of all signal points are positive.
2 System Software Design
The software design of the ECG detection system includes data acquisition and storage program design and USB data transmission program design.
2.1 Collection and storage program design
The acquisition and storage program design is shown in Figure 4. First, initialize the microcontroller and Flash chip, set the system clock, sampling frequency, pin definition, etc. Then filter each sampling data. Since a bandpass filter has been designed in the previous hardware design, the main consideration here is to remove the 50Hz power frequency and burrs. The use of Chebyshev I type 2 filtering can effectively remove the 50Hz power frequency and smooth the filtering, and can remove burrs. The formula is as follows:
Considering that the coefficients generated by the Chebyshev filter are decimals, they are converted into integers for the convenience of calculation. Each coefficient is multiplied by 4096, and the integer part is taken. The calculated result is then right-shifted 12 bits to obtain the final result.
Figure 5 is a comparison chart of ECG signals before and after processing, and it can be seen that the effect is quite obvious.
2.2 USB data transmission program design
The purpose of USB data transmission program design is to make PDIUS-BD12 reach the maximum transmission speed on USB. PDIUSBD12 program design adopts interrupt drive. When CPU processes foreground tasks, USB transmission can be carried out in the background, which ensures the best transmission rate and better software structure. The data exchange between the background interrupt service program and the foreground main program loop is realized through event flags and data buffers. The host must first send a token packet to PDIUSBD12. After receiving the token packet, PDIUSBD12 sends an interrupt to the microcontroller. The microcontroller enters the interrupt service program, first reads the interrupt register of PDIUSBD12, determines the type of USB token packet, and then performs the corresponding operation.
In the communication between SPCE061 microcontroller and PDIUSBD12, PDI-USBD12 is responsible for handling all tasks related to USB bus transactions, such as bus wake-up, data reception/transmission, packaging, CRC check, etc., but is not responsible for interpreting the meaning of these data; SPCE061 is responsible for processing data, responding to host requests, and controlling the work of PDIUSBD12. This is mainly achieved by the microcontroller sending commands and data to PDIUSBD12. The central processing unit (CPU) of SPCE061 controls the activities of PDIUSBD12 by executing the instruction set stored in the chip firmware. The CPU supports an instruction set including machine language instructions for moving data, performing mathematical and logical operations, program branching, etc. The command words of PDIUSBD12 are divided into three types: initialization command words, data flow command words, and general command words. PDIUSBD12 gives the codes and addresses of various commands. The microcontroller first sends commands to the command address of PDIUSBD12, and then sends or reads different data according to the requirements of different commands. Therefore, each command can be made into a function, and each command can be implemented by a function, and the function can be directly called later.
Figure 6 is a hierarchical block diagram of the program design, in which D12CI.C, CHAP9.C and ISR.C can be used to transplant the firmware interface, and EPPHAL.C and MAINLOOP.C need to be designed by yourself. In MAINLOOP.C, it is necessary to design sending USB requests, reading test keys, controlling LEDs and handling USB bus events. In EPPHAL.C, it is necessary to design the control and data transmission of each I/O port to the 12 pins of PDIUSBD.
3 Conclusion
The software and hardware design and development of the ECG detection system based on the USB bus fully reflects the convenience, low cost, and high anti-interference characteristics of USB. After testing, it works stably and reliably, and the ECG waveform is clear. It is an ideal ECG detection system. Due to the complexity of ECG interference and the limitations of software and hardware design, the noise reduction problem of ECG signals needs to be further improved.
Previous article:Application of microcontroller in single chip microcomputer speech experiment
Next article:Using STM8's TIM1 to implement a running light experiment (using an external clock)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [New Year's Flavor Competition] + New Year's Eve dinner, visit lanterns, live a wonderful life!
- New metering technology makes every drop of water count
- Introduction to TWS Bluetooth headsets and TI low-power solutions
- BlueNRG-1 controls 8 WS2812B chips to realize EEWORLD display with a shake stick
- Brushed servo based on STM8S003F3P6
- Understanding the difference between FIR filter and IIR filter in one article
- Buck charger bq25700
- General Concept of Frequency Response
- (FPGA Experiment 5): Verilog HDL language digital tube clock (hours, minutes, seconds)
- How to choose the right AFE for BMS