Design of USB interface for ECG and blood pressure monitor based on single chip microcomputer

Publisher:跳跃龙珠Latest update time:2010-12-04 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction

The home ECG and blood pressure monitoring system consists of a collection and recording device and a host electronic medical record management system. Therefore, the problem of data transmission needs to be solved. The traditional communication interface uses a simple RS-232 serial UART, which is slow and has poor applicability, and the transmission performance of the USB to serial port chip cannot be fundamentally improved. The USB bus interface has the advantages of fast speed, easy expansion, hot plug support, and flexible and convenient use. It is especially suitable for communication between home devices and computers.

This article focuses on the USB communication protocol and the control method of its interface chip. According to clinical needs, a miniaturized device with ECG and blood pressure intelligent monitoring and USB high-speed data transmission functions is designed and implemented, providing functions such as ECG and blood pressure data electronic medical record query, printing and network transmission, which is of great significance to improving the level of family health care.

USB interface circuit design of the monitor

The system main control chip adopts 32-bit high-performance embedded ARM microprocessor S3C44B0X, and the USB dedicated control chip is USBN9603. USBN9603 has 7 built-in FIFO ports, including 1 bidirectional control port, 3 sending ports and 3 receiving ports, each with 64 bytes.

The interface circuit between USB controller and S3C44B0X is shown in Figure 1. The USB controller is designed as Bank2, that is, the nGCS2 bank selection line is used as the chip select line of USBN9603, and the chip select address of the chip is 0x4000000. This article adopts a parallel data interface, and the lower 8-bit data lines D0~D7 of the two chips are connected to transmit communication data in parallel. Both MODE0 and MODE1 pins are grounded, and USBN9603 is configured as non-multiplexed mode. Since this working mode requires address line A0 as the selection line for accessing the USBN9603 on-chip registers DATA_IN, DATA_OUT and ADDR registers, A18 in the 32-bit address bus needs to be connected to A0 of the USB controller. When reading and writing USBN9603, it is divided into two bus cycles: first, set the address line A0 high, that is, set the bus address to 0x4040000, and write the address of the register to be accessed from the data line D[0:7], so that the address is sent to the chip in the first bus cycle; then, in the second cycle, set A0 low, that is, set the bus address to 0x4000000, and read and write D[0:7] to achieve the read and write operation of the register. The entire USB communication process mainly handles various interrupt events including receiving and sending data. Connect the INT pin of USBN9603 to the external interrupt EINT0 pin of S3C44B0X, and set the USB interrupt to the vector interrupt request mode. Since the DMA mode is not used, DAC K needs to be set high, and the DMA request line DRQ is left floating. The USB cable has 4 wires, D+ and D- are USB differential signal lines, and the other two are 5V power line and ground line. USBN9603 supports low-speed and full-speed USB communication. Connect a 1.5KΩ pull-up resistor to the D+ signal line to make it work in full-speed mode.

System expansion memory and USB interface schematic diagram

Figure 1 System expansion memory and USB interface schematic diagram The USB interface firmware of the monitor implements the operation of the USB communication process from the host. According to the agreed timing, a token packet is first issued, which contains information such as operation type, direction, peripheral address and endpoint number, and then the data sender is specified in the token to send a data packet or indicate that there is no data transmission. The USB peripheral responds with a confirmation packet to indicate that the transmission is successful. This article adopts a master-slave USB communication structure. The host computer sends various pre-agreed protocol commands to realize the collection of ECG and blood pressure data and the initialization of system equipment. The main data include the following: ECG data is in segments, each segment includes 32KB ECG data and 6B acquisition time information, and several segments are transmitted each time. The data volume is large and the transmission reliability requirements are also high; blood pressure data includes diastolic pressure and systolic pressure and their acquisition time, a total of 10B. Since blood pressure monitoring is relatively frequent, blood pressure monitoring data for a period of time will be transmitted each time, and the data volume is also relatively large; download the upgraded version of the firmware and other file information. The data flow of these three types of data is relatively large, and the reliability requirements are relatively high. All three types of data use the block transmission channel type. In addition, each USB transmission must have a control transmission channel. Therefore, three channels are required, namely the control channel, BulkIN channel and BulkOUT channel.





USB firmware data structure

This article deals with the four types of descriptors that the host computer requires the device to transmit in the control transmission during the USB device configuration enumeration phase. They are hierarchically: device descriptor, configuration descriptor, interface descriptor, and endpoint descriptor. Among them, higher-level descriptors will notify the host of any other low-level descriptor information.

The device descriptor is the first descriptor read by the host when the device is connected. Each device can only have one device descriptor, which contains information about the entire device and the configuration number supported by the device, with a total of 18 fields. Each USB device has one or more configuration descriptors, including the device's power management and the interface number supported by the device configuration. When the device receives a request to obtain a configuration descriptor, it transmits the configuration descriptor and all its interfaces, endpoints, and other subsidiary descriptors to the host. This article sets a configuration with a total of 8 fields in its descriptor. The interface contains a set of endpoints. This article sets an interface with a descriptor with 9 fields, which provides the host computer with information such as the number and type of endpoints used by the device. Each interface descriptor has zero or more endpoint descriptors, which contain the information required for the host to communicate with the endpoint. Endpoint 0 is used as a control endpoint for communication, and endpoint 1 and endpoint 2 are block transfer modes. Their descriptors contain information such as endpoint number, transfer direction, endpoint transfer type, and maximum transfer bytes of data packets.

The USB firmware communication process

is shown in Figure 2. After entering the communication module, the firmware first calls the initialization routine to configure the USB interface device and put it into operation, and then enables the interrupt. The main function of USB communication is implemented in the interrupt service. The main program just waits in a loop for an exit button. When an interrupt signal is detected, it enters the interrupt service subroutine, determines the interrupt type based on the value of register MAEV, and enters the corresponding processing process.

USB Firmware Framework

Figure 2 USB firmware framework

[page]

The USB communication of the device mainly realizes the Bulk transmission function of ECG and blood pressure data. Based on the communication protocol of USB bus receiving and sending data, the monitor also has a specific application layer communication protocol. After receiving the user communication command, the firmware parses the control command and executes the corresponding routine. For example, when transmitting ECG and blood pressure data, the command 0x10, after receiving the command code 0x10, the firmware obtains the length of the data to be transmitted, the transmission flag of ECG or blood pressure selection and its record number from the command parameters, calls GetRecordData() according to the record number, searches for data from the Flash storage area and stores it in the sending buffer of BulkState. If ECG data is transmitted, the acquisition time of this segment of ECG data must be obtained through Get TI me(). After all the data to be transmitted are ready, the transmission begins. Since the maximum buffer of Bulk transmission is 64B, 64B data is sent first, and then the host computer is judged in the TX_EV routine whether it is received successfully. If successful, the next batch of block input transactions is transmitted, otherwise it needs to be resent, and the above process is repeated until the data is sent.

Routines of each module of USB firmware

Initialize

the initialization routine of the USB interface, including the initialization operation of the USBN9603 chip and the initialization of user variables, and then start the device enumeration operation. During the initialization stage, the firmware needs to operate the registers of the USBN9603 in strict order.

USB device enumeration process

Connect the system's USB cable to a USB connection port (hub or host root hub), and the device is in the power-on state; there are two 15KΩ pull-up resistors between the USB D+ and D- data lines and the connected hub port or the host's root hub. At this time, the pull-up resistor will cause the level on the data signal line to rise, notifying the hub that a new device has been connected; then, the hub uses the interrupt channel to report the event to the host. When a new device is indeed connected, the host sends a Set_Port_Feature request to the hub connected to the device, causing the hub to send a USB hardware reset command to the port and last for 10ms, and then identify the speed of the device. At this point, the device has completed the initialization operation. When the host proves that the device has left the reset state, it starts USB control transmission on the default channel of endpoint 0 and enters the enumeration phase.

Standard routine for block transfer

The firmware's send routine implements the block transfer function to the host through endpoint 1, and its process is shown in Figure 3. Taking uploading ECG data as an example, after the firmware receives the host's request to upload ECG data through endpoint 0, it stores the data to be transmitted in the writePtr buffer, and at the same time, stores the data to be transmitted, size and other information in bulkState.

Block transfer send module routine

Figure 3 Block transfer sending module routine


The firmware's receiving routine receives data from the host through endpoint 2. The host first sends an OUT signaling to endpoint 2. The SIE automatically receives data from the transceiver and stores it in FIFO2. FIFO2 automatically updates the status of the receive control register RXC. After the hardware operation of data reception is completed, USBN9603 will transmit a receive interrupt to the S3C44B0X processor, and the firmware executes the receive interrupt service routine.

Host-side implementation of USB communication protocol

WDM drivers include device function drivers and bus drivers. Among them, the bus driver is provided by Windows. The host-side software in this article includes the following three levels: applications in user mode, Win32API dynamic link library that implements USB communication, and WDM device function drivers in core mode. The dynamic link library encapsulates the functions of accessing the core mode driver and provides an access interface for user applications. User applications only need to call to realize the transmission of specific data. The core of host-side software design is how to develop WDM device function drivers.

Install Windows 2000 DDK on Windows 2000 platform, use Visual C++ 6.0 as development tool, and develop WDM driver with DriverWorks toolkit, kernel code debugging tool module Sof TI

CE, and USB bus monitoring tool Bus Hound. According to the prompts of DriverWizard wizard, select USB as device type; select IRP queuing mode for I/O request packet IRP; create device interface as 128-bit globally unique identifier (GUID) so that WDM can identify and access device driver through GUID when using CreateFile() function to open the device; configure control, BulkIN and BulkOUT endpoints to transmit commands and data respectively. Configure three IOCTL control commands: MYUSB_IOCTL_ COMMAND is the control command for the host to send communication commands, and its IoctlCode is 0x812; MYUSB_IOCTL_ BULK_READ and MYUSB_IOCTL_BULK_ WRITE send read and write commands for Bulk data transmission, and their IoctlCodes are 0x814 and 0x815 respectively. After all settings are completed, generate the .inf installation information file. Under these frameworks, according to application requirements, you can write the host device driver that communicates with the device firmware.

When the host requires to read, write and transmit ECG or blood pressure data in Bulk mode, it will give an IOCTL IRP with IOCTL_CODE MYUSB_IOCTL_ BULK_READ, and the processing routine is BulkReadWrite(). The bulk data reading and writing functions are implemented by passing different parameters. First, you need to obtain the channel number, input/output buffer and its size and other parameters passed by the IRP from the application, call FindPipe() to get the channel instance required by the IRP, construct a URB on the channel, call SubmitUrb() to send the URB, realize communication with the underlying USB class driver, and complete the bulk data transmission function.

Conclusion

This paper makes full use of the characteristics of USB such as fast transmission speed, good accuracy and easy use, applies the USB interface to home ECG and blood pressure monitors, completes the software and hardware design of the interface between the ARM core MCU and the USB control chip, and through the ECG transmission experiment, it shows that the system has high reliability and accuracy.

Reference address:Design of USB interface for ECG and blood pressure monitor based on single chip microcomputer

Previous article:Wireless sensors are widely used. Detailed explanation of ultra-low power RF technology
Next article:Design technology and solutions for blood pressure monitors

Recommended ReadingLatest update time:2024-11-16 19:52

Portable signal collector based on USB interface
In high-speed signal acquisition equipment, high-speed acquisition and real-time data storage are an inherent contradiction. This problem is particularly prominent in some occasions that emphasize convenience. This problem is related to three aspects: device interface, data storage medium, and control method. At pre
[Power Management]
Portable signal collector based on USB interface
Design of Embedded USB Host in ARM and LINUX Systems
1 Introduction Universal Serial Bus (USB) is a new type of high-speed serial bus. As a fast and flexible bus interface, it has been widely used in electronic products. At the same time, people have higher and higher expectations for USB, hoping that USB can be applied in various computer fields. However, since
[Microcontroller]
Design of Embedded USB Host in ARM and LINUX Systems
iPhone 15 Pro latest appearance rendering: USB-C port, protruding back, hard to describe
Now, foreign media 9to5 Mac has given a set of appearance pictures of the iPhone 15 Pro. Although they are renderings, they are compiled based on reliable information about the current rumors of the new phone. With the launch of the iPhone 15 lineup, all iPhone 15 models will switch to USB-C to replace the Lightning
[Mobile phone portable]
Schematic diagram and circuit diagram of USB sound card based on PCM2702
Schematic diagram and circuit diagram of USB sound card based on PCM2702 Make a sound card is no more a complex issue. If you use great IC PCM2702 from BURR BROWN / Texas Instruments you can create a fully functional USB sound card. This sound card can be powered from USB port and has one stereo output. You don’t
[Analog Electronics]
Schematic diagram and circuit diagram of USB sound card based on PCM2702
Data acquisition and control system design based on USB interface
1 System Structure The block diagram of the data acquisition and control system composed of ADuC845 single-chip data acquisition device and CH341 USB interface device is shown in Figure 1. ADuC845 completes analog data acquisition, switch input and output, control voltage and PWM control signal output, and
[Test Measurement]
Data acquisition and control system design based on USB interface
Analyst: iPhone may switch to USB-C interface next year
       Beijing time, May 12, analyst Ming-Chi Kuo believes that next year's iPhone may abandon the dedicated Lightning interface and switch to the more universal USB-C interface.   Kuo's judgment comes from an investigation, which may be conducted on component manufacturers. Kuo believes that switching to a USB-C inte
[Mobile phone portable]
STM32F4 Development Notes 9: Detailed porting process of USB CDC driver
    This article details the porting process of the USB CDC driver.     1. After generating the driver according to the process described in STM32F4 Development Notes 8: Solving the USB CDC "The device cannot start" problem , find the file shown in the figure below and add it to your project.     2. Open the usbd_
[Microcontroller]
A brief analysis of the USB bus driver framework for Linux drivers
Universal Serial Bus (USB) is a connection between a host and a peripheral device. The USB bus specification has versions 1.1 and 2.0, and of course there is now version 3.0. USB1.1 supports two transmission speeds: low speed is 1.5Mbps and high speed is 12Mbps. The transmission speed of USB2.0 can be as high as 480
[Microcontroller]
A brief analysis of the USB bus driver framework for Linux drivers
Latest Medical Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号