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
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,
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
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.
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
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.
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
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.
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
- High-speed 3D bioprinter is available, using sound waves to accurately build cell structures in seconds
- [“Source” Observation Series] Application of Keithley in Particle Beam Detection Based on Perovskite System
- STMicroelectronics’ Biosensing Innovation Enables Next-Generation Wearable Personal Healthcare and Fitness Devices
- China's first national standard for organ chips is officially released, led by the Medical Devices Institute of Southeast University
- The world's first non-electric touchpad is launched: it can sense contact force, area and position even without electricity
- Artificial intelligence designs thousands of new DNA switches to precisely control gene expression
- Mouser Electronics provides electronic design engineers with advanced medical technology resources and products
- Qualcomm Wireless Care provides mobile terminal devices to empower grassroots medical workers with technology
- Magnetoelectric nanodiscs stimulate deep brain noninvasively
- 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
- Single-chip microcomputer controlled xc1004 four-axis SPI motion control chip information
- I would like to ask a basic question: Is the discharge speed of parallel capacitors determined by the ESR of the capacitors?
- How to choose the appropriate inductor and its parameters? | MPS invites you to learn practical tips and win gifts by commenting!
- I need help with soldering tips. Why does flux often splash out when I add tin to my soldering iron, burning my hands?
- What are the differences between RTU and DTU?
- Three key technologies of mobile robots
- FPGA implementation of terrestrial digital television symbol and carrier synchronization.pdf
- Classic: MSP430 microcontroller enters low power mode program code
- X-NUCLEO-IKS01A3 sensor test based on STM32F401RE development board 3D acceleration LIS2DW12 sensor test...
- ARM Embedded Learning Resource Sharing——"ARM Embedded Architecture and Interface Technology".pdf