introduction
This article refers to the address: http://
Traditional medical equipment, especially portable monitoring, ECG, blood pressure measurement and other equipment are using standard RS232 serial interface for data communication and transmission, which has become increasingly unable to meet high-speed data transmission, high data storage and frequent Data collection and other requirements [1, 2]. USB communication makes up for these shortcomings. It has many advantages such as fast transmission speed, high reliability, easy connection, and hot swap. Based on this, this paper introduces a real-time data acquisition and transmission method based on USB bus interface chip CH375 to realize the medical signals of PC and portable medical equipment, and gives the corresponding source program. After testing, the system works stably and reliably.
1 CH375 chip introduction
The CH375 is a universal interface chip for the USB bus that supports the USB-HOST host mode and the USB-DEVICE/SLAVE device mode. On the local side, it has an 8-bit data bus and read, write, chip select control lines and interrupt outputs, which can be easily hooked up to the system bus of a single chip/DSP/MCU/MPU controller. The CH375 chip integrates a PLL multiplier, a master-slave USB interface SIE, a data buffer, a passive parallel interface, an asynchronous serial interface, a command interpreter, a protocol processor for controlling transmission, and a general firmware program.
The CH375 chip has 7 physical endpoints inside. Endpoint 0 is the default endpoint and supports uploading and downlinking. The upload and downlink buffers are each 8B. Endpoint 1 includes the uploading endpoint and the downstream endpoint. The upload and downlink buffers are each 8B, and the endpoint of the uploading endpoint is 81H. The endpoint number of the downstream endpoint is 01H; the endpoint 2 includes the upload endpoint and the downstream endpoint, the upload and downlink buffers are each 64B, the endpoint number of the upload endpoint is 82H, and the endpoint number of the downstream endpoint is 02H. The host endpoint includes an output endpoint and an input endpoint. The output and input buffers are each 64B. The host endpoint uses the same set of buffers as endpoint 2. The output buffer of the host endpoint is the upload buffer of endpoint 2, and the input buffer of the host endpoint is The downstream buffer of endpoint 2. The system uses batch endpoint 2 to transfer data to the buffer, and uses the host endpoint and endpoint 1 to upload data to the buffer.
The CH375 chip has a built-in standard USB communication protocol, which eliminates the time spent by developers on writing communication protocols and facilitates communication. In particular, the file-level interface provided by its dynamic link library makes it easier to read and write data.
2 system hardware structure
The working process of the system is that the embedded medical device, ie, the lower computer (PC104), collects the medical signal and sends it to the display in the DOS state, and then sends it to the host computer (PC host) through the USB interface, and the upper computer works in the Windows environment [3, 4 ].
The system selects the PC104 industrial computer motherboard with USB interface. In the development process, the 5V DC power supply is externally connected through the power interface, the external display is connected through the display interface, and the multi-function interface is connected to the external keyboard. In order to facilitate the software update, we write the working program of the lower computer on the USB flash drive, which is connected to the USB interface of the PC104 motherboard.
The system based on CH375 chip also designed PC104-USB adapter board, and connected it as the expansion module of PC104 motherboard through PC104 bus interface. There are two USB ports on the adapter board, and one of them can be connected to the host computer through the USB adapter cable. The hardware platform of the system is established, and the system hardware connection is shown in Figure 1. The software implementation of system communication is described in detail below.
Figure 1 system hardware structure diagram
Figure 1 system hardware structure drawing
3 programming in the lower computer
The USB protocol stipulates that any transmission process is initiated and controlled by the host. The CH375 generates an interrupt when it receives the data sent by the host. To do this, the work of the lower computer is to wait for the interrupt of the CH375 and perform corresponding processing.
The lower computer works in the DOS state, and the software program uses the BORLANDC language. The main job is to initialize CH375, query interrupt and interrupt processing. The relevant program code is as follows:
(1) Interrupt service program for processing received data
Void interrupt USB(__CPPARGS)
{
Unsigned char len,i;
/ / Get the interrupt status and cancel the interrupt request
CH375WriteCmd(0x22);
D0=CH375ReadData(); //Read back status
If((d0==0x02)||(d0==0x01)) //Batch Endpoint 2 receives the data sent by the PC
{//Read data}
Inportb(0x21);
Outportb(0x20,0x20); //issue the EOI command,
Clear interrupt
}
(2) Write data subroutine
Void CH375WriteData( unsigned char dat )
{
/* Write data port*/
Outportb( PortBaseAddr + 0, dat );
DelayuS( 1 );
}
(3) Reading data subroutine
Unsigned char CH375ReadData( void )
{
Unsigned char d;
DelayuS( 1 );
/* Read data port*/
d = inportb( PortBaseAddr + 0 );
Return( d );
}
(4) Main program
Int main(int argc,char *argv[])
{
. . . . . . . . . . . . . . . . . .
For(;;) //wait
{//Software enters the main loop to handle emergencies
While(kbhit()) ch="getch"();
If(ch==27) break;
If(ch==59){.//Send data to the PC}
If(ch==60){//write interrupt feature data}
readbufUSB (); / / read the USB interface buffer data
}
. . . . . . . . . . . . . . . . . .
}
4 programming in the host computer
Because CH375's dynamic link library DLL provides a number of API interface functions, the application can communicate with the lower computer only through a few simple file manipulation API functions.
Also, the CH375 dynamic link library DLL provides a pseudo interrupt service (the actual interrupt service is still completed in the driver library, but only after the completion of the notification to the DLL, and then the DLL calls the pseudo interrupt service subroutine), based on Therefore, the system uses a pseudo interrupt service to upload data, which not only shortens the development cycle of the system, but also satisfies the real-time requirements of the lower computer. The program flow chart of uploading data is shown in Figure 2.
The downlink of the data only needs to send the data with a simple downlink API. It can be interrupted by CH375.
The upper PC works in the Windows environment, we use Visual C++6.0 language programming. The specific program is implemented as follows:
(1) Initialize the PC104-USB card
Here, the initialization of the device is completed, such as the loading of the CH375DLL.DLL file, the successful opening of the device, the cleaning of the buffer, the data upload mode, and the setting of the pseudo interrupt service program.
Figure 2 Upload data flow chart
Figure 2 procedure flowchart of uploading data
(1)void Init_PC104-USB()
{
. . . . . . . . . . . . . . . . . . .
If ( LoadLibrary( "CH375DLL.DLL" ) == NULL )
{ // hint language }
// The device must be turned on before using
If ( CH375OpenDevice( mIndex ) ==
INVALID_HANDLE_VALUE )
{ //Prompt language}
Else{
M_pc104usb_ok=TRUE;
Result=CH375SetTimeout(mIndex, 500, 500 ); // Set the timeout for USB data reading and writing. If the reading and writing is over 500mS, it will be forced to return, avoiding waiting all the time.
CH375SetBufUpload( mIndex, 1); //Enable internal buffer upload mode and clear existing data in buffer
/ / Set the pseudo interrupt service program
mPCH375_INT_ROUTINE ptr;
Ptr=InteruptProcess;
Result=CH375SetIntRoutine(mIndex,ptr);
}
}
(2) Receive data subroutine
Void PC_RecievData();
{ . . . . . . . . .
/ / Query the number of existing data packets in the internal upload buffer, successfully return the number of packets, error returns -1
Long packnumber=
CH375QueryBufUpload( mIndex);
If(packnumber>0)
{
CH375ReadData(mIndex,&m_recev_buf, len)
}
. . . . . . . . . . .
}
in conclusion
With the wide application of embedded computers in medical devices and the rapid development of USB communication technology, this paper initiates uploading data streams through the USB bus interface chip CH375 and PC host in pseudo-interrupt mode. The following APIs initiate the communication method of downlink data streams. And using a series of API interface functions, the real-time data acquisition and transmission between the upper computer (PC) and the lower computer (PC104) is successfully realized. The tested system can accurately send and receive data, and the communication is stable and reliable. The use of USB communication will provide broad prospects for the transformation of traditional medical equipment and the rapid development and application of a new generation of portable medical equipment.
This article is innovative: using USB interface technology, using the USB module CH 375 to achieve real-time data acquisition and transmission between the PC and the portable medical device, and without the need to write complex USB drivers, using its dynamic link library can be achieved. It can make the data acquisition and transmission system very convenient from RS232 communication, serial communication, parallel communication, and USB communication to make up for the shortcomings of slow speed and upgrade the system.
references
[1] Wang Gang. Liu Yayan. Application of USB interface technology in portable medical instruments [J]. Electronic Technology. 2004, 2, 10-12.
[2] Su Quan. Liang Kaiqi. Application of USB TO RS-232 in traditional medical equipment [J]. Medical Equipment Information. 2005, 20 (6) 19-20.
[3] Li Xinlong, Yan Hongfan, Di Guowei, Wang Xin,. Application of USB Chip CH375 in Energy Meter System[J]. Microcomputer Information, 2006-26:318-320.
[4] Li Jian. Xu Yuhua. Chen Lixue. Serial Communication Control between PC and PC104 in Windows Environment[J]. Journal of Southwest Petroleum University. 2001, 23(4) 68-76
[5] Yang Xiaopeng. Zong Ming. Visual C++ 7.0 Practical Programming Technology [M]. Beijing: China Water Resources and Hydropower Press, 2002.
Our wire harnesses are widely used for various parts of automobiles and truck , Like engine valve cover gasket/diesel gasket(DORMAN-FORD), headlamp(GROTE), Intelligent Anti-collision System(Mobileye), audio, rearview mirror, power seat, etc. Also the complete engine cable assembies for electric vehicle.
Related Products:ul wiring assembly,engine gasket cable,cable harness.
Automotive Wire Harness,Auto cable assemblies,OEM Automotive Wire Harness
ETOP WIREHARNESS LIMITED , https://www.etopwireharness.com