Design and realization of serial communication interface
based on LabVIEW
Guo Jie, Wang Zhaoba
National Key Laboratory For Electronic Measurement Technology (Taiyuan Division),
North University of China, Taiyuan, Shanxi, China
Email: guojie@nuc.edu.cn
Abstract: Serial communication is the common communication way of industry locale instrument or equipment, and in the application of low data rate demands, serial communication is still comparatively low-priced communication way. In this paper the author mainly studies the serial communication interface drive in LabVIEW, and uses virtualinstrument standard API which is VISA to practice programming. VISA does not have the programming ability, and it is a high-layer API, realizing the instrument programming by the bottom drive and accomplishing serial communication interfaceprogram of long-range data collection terminal superordination machine based on 8051 monolithic machine, which is used for such following functions:(1) to set up baud rate, data form, verification form and the control of data stream and the document saving route according to different needs, (2) after the program operating, in the nobody's post condition, waiting for receive data from the data collection at any moment, and saving the data under the form to the document being appointed, and waiting for data handling. (3) When uploading data, according to the prescriptive order format, entering the initiation andtermination moment in the order window, pressing down sending order, waiting for the data from the monolithic machine data collect system, and saving the data, thereby, to observe the transformation of data.
Keywords: LabVIEW, serial communication, VISA
I. Instruction
The serial communication is the commonly used communication mode in industry spot instrument ordata gathering system. In the development data gathering system, the serial communication is the**simplest and commonly used instrumentcommunication interface on computer and the *monolithic integrated circuit. On the serial communication application, LabVIEW has the corresponding modules to allow the user to set up hisown application system rapidly, the LabVIEW programming may get rid of the tedious first level order , and may realize the communication of PC and the instrument easily. II. VISA summary
2.1 The origin of VISA
In order to impel the standardization process of virtual instrument software, The VPP (VXI Plug & Play,which is called VPP) alliance completed the development of the standard of VISA , and issued each function prototype by standard form in 1996 . According to the VPP system specification definition, the virtual instrument system software architecture should contain three parts, as chart 2shows. The I/Ointerface software which use VPP’s standard is VISA.API (Application Program Interface) is the application software development interface, it is a group of functions of collections essentially, through it can visit the computer hardware equipment directly .VISA isthe standard API used in virtual instrument system.VISA does not have the programming ability itself, it is high level API, and it realizes the instrumentprogramming through transfering the first floor drivers. Its level as shows chart 1.
2.1.1 Input/output (I/O) interface software
The input/output (I/O) interface software between the instrument (namely I/O interface equipment) and theinstrument driver, it is a first level software level whichcompletes the direct data
access operation of instrument interior register unit and provides the information transmission for the instrument and the instrumentdriver the, it is the foundation and the core to realize theopen and the unification virtual instrument system. TheVPP system specification stipulate the characteristic, the composition, the internal structure and therealization standard of the virtual instrument system input/output (I/O) interface software detailed , and willdefine the virtual instrument system input/output (I/O)interface software which is up to the VPP standard to beVISA software.
Chart 1 VISA interior mechanism
the software develop
environment applying
The software
applying
Instrument driver
I/O Interface software
Chart 2 the virtual instrument system software architecture
2.1.2 Programme of instrument driver
Each instrument module has its own instrument driver.The essence of instrument driver was provides for the users more abstract operation function collection which is used in the instrument operated. As for the application procedure, it through the instrument driver to realize the operation of instrument; Instrumentdriver program call the unified foundation and stylefunction storehouse (the VISA storehouse) which provided by input/output (I/O) software to realize operation and management of regarding instrument,also is and the form which s through. Once the application programmer had the instrument driver program he can enter into the design work of virtual instrument system even he is not extremelyunderstands the instrument built-in function process.The instrument driver program is the link and bridge to connect the upper application software and the first floor input/output (I/O) software.
2.2 Characteristics of VISA
Compares with other extant I/O interface software, VISA has several characteristics as following:
(1) The control function of VISA I/O is suitable foreach kind of instrument. VISA has contained the control operation of VXI instrument, GPIB instrument,RS-232 the serial instrument and so on, and has contained the operation of register component, memory component and so on, its form is unified.
(2) The control function of VISA I/O is suitable foreach kind of instrument hardware interface. (3) The control function of VISA I/O is suitable forboth the single processor system structure, and the multi-processor structure or the distribution network structure.
(4) The control function of VISA I/O is suitable formany kinds of networks mechanism. Regardless of the virtual instrument system network constitute the VXI engine cases expands network or the Ethernet ,the instrument operation is coincident .
The source program of VISA I/O software storehouse is exclusive, and is foreign to its system andprogramming language, it only provides the standard form API document as the system output. In the VISA structure, the difference of instrument type show as the different resources name. As a VISA user, the use of different type instrument in the form and the method is the same.
III. System designs
According to the request of the experiment of remotedata gather terminal, in the design the RS-232 communication interface part of computer:
(1) According to different needs design the baud rate,the data format, the verification form as well as the data stream control, and establishes the document path of data storage.
(2) After running the program, when nobody duty, it waits for receiving the data from the data gathering terminal momentarily, and stores the data in the document which assigns in the form of text documents , waiting for the data processing.
(3) When transfering the data, according to stipulated orders form, in command window input the outset and the termination time, presses the transmission command, waiting for the data from the data gathering system of monolithic integrated circuit, and store the data in the text documents which assigned the path, and display the data in the observation window simultaneously to observe change of the signal. 3.1 Initializing serial interface
According to the request of design ,initialize the serial interface as: Baud rate 2400b/s, data position 8 bit, 1 bit stop position, non- parity check position.
3.2 Operation of reading data
After the system initialized, it is waiting for receive the data .The data gathers terminal transmit data time-lapse. The data is storaged in specific folder asthe data and the time are transmitted on together, and record the data history automatically, waiting for the processing of following procedure.
3.3 Operation of writing data
When transmit data of specifically time slice, the computer sends an order (namely value of outset time and termination time) to the monolithic integrated circuit, and withdrawal from record data, transmitting an order string to the serial interface, the order must be written in outset time and the termination timewindow before pressing the transmit button, after transmission wait it for the monolithic integrated circuit process data delayed and waiting for receiving data . After receiving the data and displaying the data in the observation window close the read data 0 button, the data not be lose as the system will in thecondition of waiting receive the data which transmitted time-lapse .It should be noticed that the control button which send order can be designed as apulse, otherwise the program will send orders circularly ,and cannot return to the condition of waiting for transmit time-lapse.
3.4 Close serial interface
After close the gather system close serial interface, releases the resources which took up by LabVIEW.
IV. Program flow diagram
Program flow diagram like chart 3 shows.
Chart 3 program flow diagram
Start to run. Initialize serial interface. Waiting receive data.Stored datum. The data acquisition system onfixed time passes on the data. Transmit order. Transmit order character. Waits for receive data. Requests some o'clock compartment data whichpasses on. stores data in the document. Confirms the data receive. Whether withdraws from the procedure. Close serial interface.
V. Confirm program
Transmitting time orders to the gather terminal, namely record the returned data in document data.txt, and display the data in the observation window simultaneously. Receiving the data which is from data gather terminal transmit time-lapse, writing in the document DATA1.txt, waiting more data processing.
VI. Conclusion
It has completed the design and realization of serial interface driver through the debugging, the results indicate that the transmission of data is accurate, andthe establishment of parameter is flexible, reach the requirements of design. REFERENCES
[1] Yang Leping, Li Hai Tao, Yang Lei. LabVIEWprogramming and application [ M ] 2 version Beijing:Publishing House OF Electronics Industry,2005.
[2] Liu Jun hua. Design of virtual instrument Based on LabVIEW [ M ] Beijing: Publishing House of ElectronicsIndustry,2003.
[3] Liu Jun hua. Graph programming language of virtual instrument LabVIEW course Xi'an Publishing House of Electron Technology University