Saturday, January 28, 2012

The blood pressure of ECG monitor USB interface design

Introduction home blood pressure monitoring system and Electrocardiograph from acquisition and record device and PC electronic case management system, therefore, need to address the problem of data transmission.

Traditional communication interface with a simple RS-232 serial UART, this way slow and bad fit, while the USB transfer serial chip transmission performance cannot been fundamentally improved. USB interface is a fast, easy to scale and support hot-plug, easy to use and flexible, especially for household equipment and computer communication connection.

This article focuses on USB communication protocol and interface chip control method for clinical needs, design and realization of the intelligent with ECG, blood pressure monitoring, USB high-speed data transmission function of miniature devices, providing ECG, blood pressure data electronic medical record query, printing, and network transport functions, for improving family health-care level is very important.

Monitor's USB interface circuit design system main control chip uses 32-bit high-performance embedded ARM microprocessor S3C44B0X, USB dedicated control chip selects the USBN9603.

USBN9603 built-in 7 FIFO ports, including 1 bi-directional control port, 3 3 send port and receive ports, each with 64 bytes.

USB controller and S3C44B0X interface circuit shown in Figure 1.

The USB controller is designed to store the nGCS2 Bank2 selection line as the USBN9603 slice alignment, the chip-chip selected address 0x4000000. This article uses the parallel data interface, two chip low 8-bit data cable connected D0 ~ D7, parallel transmission communication data. The MODE0 MODE1 pin are grounded and, configure the USBN9603 as non-multiplexed mode, because this mode requires the address lines A0 as access USBN9603 chip register DATA_IN, DATA_OUT and ADDR register select line, connecting the 32-bit address bus of the A18 to USB controller A0. The USBN9603 to read and write, is divided into two bus cycle: first of all, reset the address lines A0, namely to set high bus address for access will be 0x4040000 register address from cable D [0: 7] write, this is the first bus cycle will address to the chip; then, in the second cycle, low, i.e. A0 reset set the bus address read-write for 0x4000000, D [0: 7] can be realized on the registers of read and write operations. The entire USB communication process mainly dealt with include receiving, sending data and other disruption event, the USBN9603 int pin connected to the external interrupt S3C44B0X EINT0 pin, set USB interrupt-vector interrupt request mode. Because it does not use DMA, DACK reset, DMA request line DRQ vacant. USB cable has 4 wires, D + and D-is USB differential signal line, the other two are 5V power and ground wire. USBN9603 support low-speed and full speed USB communications, at D + signal cable connection 1.5 K Ω pull-up resistor to work at full speed mode.

Figure 1 system extended memory and USB interface schematics monitor's USB interface firmware implementation USB communication process is started from the host, in accordance with the agreed time to issue a token packet that contains the operation type, direction, peripherals, address and endpoint, and other information, and then specify the token data sender sends a packet or pointed out that no data transmission.

And USB peripherals to respond to a confirmation packet, indicating that the transfer was successful. This article uses the master-slave USB communication structure, the host computer by sending various prior agreement good protocol commands, to achieve the ECG, blood pressure data collection and to initialize the settings of the system equipment, mainly include the following data: ECG data to segment and each segment including 32KB ECG data and 6B acquisition time information, each transport segments, the amount of data, the transmission reliability requirements are high; blood pressure data including the diastolic pressure and systolic blood pressure and its acquisition time, 10B, because blood pressure monitoring more frequently, every time will transfer time of blood pressure monitoring data, the amount of data is also relatively large; download the upgraded version of the firmware, and other file information. These three data flows are relatively large, and reliability requirements are higher, three data selection block transmission channel types, in addition, each USB transfer will have control of the transmission channel. Therefore, you need to use three channels, namely the control channel, BulkIN channel and BulkOUT channel. USB firmware data structure this article relates to the USB device configuration enumeration phase super-computer in control transmission requires device transfer 4 class descriptors, in a hierarchical order: the device descriptor, the configuration descriptor, interface descriptor and endpoint descriptors, which, compared with higher-order descriptor will notify the host any other low-level descriptor information. Device descriptor is in the device connection host first read descriptor, each device can have only one device descriptor that contains the entire device and the device supports configuration number, total 18 fields. Each USB device has one or more of the configuration descriptor that contains the device power management and device configuration supported interface numbers, when the device receives get configuration descriptor's request, transfer the configuration descriptor and all the interface and endpoint and other ancillary descriptor to a host, this article sets a configuration, the descriptor of 8 fields. Interface contains a set of endpoints, the paper sets an interface, the descriptor has nine fields, as the host computer provides equipment use endpoint information such as the number and types. Each interface descriptor has zero or more endpoint descriptor that contains the host and endpoint to communicate the required information, endpoint 0 as a control endpoint to an endpoint of communication, 1 and endpoint 2 respectively block transfer mode, the descriptor contains endpoint number, transmission direction, endpoint transport type, maximum transfer byte packets. USB firmware communication processesUSB firmware framework process as shown in Figure 2, after entering the communication module, the firmware first calls the initialization routine, configure USB device, and make it into working order, and then enable interrupts, USB communication's main function is to interrupt the service, the main program is in a loop waiting for exit key, when break signal is detected, you are ' clicking ' to interrupt service routines, according to the register value judgment MAEV interrupt type, and enter the appropriate process. Figure 2USB firmware framework device USB communication mainly for ECG and blood pressure data Bulk transfer function. In the USB transceiver data communication protocols based on the monitor there is a specific application-layer communication protocol. Firmware receives user communication command, analytical control command and execute the corresponding routines. As transmission of ECG and blood pressure data command 0x10, firmware after receiving the order code 0x10, obtain from the command parameters be transmitted data length, select the ECG or blood pressure and its transport signs record number and other information, based on record number call GetRecordData (), Flash store to find data and stored in the send buffer BulkState, if transmitted ECG data you need to get through the Gettime () which ECG data acquisition time. All question to send data when you are ready to begin the transfer, as the Bulk transfer of maximum buffer to send 64B, first data, and then in 64B TX_EV routine to determine whether the receiving host computer, and if successful you successfully transfers the next batch of block input transaction, you will need to repeat, repeat the above process until loop data sent.

USB firmware module routine to initialize the USB interface initialization routine, including the USBN9603 chip initialization and user variables initialized after device enumeration.

During the initialization phase, the firmware needs to be strictly in accordance with the order on the USBN9603 registers. USB device enumeration process, the system's USB connector to access a USB connection port (hub or host root hub), the device is turned on; the USB D + and D-data and the access of hub port or the host's root hub between two 15 K Ω with pull-up resistor. At this point, the pull-up resistor will make the data signal line-level rise, notice a new device access hub; then, use interrupt channel hub reported to host events, does have a new device access, the host device to connect the hub to send asks, so that the hub Set_Port_Feature to port USB hardware reset command sent and sustained 10ms, and then identify the device speed. At this point, the device has completed the initialization operation in the host that the device has left the reset State starting in the endpoint 0 is the default channel for USB control of transmission into the enumeration phase. Block transmission standard routine firmware send realizing through endpoint 1 routine to host block transfer function, the process shown in Figure 3. Upload ECG data, for example, firmware through the endpoint 0 receiving host upload ECG data requirements, data to be transferred into the buffer, at the same time, writePtr put the question to the transferred data, size, and other information into bulkState. Figure 3 transport send module routine firmware to receive routine through the endpoint 2 receive data from the host, the host should send a letter OUT to endpoint 2, SIE from the transceiver to automatically receive data and stored to FIFO2, FIFO2 automatically updates receive control register RXC State data receive hardware operation completes, the USBN9603 a reception interrupt transfer to perform S3C44B0X processor, firmware receives the interrupt service routine. USB communication protocol of the host-side implementation of WDM drivers including equipment feature drivers and bus drivers. Among them, the bus driver provided by Windows, this host-side software includes the following three levels: user-mode applications, achieve USB communication Win32API dynamic link library and kernel mode driver for WDM device capabilities. Dynamic link library encapsulates access kernel mode driver functions, and user application provides access to the interface, the user application simply call for specific data transfers instead of the host-side software design of the core is how to develop WDM device features driver. In Windows2000 platform installation Windows2000DDK, use VisualC + + 6.0 as a development tool, with DriverWorks Kit and kernel code debugging tool module, as well as USB SoftICE monitoring tool for WDM driver BusHound. According to the DriverWizard Wizard, select the device type is USB; select i/o request packet handling of IRP for IRP Queuing; create device interface is 128 bits of a globally unique identifier (GUID) that identifies that makes using CreateFile () function to open a device, WDM by GUID identification and access device driver; configuration control, BulkIN and BulkOUT these three endpoints transmit commands and data respectively. Configure three IOCTL-control command: MYUSB_IOCTL_COMMAND is host to send communications command control command, its IoctlCode as 0x812; MYUSB_IOCTL_BULK_READ and MYUSB_IOCTL_BULK_WRITE sent separately transmitted Bulk data read/write command, its IoctlCode 0x814 and 0x815 respectively. All Setup is finished, generate .inf Setup information file. In this framework, according to application requirements, you can write and host communication device firmware device drivers. When the host requires read and write in Bulk form and transmit ECG or blood pressure data, givesIOCTL_CODE as MYUSB_IOCTL_BULK_READ of IOCTLIRP, handling routine to BulkReadWrite (). By passing different parameters separately for BULK data read/write function, you first need to obtain from the IRP application delivery channel number, input/output buffer and its size and other parameters, call FindPipe () IRP request channel instance, constructed on that channel, called URB SubmitUrb () send realizing underlying URB, USB class drivers for the communication, the complete Bulk data transfer capabilities. Conclusion of this article to take full advantage of USB transfer speed, accuracy and ease of use and other features, the USB interface to household ECG, blood pressure monitor, complete the arm MCU and USB control chip interface hardware and software design, and ECG transmission experiment, indicating that the system has high reliability and accuracy. References: 1 Xiao-Wen .USB2.0 hardware design-Tsinghua University Press, 2002: 67 ~ 105 2 King arts. high-speed serial bus in DSP data acquisition system and research-Zhejiang University Master's thesis .2002: 9 ~ 21 3NationalCompany.USBN9603 (UniversalSerialBus) Full SpeedFunctionController.NationalSemiconductors 4 wu'an River, Lily .Windows device drivers (VxD and WDM) develop practice-electronic industry press, 2001: 120 ~ 177

No comments:

Post a Comment