Int. J. of Computers, Communications & Control, ISSN 1841-9836, E-ISSN 1841-9844 Vol. VI (2011), No. 2 (June), pp. 367-374 Digital Control of a Waste Water Treatment Plant R. Vilanova, J.D. Rojas, V.M. Alfaro Ramón Vilanova, José David Rojas Department de Telecomunicació i Enginyeria de Sistemes Universitat Autònoma de Barcelona 08193, Bellaterra, Spain, E-mail: ramon.vilanova@uab.cat, josedavid.rojas@uab.cat Víctor M. Alfaro Escuela de Ingeniería Eléctrica Universidad de Costa Rica San José, 11501-2060 Costa Rica. E-mail: victor.alfaro@ucr.ac.cr Abstract: The Activated Sludge Process (ASP) is arguably the most popular bioprocess utilized in the treatment of polluted water. The ASP is described by means of a nonlinear model and results on a Two-Input Two-Output multi- variable system. In this paper a discrete time digital control is proposed where the design of a decentralized controller is faced. Local controllers are given the form of a Two-Degree-of-Freedom PI controller tuned using the data-driven Virtual-Reference Feedback tuning approach. Keywords: ASP, Process Control, PID, Data-Driven Control, VRFT. 1 Introduction Water pollution represents one of the most serious environmental problems due to the dis- charge of nutrients into receiving waters. Hence, stricter standards for the operation of wastew- ater treatment plants (WWTPs) have been imposed by authorities. In order to meet these standards, improved control of WWTPs is needed. Wastewater treatment control has begun a gradual progress towards the use of more advanced technology, in the face of more stringent modern water quality standards. Several approaches have been reported in the literature that attempt to control the WWTPs process. Among others, the Activated Sludge Process (ASP) is arguably the most popular bioprocess utilized in the treatment of polluted water, using microor- ganisms present within the treatment plant in the biological oxidation of the wastewater. The simplified but still realistic and highly non-linear four-state multivariable model considered here is the ASP as presented in [1]. The ASP is described by means of a nonlinear model and results on a Two-Input Two-Output (TITO) multivariable system. In this paper a discrete time digital control is proposed where the design of a decentralized controller is faced. The paper designs the local controllers as discrete time Proportional-Integral (PI) controllers. The controllers are synthesized using the Virtual Reference Feedback Tuning, which is a model-free based approach where just purely data taken from the system is considered, therefore there is no need for a mathematical model of the system. On the basis of these data the discrete time PI controllers are tuned. 2 The two-degree-of-freedom Virtual Reference Feedback Tuning The Virtual Reference Feedback Tuning (VRFT) is a one-shot data-based method for the design of feedback controllers. The original idea was presented in [2], and then formalized by Copyright c⃝ 2006-2011 by CCC Publications 368 R. Vilanova, J.D. Rojas, V.M. Alfaro r + + + − Cr(θr) P d y Cy(θy) Figure 1: Two degrees of freedom structure Lecchini, Campi and Savaresi (see [3–5]). In this section, an outline of the two-degree-of-freedom case is presented. The design methodology is presented in [5], the control structure is presented in Fig. 1. The objective of this method is to minimize the criterion in (1). JMR(θr, θy) = ∥(ΨM(z; [θr, θy]) − M(z))WM(z)∥ 2 2 + ∥(ΨS(z; θy) − S(z))Ws(z)∥ 2 2 (1) with ΨM(z; [θr, θy]) = P(z)Cr(z; θr) 1 + P(z)Cy(z; θy) ΨS(z; θy) = 1 1 + P(z)Cy(z; θy) (2) and M(z) being the target input-to-output transfer function and S(z) the target sensitivity function. In the VRFT framework a plant model is not available, and is not intended to find one. Instead, a batch of input/output data is taken from an experiment on the plant (namely input u(t) and output y(t)). So, in order to find the parameters of the controllers (θr and θy) the signals r̄(t), d̄(t) and ȳ(t) are defined. These signals are called “virtual” because they are not really measured, but constructed from the input/output data available and the desired closed-loop relations as follows: • r̄(t) is the virtual reference, so that y(t) = M(z)r̄(t) • d̄(t) is the virtual perturbation, so that y(t) + d̄(t) = S(z)d̄(t) • ȳ(t) is the virtual-perturbed output of the plant, so that ȳ(t) = y(t) + d̄(t) This signals are the ones that would be found if u(t) and y(t) had been measured in closed-loop and if the closed-loop dynamics were given by M and S i.e., if the perfect controllers were set in the loop. On the basis of these “virtual” signals the controller’s parameters are found by minimizing the following alternative identification cost function: JNV R(θr, θy) = 1 N N∑ t=1 [ΓM(t; [θr, θy])] 2 + 1 N N∑ t=1 [ΓS(t; [θr, θy])] 2 where ΓM(t; [θr, θy]) = LM(z)(u(t) − Cr(z; θr)r̄(t) + Cy(z; θy)y(t)) (3) ΓS(t; [θr, θy]) = LS(z)(u(t) + Cy(z; θy)ȳ(t)) (4) and LM(z) and LS(z) are appropriate filters to be chosen so (3) becomes an approximation to (1). If the controllers are linear in the parameter (Cr(z; θr) = βr(z)T θr and Cy(z; θy) = βy(z)T θy) the cost criterion (3) becomes a standard quadratic optimization problem. In [5] the authors use the Digital Control of a Waste Water Treatment Plant 369 concept of “ideal controller” to derive the structure of filters LM and LS. The ideal controllers Cr0 and Cy0 are the ones that, if used in the control loop, would solve (1) exactly, that is Cy0 = 1 − S SP Cr0 = M SP (5) When comparing (1) and (3) using the Parseval Theorem the expression of the filters LM and LS that must make the identification problem (3) match the control problem (1) are found to be: |LM|2 = |M|2|S|2|WM|2 1 Φu |LS|2 = |S − 1|2|S|2|WS|2 1 Φu (6) 3 2-DoF PI structure for the VRFT In order to apply the VRFT framework to the Activated Sludge Process, the structure of the controllers has to be decided before the optimization is carried out. In [6], a decentralized PI structure is used in the same plant with good results for both, reference tracking and disturbance rejection. In this paper, a discretized version of the PI controller is used as the chosen structure for the VRFT controllers. Using a two-degree-of-freedom PI as in Fig. 1, the continuous time version of the controller is: Cr(s) = Kc ( β + 1 Tis ) Cy(s) = Kc ( 1 + 1 Tis ) (7) When applying the bilinear transformation s = 2 Ts z−1 z+1 , the controllers are Cr(z) = Kc ( β + Ts 2Ti ) + Kc ( Ts 2Ti − β ) z−1 1 − z−1 (8) Cy(z) = Kc ( 1 + Ts 2Ti ) + Kc ( Ts 2Ti − 1 ) z−1 1 − z−1 (9) From the VRFT point of view, (8) and (9) can be seen simply as linear-in-the-parameters con- trollers with two parameters as follows: Cr(z) = α1 + α2z −1 1 − z−1 Cy(z) = γ1 + γ2z −1 1 − z−1 (10) Since the continuous time controllers (7) have three adjustable parameters (Kc, Ti, β), one of the four parameters in its discrete time equivalent (10) should depend of the other three. From (8) to (10) it can be found that α1 + α2 = γ1 + γ2 = KcTs Ti (11) and we have that γ2 = α1 + α2 − γ1 (12) Then the discrete time controllers (10) are now Cr(z) = α1 + α2z −1 1 − z−1 Cy(z) = γ1 + (α1 + α2 − γ1)z−1 1 − z−1 (13) 370 R. Vilanova, J.D. Rojas, V.M. Alfaro Once the parameters of the controllers (13) (α1, α2, γ1) are found, one can recuperate the PI (7) parameters using: Kc = γ1 − 1 2 (α1 + α2) (14) Ti = Ts γ1 − 12 (α1 + α2) α1 + α2 (15) β = α1 − 12 (α1 + α2) γ1 − 12 (α1 + α2) (16) 4 Activated Sludge Process (ASP) Description The mathematical model considered in this paper is given in [1]. The ASP process comprises an aerator tank where microorganisms act on organic matter by biodegradation, and a settler where the solids are separated from the wastewater and recycled to the aerator. The layout is shown in Fig. 2. The component balance for the substrate, biomass, recycled biomass and dissolved oxygen provide the following set of non-linear differential equations: dX(t) dt = µ(t)X(t) − D(t)(1 + r)X(t) − rD(t)Xr(t) (17) dS(t) dt = − µ(t) Y X(t) − D(t)(1 + r)S(t) + D(t)Sin (18) dDO(t) dt = − Koµ(t) Y X(t) − D(t)(1 + r)DO(t) + KLa(DOs − DO(t)) + DO(t)DOin (19) dXr(t) dt = D(t)(1 + r)X(t) − D(t)(β + r)Xr(t) (20) µ(t) = µmax S(t) kS + S(t) DO(t) kDO + DO(t) (21) where X(t) - biomass, S(t) - substrate, DO(t) - dissolved oxygen, DOs - maximum dissolved oxygen, Xr(t) - recycled biomass, D(t) - dilution rate, Sin and DOin - substrate and dissolved oxygen concentrations in the influent, Y - biomass yield factor, µ - biomass growth rate, µmax - maximum specific growth rate, kS and kDO - saturation constants, KLa = αW - oxygen mass transfer coefficient, α - oxygen transfer rate, W - aeration rate, Ko - model constant, r and β - ratio of recycled and waste flow to the influent. The influent concentrations are set to Sin = 200 mg/l and DOin = 0.5 mg/l. With respect to the control problem definition, the waste water treatment process is considered under the assumption that the dissolved oxygen, DO(t), and substrate, X(t), are the controlled outputs of the plant, whereas the dilution rate, D(t), and aeration rate W(t) are the two manipulated variables. The initial conditions and kinetic parameters are taken as in [1] and [6]. 5 Discrete-time VRFT tuned PI controller applied to the ASP Using the non-linear model presented in (17) to (21), the data in Fig. 3(a) and Fig. 3(b) was collected. Using only this data without the information of the non-linear model, or any linear approximation, the parameters of the controller are calculated according to Section 2 using the PI structure specified in Section 3. The VRFT controllers are tested against two decentralized Digital Control of a Waste Water Treatment Plant 371 Figure 2: Activated Sludge Process layout. Taken from [7] 0 50 100 150 200 250 300 0 0.05 0.1 0.15 0.2 time(s) m g /l Dilution Rate 0 50 100 150 200 250 300 20 40 60 80 time(s) m g /l Substrate Data (a) Substrate-Dilution Rate loop 0 50 100 150 200 250 300 50 100 150 time(s) m g /l AirFlow Rate 0 50 100 150 200 250 300 2 4 6 8 time(s) m g /l Disolve Oxygen Data (b) Disolve Oxygen-AirFlow Rate loop Figure 3: Data used to find the VRFT controller PI controllers which parameters are computed using IMC [8], based on considering a First-Order (FO) controlled-process given by P(s) = Kp Ts + 1 (22) The identified models obey to K1 = 437.1 and T1 = 2.7h for the first loop and K2 = 0.03 and T2 = 0.51h for the second loop. These values are as in [6]. The controllers were discretized using the bilinear transformation (sampling time of 15min). In the case of the VRFT, the controllers are directly found in discrete time. The closed-loop specifications are given in terms of the desired time constants of the controlled system for each loop. The desired time constant of the Substrate- Dilution Rate loop is approximately T1 = 2.7h while the Dissolved Oxygen-Airflow Rate loop constant time is approximately T2 = 0.51h. The closed-loop constant time for each variable is giving in terms of the dimensionless variables τc1 and τc2 via Tc1 = τc1T1 and Tc2 = τc2T2. If, for example, τc1 < 1, the Substrate-Dilution Rate closed-loop is expected to be faster than in open loop. It is worth to note that for the VRFT tuning it is possible to specify a different time constant for the disturbance attenuation transfer function (in fact S(z)). In this case, the VRFT tuned PI controllers are found with a time constant for the corresponding S(z) transfer function that is half the one specified for the reference to output relation by using τc (therefore τc/2). If τc1 = τc2 = 1, the resulting controller parameters are Kc1 = 0.0023, Kc2 = 33.33, Ti1 = 2.7h and Ti2 = 0.51h for the IMC and Kc1 = 0.0042, Kc2 = 25.41, Ti1 = 3.43h, Ti2 = 0.42h, β1 = 0.6602 and β2 = 0.74 for the VRFT. The response to a change in the set points of both loops is giving in Fig. 4. The IAE value represents the Integrated Absolute Value of the Error. As it can be seen, the responses for the VRFT provide smaller IAE as well as less demanding control actuation, computed here as the Total Variation (TV) or the sum of the control movements from 372 R. Vilanova, J.D. Rojas, V.M. Alfaro 0 20 40 60 80 100 120 40 42 44 46 48 50 52 54 Time(h) m g /l Substrate, c1 = 1 Reference IMC, IAE: 24.284 VRFT, IAE: 15.6386 0 20 40 60 80 100 120 4 4.5 5 5.5 6 6.5 Time(h) m g /l Dissolve Oxygen, c2 = 1 Reference IMC, IAE: 0.95129 VRFT, IAE: 0.67543 0 20 40 60 80 100 120 0.08 0.085 0.09 0.095 0.1 0.105 0.11 0.115 Time(h) m g /l Dilution Rate, c1 = 1 IMC, TV: 0.03196 VRFT, TV: 0.034001 0 20 40 60 80 100 120 10 20 30 40 50 60 70 80 90 100 110 Time(h) m g /l AirFlow Rate, c2 = 1 IMC, TV: 58.5604 VRFT, TV: 45.0193 Figure 4: VRFT and IMC controllers responses to set-points step changes, τc1 = τc2 = 1 one sampling time to the other. In case the closed-loop bandwidth is increased and we set τc1 = τc2 = 0.5 the resulting controller parameters are Kc1 = 0.0046, Kc2 = 66.67, Ti1 = 2.7h and Ti2 = 0.51h for the IMC and Kc1 = 0.0065, Kc2 = 33.38, Ti1 = 2.68h, Ti2 = 0.35h, β1 = 0.7752 and β2 = 1.03 for the VRFT. In this case the IMC controller presents and undesirable oscillating behavior in the Dissolved Oxygen loop, as shown in Fig. 5. The output of the controllers was saturated to 0, in case it went below this value. Also the control effort of the second controller is quite lower in the case of the VRFT with a performance nearly 50% better. Also a simulation was carried out for a disturbance in the inflow concentration. The results are depicted in Fig. 6. Again the results are quite similar, and the multivariable characteristic is tackled in a satisfactory way. As it can be seen, this data driven methodology is suitable for the control of the ASP process and it allows to skip the modeling step in order to find a good controller. 6 Conclusions This paper has presented the application of a purely data based approach for tuning of discrete time PI controllers. The main advantage of the proposed method is that it does not rely on the usual linear model approximation of the system to be controlled. Just an experiment that provides input-output data from the system is needed. The performance of the tuning approach has been tested on a non-linear multivariable system and performance compared with that of the well known IMC method. As designed performance is more demanding, the resulting control system exhibits better results than its IMC counterpart. Digital Control of a Waste Water Treatment Plant 373 0 20 40 60 80 100 120 40 42 44 46 48 50 52 54 Time(h) m g /l Substrate, c1 = 0.5 Reference IMC, IAE: 12.8966 VRFT, IAE: 7.9997 0 20 40 60 80 100 120 3 3.5 4 4.5 5 5.5 6 6.5 Time(h) m g /l Dissolve Oxygen, c2 = 0.5 Reference IMC, IAE: 1.0949 VRFT, IAE: 0.59053 0 20 40 60 80 100 120 0.08 0.09 0.1 0.11 0.12 0.13 0.14 0.15 Time(h) m g /l Dilution Rate, c1 = 0.5 IMC, TV: 0.043395 VRFT, TV: 0.04601 0 20 40 60 80 100 120 0 20 40 60 80 100 120 Time(h) m g /l AirFlow Rate, c2 = 0.5 IMC, TV: 163.5215 VRFT, TV: 64.5191 Figure 5: VRFT and IMC controllers responses to set-points step changes, τc1 = τc2 = 0.5 0 20 40 60 80 100 120 40.6 40.8 41 41.2 41.4 41.6 41.8 42 42.2 42.4 42.6 Time(h) m g /l Substrate (Disturbance), c1 = 0.5 IMC, IAE: 24.7512 VRFT, IAE: 19.2922 0 20 40 60 80 100 120 6.108 6.11 6.112 6.114 6.116 6.118 6.12 6.122 6.124 Time(h) m g /l Dissolve Oxygen (Disturbance), c2 = 0.5 IMC, IAE: 0.093692 VRFT, IAE: 0.087208 0 20 40 60 80 100 120 0.072 0.074 0.076 0.078 0.08 0.082 0.084 Time(h) m g /l Dilution Rate (Disturbance), c1 = 0.5 IMC, TV: 0.043227 VRFT, TV: 0.046262 0 20 40 60 80 100 120 89.6 89.8 90 90.2 90.4 90.6 90.8 91 91.2 91.4 91.6 Time(h) m g /l AirFlow Rate (Disturbance), c2 = 0.5 IMC, TV: 25.757 VRFT, TV: 24.6659 Figure 6: Responses changing the specification for the VRFT and comparison with the IMC controller, τc1 = τc2 = 0.5 374 R. Vilanova, J.D. Rojas, V.M. Alfaro Acknowledgment This work has received financial support from the AECI-PCI program A/025100/09 and from the Spanish CICYT program under grant DPI2007-63356. Research work by J.D. Rojas has received financial support from the Universitat Autònoma de Barcelona. Support from the Universidad de Costa Rica is greatly appreciated. Bibliography [1] F. Nejjari, A. Benhammou, B. Dahhou, and G. Roux, “Non-linear multivariable adaptive control of an activated sludge wastewater treatment process,” Int. J. Adapt. Control Signal Process., pp. 347–365, 1999. [2] G. Guardabassi and S. Savaresi, “Virtual reference direct design method: an off-line approach to data-based control system design,” Automatic Control, IEEE Transactions on, vol. 45, pp. 954–959, May 2000. [3] M. C. Campi, A. Lecchini, and S. M. Savaresi, “Virtual reference feedback tuning: a direct method for the design of feedback controllers,” Automatica, vol. 38, no. 8, pp. 1337 – 1346, 2002. [4] A. Lecchini, M. Campi, and S. Savaresi, “Sensitivity shaping via virtual reference feedback tuning,” in Decision and Control, 2001. Proceedings of the 40th IEEE Conference on, vol. 1, pp. 750–755 vol.1, 2001. [5] A. Lecchini, M. Campi, and S. Savaressi, “Virtual reference feedback tuning for two degree of freedom controllers,” International Journal of Adaptative control and Signal Processing, vol. 16, no. 5, pp. 355–371, 2002. [6] R. Vilanova, R. Katebi, and V. Alfaro, “Multi-loop PI-based control strategies for the Ac- tivated Sludge Process,” in Emerging Technologies and Factory Automation, 2009. ETFA 2009. IEEE International Conference on, September 2009. [7] S. Caraman, M. Sbarciog, and B. Marian, “Predictive Control of aWastewater Treatment Process,” International Journal of Computers, Communications & Control, vol. 2, no. 2, pp. 132–142, 2007. [8] M. Morari and E. Zafirou, Robust Process Control. Prentice-Hall International, 1989.