Operation and Ph Control of A Wastewater Treatment Unit Using Labview

LABVIEW is a powerful and versatile graphical programming language that had its roots in operation, automation control and data acquisition of the system. The pH control system of a non-linear wastewater treatment unit, contains heavy metals (Cu, Cr, Cd, Fe, Ni and Zn), had been developed depending on dynamics behavior of the process. The pH value of wastewater is change by addition chemicals (lime or Na 2 S). The semi-batch pH process system dynamically behaved as a first order lag with dead time. The tuning of control parameters was carried by several methods; Internal Model Control (IMC), Minimum (ITAE) criteria and Adaptive mode. Since the process was fast, the Integral of Absolute of Error (IAE) criteria was used to compare between the above tuning methods. Adaptive control was the best and effective to determining the values of proportional gain (Kc), Integral time constant ( t I ) and Derivative time constant ( t D ).PI mode was found to be the best for control the fast pH process.

PDF created with pdfFactory Pro trial version www.pdffactory.com

Introduction
Wastewater from metal finishing industries contains contaminants such as heavy metals, organic substances, cyanides and suspended solids at levels, which are hazardous to the environment and pose potential health risks to the public.Heavy metals, in particular, are of great concern because of their toxicity to human and other biological life.Heavy metal typically present in metal finishing wastewater are; cadmium, chromium, copper, iron, zinc …etc (Sultan, 1998) [1] .
Conventionally, metal finishing waste streams are treated by chemical means and the quality of treated effluents much meets discharge standards.Several methods are used for the wastewater treatment plants such as; membranes, adsorption process and electro-chemical treatment.For large scale and industrial application, the technique used in the convention treatment of wastewater involves precipitation of heavy metals flocculation, settling and discharge.The treatment requires adjustment of pH as well as the addition of chemicals (acid and caustic … etc).
pH is monitored and controlled by manipulating a base stream, which is usually a solution of a lime or sodium sulfide.Modern treatment plants involve physical and chemical precipitation where maintenance of pH is the key factor for efficient treatment.Most of the process uses a pH sensor (glass electrode) as the online measuring for control (Chaudhuri, 2006) [2] .
The pH is a measure of acidy or alkalinity of a solution.It plays an important role in determining treatment efficiency.Effective metal removal by sulfide or hydroxide precipitation requires that the pH of the wastewater be controlled within the neutral to slightly alkaline range (Anast et al, 1995, March et al, 2002  and EPA 2005)  [3,4,5] .
The combination of hydroxide and sulfide precipitation for optimal metals removal is being well considered, a common configuration is a two-stage process in which hydroxide precipitation is followed by sulfide precipitation with each stage followed by a separate solids removal step.This will produce high quality effluent of the sulfide precipitation process while significantly reducing the volume of sludge generated and the consumption of sulfide reagent (EPA, 1998) [7] .
The treatment process includes the following steps: 1. Adjustment of pH. 2. Reaction of heavy metals ions with hydroxide or sulfide.

Precipitation of sludge.
Typically, the solubilities of most metal precipitation decrease with increasing pH to a minimum value (termed the isoelectric point beyond which the precipitation became more soluble, owing to their amphoteric (soluble in both acidic and basic solutions) properties (EPA, 2005) [5] .
Precipitation and solubility curves of heavy metals for hydroxide and sulfide process are showed in Figures (1 & 2).Concentrations of heavy metals are a function of pH.
LABVIEW is a graphical programming language that has its roots in automation control and data acquisition (Canete et al, 2008) [6] .
In the present work, the LABVIEW technique is used to operate and control the pH of the semi-batch neutralization process of PDF created with pdfFactory Pro trial version www.pdffactory.comtreatment unit automatically by online digital computer.

Dynamics and Control of pH system Dynamic Characteristics of the Process
It is difficult to formulate and identify a mathematical model for the pH process as small as amount of polluting element will change the process dynamics considerably (Shinskey, 1973) [8] .
(Henson and dale, 1994) [9] have proposed the dynamic model of the continuous pH system using conservation equations and equilibrium relations.Modelling assumptions include perfect mixing, constant density and complete solubility of the ions involved.The linearized model is: Where; K: Process gain U: Input feed rate τ: Time constant So that, the transfer functions of the single stage becomes Therefore, the dynamic model of the signal stage of pH process is a first order lag system.

pH Control
For industrial application, it is widely used on-line and PID control for control the pH of a wastewater treatment plants.The on-off type is used where the holdup time constant (time lag) of the process is high (more than 10 minutes).But where hold up time is relatively short, multimode (PID) control is applicable (Emerson, 2004)  [10] .
(Chaudhuri, 2006) [2] studied the pH control in a neutralization process.Attempts had been made to correlate pH of the mixing process based on fundamental laws of titration under dynamic conditions and four control logics, namely, Model Predicted Control (MPC), Modified Linear control (MLC), Artificial Neural Network Control (ANN) and Fuzzy Logic Control (FLC) had been developed.PID control model was the fastest one among the other control models as far as the rise time is concerned.

Tuning Controllers with Empirical Relations
Empirical tuning roughly involves doing either an open loop or a closed-loop experiment, and fitting the response to a model (Chau, 2001) [11] .The controller gains are calculated based on this fitted function and some empirical relations.When empirical tuning relations were used, system dynamic response specifications cannot be dictated.The controller settings are seldom optimal and most often require field tuning after installation to meet more precise dynamic response specifications.Empirical tuning may not be appealing from a theoretical viewpoint, but it gives a quick-and dirty starting point.
Most empirical tuning relations that used here are based on open loop data fitted to a first order with dead time transfer function.This feature is unique to process engineering where most units are self-regulating.The dead time is either an approximation of multi-stage processes or a result of transport lag in the measurement.With large uncertainties and the need for field tuning, models more elaborate than the first order with PDF created with pdfFactory Pro trial version www.pdffactory.comdead time function are usually not warranted with empirical tuning.
Adaptive is called a control system, which can adjust its parameters automatically in such a way as to compensate for variations in the characteristics of the process it controls.The various types of adaptive control systems differ only in the way the parameters of the control are adjusted (Stephanopoulos, 1984) [12] .
There are two main reasons to use the adaptive controllers in chemical process.First, most chemical processes are non-linear.Therefore, the linearized models that are used to design linear controllers depend on the particular steady state (around which the process is linearized).Second, most of the chemical processes are nonstationary (i.e.their characteristic change with time).
In the present work, the process reaction curve method was used while the Adaptive control, Internal Model Control (IMC) and Integral of Time-Weight Absolute Error (ITAE) were used to obtain the optimum settings (Kc,τ I & τ D ) of controller.Since the process was very fast the Integral absolute Error (IAE) criteria was used to determine the controllability of tuning methods.

Labview Technique
LABVIEW (Laboratory Virtual Instrument Engineering Workbench) is a powerful and versatile graphical programming environment that was developed primarily to facilitate instrumentation control, data acquisition and analysis (Bishop,  2004)  [13] .Applications created with LABVIEW are referred to as virtual instruments (VIs) created as block diagrams.
Input and output interfacing with the VI is performed in another window called front panel.The graphical icon based source code and interfacing creates very userfriendly application and eliminates typing in lengthy character-base code.Besides, LABEVIEW enables to interface dried environment has been applied to a wide variety of control problems such as bioprocess control (Zeng et al, 2006) [14] and thermal system control (Lin & Yin, 2007) [15] .
From previous work (at this time), the LABVIEW technique was limited used for operation and control of water treatment plant.In the present work, the LABVIEW program (version 8.2) was designed to operate and control the experimental date are collecting and plotting directly by on-line digital computer (Figure 3 & 4).

Benefit of Using LABVIEW in Scientific Research
The many benefits of using an integrated development environment and programming language such as LABVIEW in academic research and scientific computing applications include the following: [13] ü  5) was designed and constructed into the best way to simulate the real process and collect the desirable data.
The specifications of the main parts of the system are: A.
Treatment (precipitation) tanks with size of two litres for each cylindrical type with lower conical shape are made of polypropylene plastic (anti-chemical corrosion).

5.
Chemical containers (cylindrical type) with size of 0.5 litres for each made of resist glass anti-chemical corrosion.6.
Sand filter is made of polypropylene (transparent) with size of two litres.2/3 of container volume is occupied with the adsorbent fine sand.
The piping, manual valves and fittings which sized from 1/8 to 1/4 inches which are made of polyethylene plastic which resist the chemical corrosion.B.
Control Hardware The block diagram of control hardware components illustrated in Figure 4 which are: 1.

2.
Control valve (electronicmotorised-Equal percentage type) with 2-way which is normally closed type and manufactured by (GF-GmbH Germany).All contact area to chemical solutions is made of Teflon plastic.The input signals (0-12 Volts D.C).The time response of the valve is 6 seconds (from fully closed to fully open).3.
Interface system (type PCI 5500 MF) manufactured by (Data Translation company, Ecan series).High speed, 8 channels multiplexed 12-bit analogy to digital converter with 16 digital I/O lines and 2 counters / 2 timers for compatibles, which is digitally calibrated.The acquisition rate is 100 KHZ (max) and the full scale of A/D is (0-10 V).The gain error is adjustable to zero.The temperature range of operation is (0-55) o C. 4.
Input/Output signal process is designed and constructed using the desirable instrumentation amplifier (AD-524), noise filter and transducer to amplifier the signals from millivolts to volts to reject any undesirable noise from input signal.The transducer is used to convert the low voltage 10 volts to 220 volts.6.
Laptop computer ( hp-6735) is connected to operate and control the system.
All connection wires are used which type of coaxial wire to prevent any undesirable noise from surrounding to desirable the signal of process variables.

Experimental Procedure
The experimental runs are achieved automatically by on-line digital computer as follows: Normal operation 1.

2.
When the starting conditions reach the steady state (pH 7 and 25 o C), the experimental run then started automatically by computer with the aid of the LABVIEW program.

3.
The manual valves V1 & V2 are opened while the others are closed.Adjust the mixer1 at 15 rps to obtain well-mixed, dosing pump at 0.45 cc/sec and control valve (fully closed), Starting the system by digital computer.When the system reaches the desired values of wastewater (pH 8), then it is shutdown automatically.4.
After the reaction of heavy metals ion with hydroxide is obtained and the sludge is precipated (above one hour).The evacuated pump 1 is operated to draw clear water from tank 1 and fill tank 2.

5.
pH of wastewater into tank 2 is neutral or slightly alkaline.The manual valves V2 & V4 are opened while the others are closed.Adjust the mixers, deposing pump and control valve at desired value similar as in procedure (3) then the system is operated automatically by digital computer.The system is shutdown automatically when reached to the desired value of (pH 9). 6.
Since Na 2 S solution is more reactive with metal ions than hydroxide, the reaction and precipitation processes are achieved at interval time of 45 minutes.The evacuated pump 2 draw the clear water from tank 2 and flow through sand filter then to drain.Dynamic (Open Loop) 1.
Connecting directly the dosing pump to storage tank of Ca(OH) 2 solution, i.e., by pass the control valve.

2.
Repeating the operating of tank 1 with Ca(OH) 2 solution as previously explained.The controller's parameters (Kc, τ I & τ D ) are adjusted to zero.

3.
Creating 10% step change in inlet flow rate of hydroxide by the manual valve V3.

4.
When reaching the desired value (pH 7.8), the system is automatically shutdown.

5.
Recording & plotting the pH of water into tank as function of time.
The interval sampling time is selected as one second since the process is very fast.The above steps are repeated when using the Na 2 S solution as chemical reagent.

Closed Loop 1.
Selecting the values of controller's parameters (Kc, τ I & τ D ) by directly tuning the desired knobs in the front panel which appeared on the monitor.
PDF created with pdfFactory Pro trial version www.pdffactory.com

2.
Ready tank 1 with wastewater initial conditions of pH 7 and 25 o C.

3.
By servo technique (10 % step change in set value 0.8 pH).It is desirable to select step change below one unit (nonlinear pH process).4.
Starting the system by LABVIEW program. 5.
Recording & plotting the pH, error and controller action responses directly by the computer.
The residual concentration of heavy metals into tanks 1 & 2 can be obtained either from Figures (1 & 2).The tuning of controllers, desired values can be done directly through the virtual panel on the computer monitor.In addition, the response curves of pH, error and controller action are plotted on the computer.

Dynamics Characteristic
In the present work, the dynamics characteristics of the pH process was studied without precipitation using process reaction curve under conditions of isothermal and complete solubility of the ions.The pH process was to be considered as a semi batch process with fast reaction and the pH response yield sigmoidal shape curve (Chaudhur, 2006) [2] .Precipitation was poorly known phenomenon and it was difficult to derive an accurate model (Barraud et al, 2009) [16] .
The semi batch pH system is a nonlinear unsteady state process, which have several steady state (equilibrium) points at each interval of time due to the change of the tank hold up.
The input (manipulated) variable was the flow rate (F) of alkaline while the pH of water was the output (controlled) variable.G v (s) = …(7) From Equations (4 & 5), the process tanks are dynamically behaved as a first order lag system with dead time (Barraud et al, 2009) [16] .The dynamics parameters (K, τ &t d ) are approximately similar for hydroxide and sulfide process due to the same operating condition.Dead time for both systems (G p1 & G p2 ) were because of combining; pHelectrode lag, computer interface lag and bad mixing.The dynamic lags of the process caused sluggish control.
Actually, the pH system could be dynamically described as a multicapacitance system.Two systems in series first represented the mixing tank as a first lag system and the second was the pH-electrode, which was almost first lag (Equation 6) system.Since the time lag of pHelectrode was small (one second) when compared to that of the process (5-6) seconds, then the system could be considered approximately as the PDF created with pdfFactory Pro trial version www.pdffactory.comfirst order lag system with dead time (Equations 4 & 5).
The dynamics parameters (K, τ & t d ) are functions of tanks dimensions and operating variables (flow rate, mixing and speed …etc).These parameters are very important to obtain the optimum settings of the PID control by various methods.
Since the system was unsteady state semi-batch process, so that the dynamics characteristic could be varied with time.It is difficult to be determined theoretically.

Digital Control System
The digital PID control with the aid of the LABVIEW program was used for several modes of PID algorithms.For PI (Equations 8 & 9) and PID (Equations 10 & 11) control modes, which were the so-called velocity forms (Stephanopoulos,  1984)  [12] .pH n = k c ….. (8)   pH n-1 = k c ..( 9) In these forms, one did not compute the actual value of the controller output signal at the nth sampling instate, but its change from the preceding period.
The optimum values of controllers (Tables 3 & 4) used as a starting values and then with the adaptive (self-tuning) of the PID numbers using IAE method until founding the new set that worked the process very well using aid of the MATLAB computer program (Appendix).The performance of a tuned PID with IMC and ITAE parameters was not satisfactory due to nonlinear characteristic of the process (Salehi et al, 2009) [17] .
Figure (7) shows the responses of the process with proportional logic.Since the time lag of the closed loop, system was less than that of the open loop, so that the response speed of the closed loop was faster than that on the open loop.The increasing of the controller gain (Kc) from 0.2 to 1.0 tends to increase the response speed and decrease the deviation (offset) with the desired value (pH 0.8).Oscillation was not appeared in the response at maximum value of (Kc=1.0)due to the nature of the process which always increased the pH (batch titration) of the system.The form of the closed loop responses confirmed that the precipitation tanks was dynamically first order lag system.
Integral mode advances the controller output by an amount determined by the magnitude and length of the time of the deviation in the process variable and, thus, eliminates offset.The speed of pH responses with PI control was higher to reach the desired value than Pcontrol (Figure 8).The decreasing in integral time from 5.0 to 0.5 second would decrease the maximum deviation and period.The system behaved as a second order (overdamped) and the best value of τ I is less than (1/10) t d (Shinskey, 1979) [18] .The oscillation was not appear with PI control since the pH response represented the build up of alkaline (Ca(OH) 2 or Na 2 S) concentration which always increased and no acidic reagent was added to reduce the pH and then to give oscillation form to PDF created with pdfFactory Pro trial version www.pdffactory.comthe responses of pH.PI control is the effective mode used in the present pH process (Figures 8 & 12).
Derivative action is generally used when the process has large number of time lag (Pollard, 1981) [19] .The time constant of the closed loop system was greater than that of the open loop, so that the control action response was slow compared with the open loop response.The derivative mode was highly sensitive to mixing noise (Figures 9-a & 9-b).The present process dynamically was still behaved as a first order lag system with PD control and the undesirable oscillation was appeared at derivative time constant greater than 0.5 second.The best value of τ D was equal to (1/10) of t d .Dead time is the dynamic element principally responsible for limiting controllability.The allowable mode settings and speed of response of the loop are directly related to the value of the dead time (Shinskey, 1979)  [18] .
The derivative action increased the proportional gain (Kc) which possible producing excessive oscillation.However, the PD control was not suitable for the present process due to small time lag, time delay and mixing noise.
For PID control (Figures 10 &  11) the maximum deviation was reduced, increased the stability and the offset was eliminated.The speed of PID response increased as the integral time constant ( τ I ) decreased (Figure 11).The effect of derivative time constant (τ D ) was not appearing so that it was neglected.The IMC method is better than ITAE criteria, since the IMC technique makes the system less oscillator and less settling time (Figure 10 and Tables 3 & 4).Adaptive tuning was the best and effective then IMC and ITAE techniques as shown in Table (3 & 4) and Figures (8 and 11)  Generally, the feedback control is satisfactory for the present process since the pH process was fast and dead time was small.PI mode is the fast and with low deviation (Salehi et  al, 2009 and Barraud et al, 2009) [16,17]   among the others control schemes (Figure 12 and Tables 3 &  4).
The system operated under stable conditions for various modes of the controller except PD control as shown in Figures (7 to 12). Conclusions

1.
LABVIEW was the powerful and versatile programming language for operate and control the wastewater treatment system.2.
On-line process reaction curve was more accurate to derive the dynamic model of the nonlinear unsteady state pH process.

3.
The pH process was dynamically behaved as a first order lag system with dead time.4.
Since the process was nonlinear, the optimum controller settings, which were obtained by the Adaptive mode, were more effective than that which was obtained by IMC method and ITAE criteria.Dead time of the process was responsible for limiting the controllers' settings.5.
Since the pH process was fast, PI mode was better than P and PID controllers were PD control was undesirable in the present system.6. P, PI, and PID modes get the stability conditions to the system, while PD control introduced instability behavior as a result of the noisy mixing.PDF created with pdfFactory Pro trial version www.pdffactory.com .
According to Figures (6-a & 6b), the transfer function of hydroxide process tank had the form as the followingof the instruments, the transfer functions of pH electrode and control valve are: G m (s) = ….(6)

Figure
Figure(6-b): Open Loop Response Against +ve 10% Step Change in Na 2 S Flow Rate Solution.

Figure ( 11 )
Figure (11): pH Response for PID-Control for Various Values of τ I .

Table ( 1) Tuning Relations Based on IMC
References[1] Sultan, I. A., "Treating Metal Finishing Wastewater ", A Quachem PDF created with pdfFactory Pro trial version www.pdffactory.com PID PDF created with pdfFactory Pro trial version www.pdffactory.comEng.& Tech.

Journal, Vol.28, No.17, 2010 Operation and Ph Control of a Wastewater Treatment Unit Using Labview 5537 Table (2) Tuning Relations Based on ITAE For Set Point Change
PDF created with pdfFactory Pro trial version www.pdffactory.com