Monday, January 3, 2011
【 Weak current College 】 parallel port and serial real-time communication 】
Summary of the article describes a parallel port and serial communication port to a one-way data communication method, the method was successful in practical application to be made up of 386 microprocessor engineering system of a, achieved satisfactory results. 1. Introduction to the general scientific experiments or engineering applications, often need to test data or product data output from the printer, and then the artificial (or computer) for analytical processing.
If you set those sent to the printer port data, delivered directly to the computer, the software for analysis and processing, and forms a complete data-processing system, the user's data processing convenience, better production and research services.
This paper describes the combination of oilfield using detectors Tester (SMT-100), solved those sent to the printer port (thermal printer-Fujitsu FTPO40UCS) data through PC serial port directly to your computer, as well as the development of application software interface. Second, it works because SMT-100 Detector Tester of 8-bit data is sent to the printer via the parallel port, if it wishes to output data to the parallel port via parallel port to the computer, you need to design a dedicated interface boards (such as scanners dedicated interface board). Because the computer has been configured with the parallel port are defined by the system into standard output device, unable to receive external parallel data, but the configuration of the serial port is standard input devices . The parallel data through "parallel-series" after the conversion, the standard RS-232 serial port to PC host is feasible. Particularly in industrial practice, can save distance parallel cable costs, and improve anti-interference ability, therefore the amount of data in transit is not very large, you can send using parallel, serial receive means of communication. As shown in Figure 1.
Figure 1 interface connection diagram (parallel port to a serial port) bi-directional converter adopts industrial products SXP-320 . (A)
Its main function parameter as table 1.
Table 1 (on)
The parameters set by the side of 8-bit DIP start to finish:
Figure 2 (a)
Work, simply place the baud rate, data length, stop bits, and parity settings matches the host. 3. interface programming using the BIOS serial routine transmissions, when transfer speeds greater than 2400bps, there may be missing characters . To this end, the system uses the interrupt control, serial port for receiving and storage implementation control, prevent data loss.
PC in the primary implementation of serial communications is programmable chips 8250, 10 accessible registers, of which 5 as needed, at the beginning of the program, they can be used to initialize.
Its port address and status word meaning as table 2.
PC computer 8259A interrupt chip, a shielded register (IMR), can provide eight interrupt sources, RS-232 interface corresponds to IRQ4, according to requirements set interrupt mask control word.
When an interrupt request 8250 signal (that is ready to receive data), the system bus arrival 8259A interrupt controller input (IRQ4), the CPU to respond, then executes the interrupt service program, for data transfer and storage operations.
Utility of initialization settings as follows:
mov al 2ch; Mov dx, 8259a initialization 3fbh
out 21h,almov al,03h
Mov dx, 3fbh; 8350 initialize out dx, al
mov al,80hmov dx,3fch
out dx,almov al,0bh
mov dx,3f8hout dx,al
mov al,20mov dx,3f9h
out dx,almov al,01h
mov dx,3f9hout dx,al
Mov al, 0sti; open interrupt
Use line status register (port address 3FDH), detects the data received is wrong. If so wrong, it emits a beep sound, exit interrupt service routines in order to terminate the data transfer depending on the circumstances. IV. application design using these means of communication, you can capture to an external device sends all the information that you wish to do further processing on it and storage, is needed according to user needs, the development of appropriate application software.
We will oil field Detector Tester and host (386) connected, as described above and those with serial port all of the information received, after the analysis, processing, application software, generate disk data file , as a user of an in-depth study of the original data .
Testing a component of the process are as follows:
(1) in the main program for serial port storage data, the establishment of a first-in, first-out buffer of characters, dynamic applications circle-buffer 64K memory, you can receive the equivalent of 2000 component of full information.
(2) in the main program opened a store in a single component of the result of small buffer (such as 30 bytes) readbuffer.
(3) BX-pointer to the buffer buffer circle, a sequential scan, each handling a component receives the amount of information, using stack technology, a symbol of all parameters of the delimiter (such as "=") address is pushed on the stack. And then one by one the pop-up, press output text format for processing, and processing results in readbuffer.
(4) the contents of the disk readbuffer file management function calls, write to the data file. One record at a time, so repeat (3) and (4) until the content is empty circle-buffer.
(5) work process, through ESC function keys may at any time discontinue the serial port communications. 5. concluding remarks in the debugging process, through to 500 components for testing, shipping, receiving and processing, all achieved satisfactory results.The project has been to Xi'an petroleum exploration instrument factory detector factory use, real-time, high reliability, high practicability. Reference 1 Wang Yuan, Wu Zhi-fang .IBM PC/XT interface technology and its applications-Tianjin: Nankai University Press, 1990
2 TWO WAY CONVERTER/BUFFER SXP-320 User's Manual .copyright 1990 ATEN International Co., LTD
3 Ming shen, warm winter shim .IBM-PC Assembly language programming: Tsinghua University Press, 1991
4 Zhao-et al. microcomputer peripheral interface and channel-Xi'an Jiaotong University Press, 1991
5 seismic detector principle-Xi'an petroleum factory, 1986