The Design of a Chemical Virtual Instrument Based on LabVIEW for Determining Temperatures and Pressures

A LabVIEW-based self-constructed chemical virtual instrument (VI) has been developed for determining temperatures and pressures. It can be put together easily and quickly by selecting hardware modules, such as the PCI-DAQ card or serial port method, different kinds of sensors, signal-conditioning circuits or finished chemical instruments, and software modules such as data acquisition, saving, proceeding. The VI system provides individual and extremely flexible solutions for automatic measurements in physical chemistry research.


INTRODUCTION
Measuring instruments have gone through several stages in their development: analog meter, discrete component parts (DCP) instruments, digital instruments, intelligent instruments, and have now reached the stage of the virtual instrument (VI) [1]. VI is the result of the close combination of modern electronics, transducers, instrumentation, and computer techniques. The hardware of the VI exploits the capacity of the transducer, signal condition circuit, and computer resources, and so forth. Under given hardware conditions, the software is the VI's key component. Given different softwares, the VI can transform into different instruments. We might say the software is the instrument [2]. LabVIEW is a graphical programming language developed by National Instruments and it has great power and utility. It is possible for amateur programmers to design programs of high quality by using LabVIEW, and it suits the thinking methods of scientists and engineers so that it can be honored with the name of engineering language. Nowadays, it has wide application in the fields of aerospace, communications, automobile engineering, biomedicine, and so forth. However, to our knowledge [3], it has not yet been reported on frequently in the field of chemistry.
Temperature and pressure are two very important parameters in many fields of research, including chemistry. Especially in chemical thermodynamics and the chemical industry, we can acquire vital information and guide production by measuring temperatures and pressures. Some important physical chemistry parameters, such as enthalpy, entropy, reaction rate, molar mass, can be obtained by measuring the change of the two parameters. However, owing to the special features of chemistry, these physical parameters cannot be obtained directly from the experimental values of temperature and pressure. In general, these experimental values must be processed at a deeper level according to the principles or laws of chemistry, such as converting by formula, plotting, finding equations that obey specified laws. In many situations, the value of temperature and pressure can indicate to the researcher whether the reaction is in process. Obviously, a normal instrument has difficulties in achieving that effect. Moreover, when using a standard instrument, the researcher has to process data by hand. This not only wastes time, but also easily causes human measurement error. In this paper, LabVIEW 7.0 Express-based VI for determining temperatures and pressures is developed by using temperature and pressure sensors, a signal-conditioning circuit, a DAQ card, or standard chemical instrument. This VI is able to complete the measurement of a system's temperature and pressure automatically and obtain results duly. The results are satisfactory.

THE CONFIGURATION OF THE VI SYSTEM
The configuration chart for the VI system is in Figure 1. The signals of chemical reaction are analog signals converted by sensors, such as temperature, temperature difference, pressure, pressure difference. The analog signals are 2 Journal of Automated Methods and Management in Chemistry  Figure 1: Configuration for VI system. converted into digital signals in the DAQ card or by standard chemical instruments and are sent to a computer. Finally, the digital signals are processed on the LabVIEW platform.

PCI-DAQ card method
The PCI-DAQ card method was the earliest method used in the construction of the VI. The method utilizes a DAQ card to convert analog signals to digital signals, so that a computer can process the various analog signals. It provided a way of constructing the VI by using the computer's bus, input devices, output devices, software, and so on. It is still popular in the world of measurement and control on account of its wide use and applicability for use in various laboratories and teaching sectors.
The analog signals from normal sensors are very weak, so they must be preprocessed before entering the DAQ card by methods such as impedance conversion, amplification. The signal-condition circuit of a temperature sensor made by the author is shown in Figure 2. A DC bridge is made up of a temperature sensor, Pt100, and three impedances, and sends converted DC signals, caused by the change of temperature signals, to the instrument amplifier AD620 for amplification. The bridge power source comes from 1.5 mA constant current produced by the operational amplifier. AD620 is a monolithic instrumentation amplifier based on a modification of the classic three-op-amp approach. Monolithic construction and laser wafer trimming allow the tight matching and tracking of circuit components, thus ensuring the high level of performance inherent in this circuit [4]. The LM399, in Figure 2, is a precision, temperature-stabilized monolithic offering high-quality reference voltage to the fifth pin of AD620. The amplified signals are sent to a second-order filter circuit via the sixth pin of AD620, and then are sent to a channel of a multifunction DAQ card, PCI-2005, to convert analog signals to digital signals. PCI-2005 is made by Beijing Art Corp. and it has 16 bits, 16SE/8DI, ±10 V input range, connects to computer with PCI bus, and the driver can operate it by calling LabVIEW's function [5]. Figure 3 shows the program of the PCI-2005 driver realization and dual-channel DAQs, which is used to determine the constant of the reactive rate by the decomposition of peroxide. In order to realize the PCI-DAQ driver, we use call library function (CLF) node in LabVIEW, implement A/D converters for corresponding temperature and pressure, at the same time, save text file in a text model. The other sensors' signal-condition circuits are similar to the temperature circuit, the only difference lying in amplifying times and reference voltage.

Serial port method
Serial port communication is a common method of communication between computers or between computers and peripheral devices. This method has the advantage of generalized use, but the speed of data transfer is rather lower, so it suits a measurement system that does not demand a high data transfer speed. There are very few testing systems in chemistry experiments requiring high-frequency signals, so using the serial port method to acquire data is not only making the best of laboratory resources, but also using traditional instruments to upgrade intelligent instruments.   According to communicating protocol, we can acquire the experiential data by using correlation functions in LabVIEW [3,6]. Figure 4 shows a DAQ program of serial communication using the digital temperature-measuring instrument for determining molar mass with freezing point depression. According to the communicating protocol by which data is sent, invoke the VISA node in LabVIEW to obtain initialization of the serial port, VISA Read, and VISA Close, and so forth, then programe for data acquisition, display, saving, and so forth.

Design for control panel
The control panel of the virtual instrument is an interface between user and computer. Besides friendly interface and easy control, the corresponding test function can be started up by a simple manipulation. It should also be able to finish user's task successfully. Software is a key section of the VI. Given different softwares, the VI can have different functions.
The author designs the program by the module method for convenience in development and call. Figure 5(a) shows the VI control panel where four physical chemistry experiments are displayed. The program is designed by selecting different events and a corresponding VI panel will open and enter the chemical testing system as long as we click the corresponding icon, for instance, by clicking the molecular weight icon, the panel will show as in Figure 6. The program provides a helping function in that the user can get help by lighting the help icon or keeping the cursor on a few seconds, when some helping textual material will display to describe the function of the modules and give the user some  information about the experiment. It is possible to select the method of acquisition, DAQ card or serial port, via select icon. The exit icon is used to exit from the VI testing system safely. Figure 5(b) is the block program of the VI, while a loop is used to ensure that the program will check continuously. Some sub VIs that were previously made and ran well can be called up by selecting the event. This programing method is convenient for extension and modification.

Design of program for public sub-VI
There are different tasks and data processing methods in different chemical testing systems, but the basic procedures, data acquisition, data filtering, curve fitting, real-time displaying, calculating, and generating the report of results are the same. Therefore, one program can be made as a shared sub-VI for different chemical VIs to use. During the design program based on LabVIEW, the sub-VI is a key element to modularize and layer the modular program and it corresponds to function or subprogram in text-based programing languages. User can call each VI as a sub-VI [7], and the number of sub-VIs is limitless. Moreover, a sub-VI can be the subroutine itself. By using a sub-VI during the development of a program, we can save code, reduce developing time, and raise efficiency. It is also easy to debug and manage.

Sub-VI for redisplaying data
To check or compare with acquired data expediently, the author designed a data-redisplaying icon on every subpanel. Figure 7(a) is a picture of a data-redisplaying sub-VI panel. Clicking the redisplay icon, a dialog box will allow user to select a file to read. User can redisplay acquired data several times until he clicks the exit icon. Values of the x-, yaxes are shown in the region of the cursor. The curve setting icon is used to set the curve's type, color, and thickness, and enlarge some segment of the curve. The print icon is used to print the curve on the panel. Figure 7(b) is a program for a data-redisplaying sub-VI. There are two case structures in the whole loop, the uppercase structure is used to read an acquired data file and send the data to waveform graph for display, and the lowercase structure is used to print the curve Wen-Bin Wang et al.

Sub-VI for fitting curve automatically
In a general way, the testing system of the chemical VI is able to acquire plentiful data at tremendous speed, but the whole data is discrete. During data processing, we sometimes need to fit discrete data to a curve, obtain its equation, and get intersection points of some curves, for example, we need to get the intersection points of some curves in drawing the binary metal diagram and determining molar mass with freezing point depression and we need the curve equation in measuring the surface tension of a solution. There is no function to obtain an equation directly, so we have to program it by ourselves via calling correlated functions in LabVIEW. The program for curve fitting and obtaining equations automatically is shown in Figure 8. The testing data is automatically fitted, respectively, in given fitting models, and the mean square errors (MSEs) of fitting effects are sent to an array, then according to the least MSE, computer confirms the best fitting model or fitting order. The fitting models are linear fitting, exponential fitting, and general polynomial fitting, which are found in functions "Mathematics" Fitting, and the comparing array elements are achieved depending on Array Max & Min function. When making a curve fitting in case structure the corresponding fitting result displays instantly. The program sets a sub-VI of writing equation again, which has a function for converting the best coefficients to strings, and write expressions f (x) and y = f (x), which have different functions in different conditions, for example we must use the form f (x) in the function Eval y = f (x).VI or Integration.VI. If we use the form y = f (x) [8], the program cannot run. However we have to give the form y = f (x), when we write the equation. Now we can solve the problem by connecting the right output terminals in different circumstances.
Due to the limitations of this paper's length, other common modules such as data acquisition, real-time dynamic display, elimination of excess data, and curve fitting for the construction of chemical VIs are not discussed.

Property setting for sub-VI node
After developing and debugging the sub-VI, we can create a property node and call it up as a module when we need. Every sub-VI has a connector pane, and every connector pane has several terminals. The programmer simply connects the controls or indicators with terminals but need not worry about the internal structure of the sub-VI. In a sense, input and output terminals correspond to formal parameter and actual parameter in C language, respectively. Select an appropriate terminal pattern for the sub-VI by right clicking the connector pane. There are 36 kinds of patterns to select or edit by increasing or decreasing terminals [7]. For example, the sub-VI for fitting curve has three input and two output terminals, which are connected to an array of fitting coefficient control, digital precision control, model of fitting control, and an expression of equation indicator for f (x), y = f (x), respectively.
When LabVIEW calls a sub-VI, ordinarily the sub-VI runs without displaying its front panel. But some sub-VIs need to display their front panels when called and to close their front panels after being called, such as the sub-VI for redisplaying data. There are two ways to set its properties. The first way is to select VI properties, select window appearance  from the category pull-down menu, click the customize icon, and set its dialog box. The second way is to right click the sub-VI icon and select sub-VI node setup from the shortcut menu. The first way requires every instance of the sub-VI to display its front panel when called, but the second way simply displays its front panel when called.

APPLIED EXAMPLES
The author carried out corresponding test experiments in turn, with data acquisition, real-time display, data processing, generating the report of result which can all be completed automatically giving satisfactory results [3,6]. The data processing module of the system, set on a different mission, can fulfill the corresponding testing assignment. For example, we add a data processing module of heat of combustion in the system, and can apply it to measuring the material combustion heat. The results are shown as Table 1. Their relative measurement errors are all less than 4%, a satisfactory result.

CONCLUSION
The author designed VIs for measuring temperature and pressure based on LabVIEW. These instruments were composed of four representative physical chemistry experiments: drawing a binary metal diagram, determining molar mass with freezing point depression, determining the constant of the reactive rate in the decomposition of peroxide, and measuring the surface tension of a solution by the pressure of froth. These experiments can determine the temperature, temperature difference, pressure, and pressure difference of the system, respectively. In these experiments, we can take the measurements by the PCI-DAQ method or standard chemical instruments serial port method. A manipulator can com-bine the sensors, signal-condition circuit or standard chemical instruments and corresponding data processing modules, according to the actual condition in the laboratory and the concrete requirements of the experiment, thus the system of chemical testing VIs can be constructed easily and quickly. For example, with the combination of VIs for drawing a binary metal diagram, if we take the measurements by the PCI-DAQ method, we should select Pt100 temperature sensor, temperature signal-condition circuit, DAQ card in hardware, select data acquisition.VI, data redisplaying.VI, abnormal point removed.VI, find out turning points.VI, find out eutectic point.VI, draw phase diagram.VI in software. If we take the measurements with standard instruments, we should substitute a digital temperature-measuring instrument with serial ports in place of the hardware. Nothing needs to be changed except the data acquisition.VI in software. It is similar to other experimental testing systems. The VI can be used in extensive applications because of its flexibility. It can be used in numerous experimental systems, such as determining temperature and temperature difference of fusible heat, burning heat, determining the pressure and pressure difference of pure liquid saturated steam pressure, the disposed pressure of solid. This system solves the problem of communication between the sensors or between standard instruments and the computer, which are unfamiliar for most chemical workers, and the common problems for designing chemical VI to measure temperature, temperature difference, pressure, and pressure difference. When the user needs to test the temperature and pressure which are beyond this system, then he can compose a new measuring system to meet the requirements of the new testing by transferring the function designed modules and combining them, thus avoiding a waste of manpower and material resources. This means that developers can design customized measuring instruments according to their own requirements. Exploiting VIs based on Lab-VIEW has many advantages, such as a user-friendly working panel, ease of manipulation, complex data processing, drawing and printing the result at the click of the mouse. Moreover, using the application builder tools that belong to Lab-VIEW itself to create standalone applications and installers or shared libraries (DLLs) for VIs, the user can run and extend independently from the LabVIEW development environment. Altogether, this system has very great practical application value.