# Virtual Instrument for Determining Rate Constant of Second-Order Reaction bypX Based on LabVIEW 8.0

Authors: Hu Meng; Jiang-Yuan Li; Yong-Huai  Tang
Journal: Journal of Automated Methods and Management in Chemistry
 (2009)

---

## Abstract

The virtual instrument system based on LabVIEW 8.0 for ion analyzer which can measure and analyze ion concentrations in solution is developed and comprises homemade conditioning circuit, data acquiring board, and computer. It can calibrate slope, temperature, and positioning automatically. When applied to determine the reaction rate constant bypX, it achieved live acquiring, real-time displaying, automatical processing of testing data, generating the report of results; and other functions. This method simplifies the experimental operation greatly, avoids complicated procedures of manual processing data and personal error, and improves veracity and repeatability of the experiment results.


---

## Body

## 1. Introduction

LabVIEW is the abbreviation of Laboratory Virtual Instrument Engineering Workbench, which is the innovative software product of National Instruments (NIs) in United States. It is the preferred platform when people exploit virtual instrument as the most functional graphic software at present [1–5].Ion analyzer is one of the most widely used analysis instruments in scientific research and practice. It is widely applied in biomedical, chemical, environmental protection, and other fields. Manual reading and processing data with traditional ion analyzer is not only cumbersome in operation process but also difficult to avoid personal error. The research about ion analyzer connected to computer has been reported in recent years [6]; however, the quantity is small, and the software is mostly developed in text-based programming language (e.g., C, Turbo Pascal, VB, and so on). The disadvantage of the text-based language is long developing periods, difficult maintenance, and expandedness. The VI of ion analyzer based on LabVIEW has not been reported yet. The VI of ion analyzer developed by authors is developed in graphical programming language—LabVIEW 8.0. It not only has friendly interface, easy operation, and expandability, but also can realize automatic slope, temperature, and positioning calibrations. The system has been applied to determine the rate constant of ethyl acetate saponification reaction when the LabVIEW program for determining the reaction rate constant by pX is embedded into the system. The authors have obtained satisfactory results.


## 2. System Principles and Configuration

Actually, Ion analyzer, as a high input impedance millivoltmeter, is widely used in measuring the EMF of the battery which is composed by ion selective electrode, reference electrode, and solution. The concentration of the unknown solution is acquired through measuring the EMF margin between standard solution and tested solution under the same electrode system. By the Nernst equation the authors have inferred(1)Ex-Es=±2.303RTzF(pX-pXs),IfS=2.303RTzF,pX=pXs±(Ex-Es)S,
where Ex is the potential, and pX is the pX value of tested solution.It is obvious that the relation betweenpX and ΔE(ΔE=Ex-Es) is linear. S is theoretic slope of the electrode system; however, the actual electrode slope is also influenced by temperature, ion valence, manufacturing process, surface structure, activation state of the electrode, and other factors. Although the electrodes are of the same type, the S values of the electrodes may be different. It is why ion analyzer must be proofreaded by standard solution before being used. Traditional ion analyzer needs transform switches and rheostats to complete positioning, ion valence, polarity, electrode slope, and temperature calibrations for proofreading the instrument. In this condition, operators must read and process the data artificially during measurements. The virtual instrument system based on LabVIEW 8.0 for ion analyzer brings the advantage of virtual instrument that “software is instrument” into full play. It achieves proofreading the instrument and data processing automatically by LabVIEW program, so the authors can easily get real-time pX~tand mV~t curve.System structure of the virtual instrument is shown in Figure1. Ion selecting electrode and reference electrode are immersed into the tested solution constituting electrode system. The potential signal enters into computer via the PCI-6014 Data Acquisition (DAQ) after impedance transformation and filtering by high input impedance conditioning circuit. Precise digital temperature thermoscope connects the computer by RS-232 serial port which makes the automatical temperature compensation easily.Figure 1
The system structure of VI.The homemade conditioning circuit is shown in Figure2. It is made up of one high input impedance voltage follower with CA3140 and second-order active low-pass filter with low drift OP07. Specially the CA3140 is used to accomplish impedance transformation of electrode system, then the low drift OP07 accomplishes the output signal filtering.Figure 2
The condition circuit.


## 3. Design and Implementation of the Main LabVIEW Program for System

The system software consists of four main parts, including operation panel, data acquiring and real-time displaying, data storage, and data processing and result displaying. Thereinto, the former three parts of the system software are necessary, and the last one can be adjusted according to the purpose of users’ measurement.


### 3.1. Program for Operation Panel

Virtual instrument operation panel is shown in Figure3. To enable users to adjust sampling interval and channels according to their needs, sampling interval knob and channels selecting controller are set on the left of the panel. Users can also decide whether to save the date synchronously by synchronous memory controller or not. In this LabVIEW program, Event Structure which comprises data acquiring, data saving, data processing, result printing, and exit five subevents is used. Each subevent corresponds with a control button on the panel. When clicking the control button, corresponding event will be called. Operation panel adopts Tab Control on the whole to achieve the switch between mV stall and pX stall and connects Tab Control with Selection Terminal of a Case Structure on block panel. Clicking the mV stall and pX stall button on top of the operation panel can complete the switch between mV stall and pX stall easily.Figure 3
The operating panel.


### 3.2. Program for Data Acquiring and Real-time Displaying

Program for data acquiring and real-time displaying ofpX measurement is the key program of the system which can automatically complete temperature, slope, orientation, and ion valence correction. The program consists of a Stacked Sequence Structure, which includes seven frameworks. While the program is running the structure will gradually execute the framework program according to the order of selection for labels 0,1,2….Figure4 shows the block program of the last framework. It executes real-time acquiring anddisplaysthe pX value of the solution under test and data provisional storage, which is mainly constituted by three While Structure. The upmost While Structure accomplishes the driving of data acquisition card and data acquiring continuously. Channels selecting controller select channel, AI Config function sets up the size of buffer, AI Read function sets up sampling rate, and Max & Min function controls the amount lagging to avoid data coverage. To enhance the stability and veracity of the result, 300 acquired data will be switched to pX value after averaged and then real-time displayed by the control Meter and transmitted to the downmost While Structure by native variable to save. At the same time the textboxes on the right of the operation panel display pX value, electrode slope, mV, ion concentration of X, and other data. The While Structure in the middle real time acquires the temperature value of exact digital temperature thermoscope by the serial communication VI and then transmits it to the upmost While Structure by native variable to accomplish temperature compensation automatically. The temperature of solution is real-time displayed by the control Thermometer in the operation panel. The While Structure downmost writes the discrete pX value to file according to the sampling interval set by users and displays it in Express XY Graph. Because LabVIEW program adopts parallel operation mechanism, the three While Structure can run independently.Figure 4
Block program of data acquiring and real-time displaying.The program of mV stall is similar to this and simpler relatively; the only difference is real-time displays are potential~time curve.


### 3.3. Program for Date Storage

Its block program is shown in Figure5. First, open a file dialog box with the function File Open to offer the storage path for users. Then copy the data saved in provisional file to appointed file with the function Copy and superadd initial experiment conditions to the file which is saved for the use of data processing at the same time. If any failure during data storage, it will pop up invalid save and give error reasons to users, allowing users to save again until success.Figure 5
Block program of data storage.


## 3.1. Program for Operation Panel

Virtual instrument operation panel is shown in Figure3. To enable users to adjust sampling interval and channels according to their needs, sampling interval knob and channels selecting controller are set on the left of the panel. Users can also decide whether to save the date synchronously by synchronous memory controller or not. In this LabVIEW program, Event Structure which comprises data acquiring, data saving, data processing, result printing, and exit five subevents is used. Each subevent corresponds with a control button on the panel. When clicking the control button, corresponding event will be called. Operation panel adopts Tab Control on the whole to achieve the switch between mV stall and pX stall and connects Tab Control with Selection Terminal of a Case Structure on block panel. Clicking the mV stall and pX stall button on top of the operation panel can complete the switch between mV stall and pX stall easily.Figure 3
The operating panel.


## 3.2. Program for Data Acquiring and Real-time Displaying

Program for data acquiring and real-time displaying ofpX measurement is the key program of the system which can automatically complete temperature, slope, orientation, and ion valence correction. The program consists of a Stacked Sequence Structure, which includes seven frameworks. While the program is running the structure will gradually execute the framework program according to the order of selection for labels 0,1,2….Figure4 shows the block program of the last framework. It executes real-time acquiring anddisplaysthe pX value of the solution under test and data provisional storage, which is mainly constituted by three While Structure. The upmost While Structure accomplishes the driving of data acquisition card and data acquiring continuously. Channels selecting controller select channel, AI Config function sets up the size of buffer, AI Read function sets up sampling rate, and Max & Min function controls the amount lagging to avoid data coverage. To enhance the stability and veracity of the result, 300 acquired data will be switched to pX value after averaged and then real-time displayed by the control Meter and transmitted to the downmost While Structure by native variable to save. At the same time the textboxes on the right of the operation panel display pX value, electrode slope, mV, ion concentration of X, and other data. The While Structure in the middle real time acquires the temperature value of exact digital temperature thermoscope by the serial communication VI and then transmits it to the upmost While Structure by native variable to accomplish temperature compensation automatically. The temperature of solution is real-time displayed by the control Thermometer in the operation panel. The While Structure downmost writes the discrete pX value to file according to the sampling interval set by users and displays it in Express XY Graph. Because LabVIEW program adopts parallel operation mechanism, the three While Structure can run independently.Figure 4
Block program of data acquiring and real-time displaying.The program of mV stall is similar to this and simpler relatively; the only difference is real-time displays are potential~time curve.


## 3.3. Program for Date Storage

Its block program is shown in Figure5. First, open a file dialog box with the function File Open to offer the storage path for users. Then copy the data saved in provisional file to appointed file with the function Copy and superadd initial experiment conditions to the file which is saved for the use of data processing at the same time. If any failure during data storage, it will pop up invalid save and give error reasons to users, allowing users to save again until success.Figure 5
Block program of data storage.


## 4. Design and Implementation of Program for Data Progressing

### 4.1. Basic Principles of Determining Rate Constant by pX

The biggest advantage of virtual instrument is easy expandability, fully playing the powerful data processing function of computer to deal with the test data collected according to the programming needs of users. Basic principles of determining rate constant bypX are that the concentration of the participation in the reaction system changes over time with reaction proceeding, so tracking and recording a curve of pX with the change of time t, and then by corresponding data processing under the principle of dynamics the corresponding parameters of dynamics can be determined.For easy presentation, take a typical second-order reaction the reaction of ethyl acetate saponification as an example:(2)CH3COOC2H5+OH-→CH3COO-+C2H5OH.With reaction proceeding,OH- gradually diminishes, and CH3COO- gradually increases in the system, so the PH value of the system gradually reduces. The information of reaction course is obtained by determining the PH value with the time. So the rate constant of this reaction can be determined by the method of pX.For second-order reaction, data processing formulae are different for the equal and unequal initial concentration of reactants. In accordance with the principle of dynamics, according to [7–9], when the initialconcentrations of reactants are equal, setups of the initial concentration are both c0, then the dynamic formula for the reaction is
(3)1c=kt+1c0,
where c is the concentration of NaOH at the time t; k is rate constant, for strong base BOH, [OH-]≈cBOH, pOH=-log[OH-] when the concentration cBOH≥ 10-6 M. Integration yields:
(4)1c=1[OH-]=110-pOH=10pOH=1014-pH.
So we can educe the relationship formula between the pH value of the system and time as (5)
(5)1014-pH=kt+1c0.It shows that by plotting1014-pH against t, the slope of the line is rate constant, k.When the initial concentrations of reactants are unequal, setupsa,b(a>b)  are, respectively, the initial concentration of NaOH and CH3COOC2H5, then the concentration of each component of the reaction system at different reaction time can be expressed as
(6)CH3COOC2H5+NaOH→CH3COONa+C2H5OHt=0ba00t=tb-xat=a-xxxt=∞0a∞=a-bbb,
where at,a∞ are, respectively, the concentration of NaOH at the time of t and t=∞, and x is the concentration of product CH3COONa and C2H5OH at the time of t.Whena≠b the dynamic formula for second-order reaction is
(7)ln(a-x)(b-x)=(a-b)kt+lnab.
Because a-b=a∞,a-x=at,b-x=at-a∞,
(8)lnatat-a∞=a∞kt+lnab.
Set up [OH-]t,[OH-]∞ are [OH-] of the system at the time of t=t and t=∞, then obtain
(9)-ln(1-[OH-]∞[OH]t)=[OH-]∞kt+lnab.
Also because [OH-]=10pH-14, (5) can be expressed with pH value as
(10)-ln(1-10pH∞-1410pHt-14)=10pH∞-14kt+lnab.
Set up A=-ln(1-(10pH∞-14/10pHt-14)), then
(11)A=10pH∞-14kt+lnab.Equation (11) is the relationship formula between pH value and time, which shows that by plotting A against t a straight line is obtained, and after determining  [OH-]t,[OH-]∞ of the system at the time of t=t and t=∞ rate constant k can be obtained from the slope of the line.These methods do not require determining the accurate initial concentration of reactants, which simplifies the experimental operation. By Arrhenius equationln(k1/k2)=Ea(1/T2-1/T1)/R, the activation energy can be obtained by the rate constant of different temperature.


### 4.2. Program for Data Processing and Results Displaying

The block program is shown in Figure6. The corresponding program in the Sequence Structure on the far left firstly judges whether the initial concentration of reactant is equal, then chooses the corresponding data file which is waiting for processing. The program performs the corresponding subdiagram of Case Structure according to judging result. Data processing includes linear transforming of data, transforming the label of axis, straight line fitting, and correlation coefficient R calculating, and so forth. A group of data read out from data file enters For Loop structure, by using the Loop Iteration; the automatically matching of data of X axis and data of Y axis is achieved. The autoindex of For Loop makes the results to be an array. After this array enters subprogram for straight line fitting, the unqualified data is deleted and the line slope, intercept, and other data are obtained. A cluster array is produced by the function Build Array after the data “after deleted” and “the data after fitted” are, respectively, bundled by the function Bundle, and is displayed by the control XY Graph. At the same time, by using Xscale.NameLb1.Text and Yscale.NameLb1.Text in Property Node of graph and condition of initial concentration of reactant, the label of axis is automatically transformed with different beginning condition. Correlation coefficient of straight line fitting is obtained after the data enters subprogram for R. The system will remind users whether or not to continue data processing after a set of data is processed. Another data file will be selected if the user continues to obtain rate constant at different temperature. The k value at different temperature can be used to calculate apparent activation energy Ea by the function Formula Node in Case Structure on the far right. The results and necessary parameters are added into array by the function Insert Into Array. Then each element of array is indexed and transformed into specified precise characters by function Number To Fractional String. The characters are concatenated into a string by function of Concatenate Strings, and at last the string is displayed by String Indicator.Figure 6
Block program of data processing and results displaying.


## 4.1. Basic Principles of Determining Rate Constant by pX

The biggest advantage of virtual instrument is easy expandability, fully playing the powerful data processing function of computer to deal with the test data collected according to the programming needs of users. Basic principles of determining rate constant bypX are that the concentration of the participation in the reaction system changes over time with reaction proceeding, so tracking and recording a curve of pX with the change of time t, and then by corresponding data processing under the principle of dynamics the corresponding parameters of dynamics can be determined.For easy presentation, take a typical second-order reaction the reaction of ethyl acetate saponification as an example:(2)CH3COOC2H5+OH-→CH3COO-+C2H5OH.With reaction proceeding,OH- gradually diminishes, and CH3COO- gradually increases in the system, so the PH value of the system gradually reduces. The information of reaction course is obtained by determining the PH value with the time. So the rate constant of this reaction can be determined by the method of pX.For second-order reaction, data processing formulae are different for the equal and unequal initial concentration of reactants. In accordance with the principle of dynamics, according to [7–9], when the initialconcentrations of reactants are equal, setups of the initial concentration are both c0, then the dynamic formula for the reaction is
(3)1c=kt+1c0,
where c is the concentration of NaOH at the time t; k is rate constant, for strong base BOH, [OH-]≈cBOH, pOH=-log[OH-] when the concentration cBOH≥ 10-6 M. Integration yields:
(4)1c=1[OH-]=110-pOH=10pOH=1014-pH.
So we can educe the relationship formula between the pH value of the system and time as (5)
(5)1014-pH=kt+1c0.It shows that by plotting1014-pH against t, the slope of the line is rate constant, k.When the initial concentrations of reactants are unequal, setupsa,b(a>b)  are, respectively, the initial concentration of NaOH and CH3COOC2H5, then the concentration of each component of the reaction system at different reaction time can be expressed as
(6)CH3COOC2H5+NaOH→CH3COONa+C2H5OHt=0ba00t=tb-xat=a-xxxt=∞0a∞=a-bbb,
where at,a∞ are, respectively, the concentration of NaOH at the time of t and t=∞, and x is the concentration of product CH3COONa and C2H5OH at the time of t.Whena≠b the dynamic formula for second-order reaction is
(7)ln(a-x)(b-x)=(a-b)kt+lnab.
Because a-b=a∞,a-x=at,b-x=at-a∞,
(8)lnatat-a∞=a∞kt+lnab.
Set up [OH-]t,[OH-]∞ are [OH-] of the system at the time of t=t and t=∞, then obtain
(9)-ln(1-[OH-]∞[OH]t)=[OH-]∞kt+lnab.
Also because [OH-]=10pH-14, (5) can be expressed with pH value as
(10)-ln(1-10pH∞-1410pHt-14)=10pH∞-14kt+lnab.
Set up A=-ln(1-(10pH∞-14/10pHt-14)), then
(11)A=10pH∞-14kt+lnab.Equation (11) is the relationship formula between pH value and time, which shows that by plotting A against t a straight line is obtained, and after determining  [OH-]t,[OH-]∞ of the system at the time of t=t and t=∞ rate constant k can be obtained from the slope of the line.These methods do not require determining the accurate initial concentration of reactants, which simplifies the experimental operation. By Arrhenius equationln(k1/k2)=Ea(1/T2-1/T1)/R, the activation energy can be obtained by the rate constant of different temperature.


## 4.2. Program for Data Processing and Results Displaying

The block program is shown in Figure6. The corresponding program in the Sequence Structure on the far left firstly judges whether the initial concentration of reactant is equal, then chooses the corresponding data file which is waiting for processing. The program performs the corresponding subdiagram of Case Structure according to judging result. Data processing includes linear transforming of data, transforming the label of axis, straight line fitting, and correlation coefficient R calculating, and so forth. A group of data read out from data file enters For Loop structure, by using the Loop Iteration; the automatically matching of data of X axis and data of Y axis is achieved. The autoindex of For Loop makes the results to be an array. After this array enters subprogram for straight line fitting, the unqualified data is deleted and the line slope, intercept, and other data are obtained. A cluster array is produced by the function Build Array after the data “after deleted” and “the data after fitted” are, respectively, bundled by the function Bundle, and is displayed by the control XY Graph. At the same time, by using Xscale.NameLb1.Text and Yscale.NameLb1.Text in Property Node of graph and condition of initial concentration of reactant, the label of axis is automatically transformed with different beginning condition. Correlation coefficient of straight line fitting is obtained after the data enters subprogram for R. The system will remind users whether or not to continue data processing after a set of data is processed. Another data file will be selected if the user continues to obtain rate constant at different temperature. The k value at different temperature can be used to calculate apparent activation energy Ea by the function Formula Node in Case Structure on the far right. The results and necessary parameters are added into array by the function Insert Into Array. Then each element of array is indexed and transformed into specified precise characters by function Number To Fractional String. The characters are concatenated into a string by function of Concatenate Strings, and at last the string is displayed by String Indicator.Figure 6
Block program of data processing and results displaying.


## 5. Example of Application

This system is used to determine the rate constant of ethyl acetate saponification reaction at the temperature of 298 K and 308 K when the initial concentration of reactants is equal and unequal. In the measuring process the system automatically collects testing data and real-time displayspH~t curve, as shown in Figure 3. It also automatically processes testing data and generates the report of result. Figure 7 is the data processing panel under equal initial reactants concentration, and the two XY Graphs on each side, respectively, display testing data at the temperature of 298 K and 308 K. The underside of panel is a testing conditions and results showing box which can display reaction temperature, rate constant, correlation coefficient, and apparent activation energy together. Relevant data of test is shown in Table 1.Table 1
The data and results of test. Notes:a is the concentration of NaOH; b is the concentration of CH3COOC2H5.
c0/mol·dm-3T/Kk/dm3·mol-1·min-1δ%Ea/kJ·mol-1δ%abExperimentalReference [10, 11]Experi-mentalReference [12]0.04900.04902986.8646.850.2033.4833.390.270.04900.049030810.64310.501.360.02450.01962986.9266.851.1134.142.250.02450.019630810.83410.503.18Figure 7
The panel of data processing ata=b.


## 6. Conclusion

The virtual instrument system based on Labview8.0 for ion analyzer, which has advantages of easy operation and friendly interface, can determinepX, realize real-time displaying and drawing a curve of pX or mV with the change of time t, process data, and generate result report automatically. The relative error of result is less than 3.5%. For any second-order reaction system, the virtual instrument system can track the concentration change of the corresponding ion and then determine its rate constant if appropriate ion-selective electrode is used. For other series of reactions, the system can also determine their rate constants by amending data-processing program under the principle of dynamics. With its easy expandability, the system can be used in autodetermination studies such as potential titration, potential analysis, and potential equilibrium constant measurement through embeding different data-processing programs of LabVIEW. What is more, the system provides users with great convenience for tracking and measuring pX or potential application research; the authors believe that it can be widely used in the production and environmental monitoring.



---

*Source: 849704-2009-08-31.xml*