Design of a model reference adaptive PID control algorithm for a tank system

Received Mar 31, 2020 Revised Jun 20, 2020 Accepted Jul 6, 2020 This paper describes the design of an adaptive controller based on model reference adaptive PID control (MRAPIDC) to stabilize a two-tank process when large variations of parameters and external disturbances affect the closed-loop system. To achieve that, an innovative structure of the adaptive PID controller is defined, an additional PI is designed to make sure that the reference model produces stable output signals and three adaptive gains are included to guarantee stability and robustness of the closed-loop system. Then, the performance of the model reference adaptive PID controller on the behaviour of the closed-loop system is compared to a PI controller designed on MATLAB when both closed-loop systems are under various conditions. The results demonstrate that the MRAPIDC performs significantly better than the conventional PI controller.


INTRODUCTION
Adaptive control of uncertain processes has become more and more important in industry. Adaptive controllers differ from ordinary ones, because their parameters are variable, and there is a mechanism for adjusting these parameters online based on signals in the system [1]. The design of an adaptive PI controller to stabilize a mass damper-spring system under parameters' uncertainties was proposed in [2]. The designed adaptive PI controller adjusts to parameters' variations, and the output of the process follows the set points, regardless of the values of the parameters. But it does not guarantee stability when external disturbances and large variations of parameters occur.
In [3], the design of a PID controller on MATLAB to maintain the level of liquid constant in a coupled-tank system (CTS) was proposed. The control parameters were found using the trial and error methodology and the results were analysed in MATLAB/Simulink environments. Proportional (P), proportional integral (PI), proportional derivative (PD) and proportional integral derivative (PID) controllers were applied on the process and their performances were compared to select the most suitable control solution. The PID controller showed superior results, but it did not guarantee stability to disturbances and variations of plant parameters.
Adaptive controllers, as opposed to conventional constant gain controllers (PID controllers), are very effective in handling situations where the variations of parameters and environmental changes are very frequent with the application of model reference adaptive control scheme in a first order system [4]. They noticed that the newer adaptive control schemes could not cope with drastic changes in loads, inertias and forces, unpredictable and sudden faults, or frequent, or unforeseen disturbances. Most conventional PID controllers with constant gain were also unable to cope with these problems. For this reason, the authors developed a control technique to solve these problems and added an adaptation gain to show the effects on the system performance. An adaptive control algorithm of a water tank model was simulated in [5]. It was concluded that, compared to the one degree of freedom (1DOF) algorithm, the two degrees of freedom algorithm (2DOF) reduced the control input demands, which was important from the practical point of view. But the 2DOF had slower output response compared to the 1DOF.
A robust optimal adaptive control strategy was developed in [6] to deal with tracking problem of a quadrotor unmanned aerial vehicle (UAV). The controller has a prominent ability to stabilize nonlinear dynamic system of quadrotor, force the states to follow desired reference signals, and find optimal solution for the tracking problem without control input saturation. The performance analysis of a conventional PID controller and a MRAC was done in [7]. Cylindrical tank interacting and noninteracting systems were selected as processes to be controlled. The results showed that the MRAC has better overshoot, settling time and set-point tracking performance than the conventional PID controller.
The development of direct and indirect adaptive control methods to control the power in a TRIGA MARK II reactor was proposed in [8]. The analysis showed that the adaptive algorithm offers overall better results than the feedback control algorithm. The adaptive algorithm reduced the settling time up to 25% of the nominal settling time.
A model reference adaptive controller without integral (MRACWI) parameter for position control of a DC Motor was designed in [9]. The controller produced better performance in terms of settling time, percentage overshoot and mean square error as compared with PID controller, standard MRAC and MRAC with a sigma modification. A drawback of this algorithm is that its performance to variations of parameters and external disturbances is unknown.
A comparison of the time specification performance between a conventional PID controller and a modern sliding mode controller (SMC) for a nonlinear inverted pendulum system was done in [10]. The performances of both control strategies were assessed to see which one had better handling of pendulum's angle and cart's position. The overall results of the analysis showed that the sliding mode controller had faster rising time, better settling time and a much better percentage of overshoot compared to the conventional PID. Both controllers did not have any steady state errors. Since the inverted pendulum is a highly nonlinear system, this research showed two drawbacks. The authors did not investigate the performance of the controllers when external disturbances and variations of parameters occur. These studies would have made the investigation more realistic.
Advanced PID are also used in the medical sector, [11] proposed a fractional order PID controller and an integer order PID controller for supressing epileptic activities. Both controllers showed great results to stabilize the patient, but the fractional order PID controller is more suitable for implementation in FPGA because it uses less flip-flops. Unfortunately, the study did not take in consideration sudden abnormal activities of the brain cells to evaluate the time response taken by the controller to stabilize the patient. This study is crucial to bring the patient back to a good health condition in the shortest time possible.
In [12], a novel data-driven sigmoid-based PI controller was designed to track the angular velocity of dc motor powered by a dc/dc buck converter. The results of the investigations showed that the data-driven sigmoid-based PI, which is tuned using global simultaneous perturbation stochastic approximation, yields a better angular velocity tracking as compared to conventional PI and PI-Fuzzy. A drawback of this study is that, the performance of the sigmoid-based controller was not evaluated for disturbance rejection.
In [13], the performance of the fractional order proportional-integral-derivative (FOPID) controllers designed by using artificial bee colony (ABC) for fractional orders systems is compared to conventional PID controller optimized by the ABC colony algorithm. The results of the simulations showed that the FOPID controllers had significantly better performance compared to the conventional PID controllers. Unfortunately, there was no study made to evaluate the performance of the controller when disturbances occur.
An adaptive safe experimentation dynamics (ASED) for data driven neuroendocrine-PID control of MIMO Systems was designed in [14]. The performance of the ASED based method was compared to the standard safe experimentation dynamics (SED) and simultaneous perturbation stochastic approximation (SPSA) based methods. The results of the simulations showed that the ASED and SED based methods have successfully solved the unstable convergence issue in the existing neuroendocrine-PID based standard SPSA. Moreover, the presented ASED based algorithm outperforms the SED and the SPSA based methods in the perspective of the control performance accuracy in terms of lower objective function, total norm error and total norm input. A drawback of this research is that, the authors did not perform plant's parameters changes to see the influence of the adaptive gain of the ASED controller. The research gap and merit of the adaptive PID controller developed in this paper compared to the other advanced PID controllers reviewed is that, the proposed controller can stabilize the closed-loop system when variations of parameters and sudden random disturbances occur simultaneously. None of the reviewed papers explored this scenario.
The main contribution of this paper is that it presents the design of a model reference adaptive PID controller (MRAPIDC) based on the MIT approach to stabilize and optimize the linearized model of the twotank liquid level process affected by sudden changes of parameters and input disturbance. Then, a reference model is developed based on control theory, and a PI regulator is designed on MATLAB to control the reference model. The designed PI controller is a novel idea to add stability to the output signals of the reference model, hence making the adaptive algorithm more robust. Another novelty of this research is the inclusion of three new adaptive gains in the final structure of the MRAPIDC to make the closed-loop system robust when large variations of parameters and sudden external disturbances occur simultaneously. The controller keeps the percentage of overshoot of the closed-loop system below 10% and its recovery time to sudden variations of parameters is lower than 5 seconds, which is a huge advantage compared to the other adaptive controllers reviewed. Another advantage of this adaptive algorithm is that real-time tuning of the three adaptive gains can be done to improve the performance of the closed-loop system. Furthermore, the performance of the MRAPIDC is compared to a classic PI controller designed on MATLAB for the linearized model of the two-tank system. The adaptive control algorithms, PI control algorithm and the models of the closed-loop systems are simulated in MATLAB/Simulink. The outline of this paper is as follows: the modelling and simulation of the process is proposed in section 2. Section 3 discusses the design of a MRAPIDC based on model reference theory. The simulation results are shown in section 4. Section 5 draws the conclusion.

MODELING AND SIMULATION OF THE TWO-TANK SYSTEM
In this paper, a two-tank liquid level system is selected as a plant to be controlled, because it is a nonlinear inherently unstable system. The system is made of two-tank mounted above a reservoir, which has the function of a storage element for liquid. The system has an independent pump to pump liquid from the reservoir to the tanks. The two-tanks are interacting, which means that the liquid moves from one tank to the other. When two tanks are state dependent, the interaction of liquid between the tanks exhibits a nonlinear behaviour [15]. The simplified block diagram of the process is shown in Figure 1. The nonlinear equations of the two-tank liquid system model can be derived by applying the Bernoulli's law of conservation of mass [15]: The nonlinear dynamic equations derived from tank 1 are: The dynamic equations derived from tank 2 are: At equilibrium for a continuous liquid level set-point, the derivative of the liquid levels in the tanks must be zero ( ). In the scenario when: ; the system is state decoupled. Therefore, to satisfy the conditions of the simulation of the liquid level system: , the level of liquid in tank 1 must be bigger than this of tank 2.
The state space representation of the nonlinear system is the following: Then: The parameters of the two-tank process are given in Table 1. The next section is to derive a linearized model of the nonlinear tank process to find an accurate equivalence of both models.

Linearization of the nonlinear model of the two-tank process
The linearization of the two-tank liquid system is performed around its operating points, and to achieve that, only the linear terms of the Taylor series expansion of the nonlinear model are considered. In (7) and (8) are considered to linearize the nonlinear model of the system.
Let define the state variables of the system: By substituting ℎ 1 and ℎ 2 , by 1 and 2 in (7) and (8), it is obtained: The (9) and (10) can be expressed by the standard nonlinear model: where: ( ), ( ) and ( ) are the nonlinear vector functions of the state vector. The linearization of the nonlinear model is performed according to Taylor series method. The linearized model is derived based of the nonlinear functions 1 , 2 , 1 and 2 . For the case of the twotank system, the nonlinear functions are: Then: The derivative according to is:  Derivatives of the second function 2 according to the two states are: The terms of the control matrix B can also be found with the same procedure:  Derivative of 1 per the two states:  Derivative of 2 according to the two states: After all the linearized expressions of the system are done, the linearized state space representation of the two-tank process is: where the coefficients of the matrices defined in (24) are calculated for the equilibrium values of the state variables given by (6) and (7). At equilibrium for continuous liquid level set-point, the derivative must be zero (ℎ 1 = ℎ 2 = 0). In the scenario when: ℎ 1 = ℎ 2 , the system is state decoupled. Therefore, to satisfy the conditions of the simulation of the liquid level system: ℎ 1 > ℎ 2 . The model defined by (6) and (7) will be used to develop the adaptive control algorithm.

DESIGN OF A MODEL-REFERENCE ADAPTIVE PID-CONTROLLER
The Massachusetts Institute of Technology (MIT) rule is a gradient rule. It was derived at MIT in its instrumentation laboratory, hence its name. The MIT rule is the original approach to model reference adaptive control (MRAC) [15,16]. To give a representation of the MIT rule, let consider as an adjustable parameter of a controller. The desired closed-loop response of the output is ; and the error between the output of the closed-loop system and the output of the refrerence model is ε. In the paper, the desired output is proposed to be determined by a reference model output. To define the MIT rule, let consider the following loss function [17]: It is necessary to determine at every moment of time the parameters of the controller in such a way that the function ( ) is minimized.
The MIT fundamental approach consists of adjusting the parameters of the closed-loop system such that the loss function described in (25) is minimized. To minimize the function ( ), a realistic approach would be to change the parameters of the system in the direction of the negative gradient of : where: is an adaptation gain; and ( ) is the sensitivity derivative function of the system towards its timevarying parameters. represents in this case, the time varying parameters of the controller. In (26) is the MIT rule. The sensitivity derivative expresses how the adjustable parameters influence the error. In general, it is assumed that the parameter changes are slower than the other variables of the system. Hence, the sensitivity derivative ( ) can be evaluated by assuming that the adjustable parameter is constant. To summarize, the following steps can be used to design an adaptive controller based on the MIT rule:  Define the coefficients of the transfer function of a plant with unknown parameters.  Choose a reference model.  Choose a control algorithm to achieve perfect model tracking.  Define the error of the closed-loop system.  Derive the expressions of the control parameters.  Apply the negative gradient of to find the updating parameters.

Determination of the transfer function coefficients for the linearized model
The state space representation of the tank process is represented as given in (24) To transform the state space model of the linearized system to transfer function, the following formula is applied [18]: where I is the identity matrix, and: The calculation of the transfer function of the linearized model is the following: The design of the model reference adaptive PID controller to stabilize the developed linearized model is described in the next section.

Procedure to design the model-reference adaptive PID-controller (MRAPIDC) for the linearized model of the two-tank liquid level system
To make the derivation of the adaptive PID controller much simpler mathematically, the final expression of the transfer function of the linearized model is simplified as:

Design of the desired linear reference model
The linearized model of the tank system is of a second order. Therefore, the linear reference model can be designed as a typical second order transfer function as follows: From the design specifications, the values of the dominant poles can be obtained as follows: where: ( ) is the transfer function of the reference model, is the output of the reference model and is its input.
Then the output of the reference model is: To guarantee the stability of the closed-loop system, the reference model must meet the following design characteristics: To ensure stability and robustness of the closed-loop system when large variations of parameters occur, a proportional integral (PI) controller is designed on MATLAB for the reference model R(s) using the programming command line ( , ) [21,22]. The parameters and are tunned to find their optimal values. This additional PI has also the ability to guarantee stability when sudden external disturbances affecting the two-tank process occur. The parameters of the PI controller are: = 0.001 and = 4 The transfer function of the PI controller is the following:

Selection of the control algorithm to achieve perfect model tracking
To achieve perfect model tracking, the following proportional integral derivative (PID) control algorithm is selected for the process as: where: is the proportional gain; is the integral gain; is the derivative gain; is the plant output; and ( ) = ( ) − ( ), with ( ) as the input of the reference model.
The representation of the PID controller in Laplace domain is: The output ( ) of the two-tank liquid level process can be found as follows: The substitution of (30) into (31) gives: The closed-loop system is: It is known that: The PID coefficients are not known. It is necessary to determine them in such a way that the PID controller has adaptive behaviour towards the parameters variations of the process to be controlled. The design of the PID controller is further done in the time domain. In the time domain, (33) can be written as given in , because of the following:  The model parameters vary at every moment of time.  The adaptive controller must change its parameters also at every moment of time.
Following , the representation of (33) in the time domain is: where: is a differential operator.

Determination of the error between the plant states and the reference model states
The tracking error of the closed-loop system and the reference model is [24,25]: Substituting (28)

Derivations of the expressions of the control parameters
The expressions of the sensitivity functions of the closed-loop system error towards the controller parameters are derived by differentiating (36). These expressions are defined as ( ) , ( ) , and They are derived as follows: To make sure that there is a perfect tracking error, let assume that, the time behaviour of the process is equal to the time behaviour of the reference model, as follows: The gradient method described in (26) is applied to find the expressions of the control parameters: where: , and are the adaptation gains.
The expression of the adaptive PID controller is the following:

SIMULATION RESULTS
The Simulink diagram of the closed-loop system with the derived adaptive PID controller is shown in Figure 2. The simulation is done in MATLAB/Simulink environment. The closed-loop system is made of the following subsystems:  Plant model represented as a second order transfer function.  Reference model.  Adaptation control algorithms.  Figure 5  Simulation results when the set point is 13cm as shown in Figure 6

Scenario 2
Results when the closed-loop system is subjected to new parameters variations:  In Table 2, a summary of the performance comparison between the closed-loop system with modelreference Adaptive PID-controller and the closed-loop system with PI controller when the system is affected by variations of the parameters is given. The results of the simulation show that the closed-loop system under adaptive PID controller has better performance than the PI controller. The adaptive PID controller shows stability and robustness with faster rise time and settling time. It also has a quicker recovery time when variation of parameters occurs compared to the PI controller.

Performance comparison of the Pi-controller and the model reference adaptive PID-controller in terms of random input disturbance rejection
The random disturbance has the following characteristics:  Amplitude: 0.8cm The Simulink block diagram of the closed-loop system with input disturbance is shown in Figure 9. The random disturbance has the following characteristics:  The results of the simulation show that the adaptive PID controller is robust to parameters' variations and rejects input disturbance, while the conventional PI controller shows an unstable convergence behaviour. The performance of the adaptive PID controller is outstanding.

Analysis of the design specification achievement
In the previous sections, the two-tank liquid level system is subjected to parameters' variation and random input disturbances, both are applied to the closed-loop system in different conditions.
The various simulations of the two-tank liquid level process reveal the following observations:  The adaptive PID controller and the system adapt to the changes of plant parameters.  The adaptive PID controller and the system reject random input disturbances.  The stability of the system is achieved.  The error signals go to zero.  The plant output always follows the reference model and the set-points trajectories regardless of the bounded values of the varying parameters, and the introduction of random input disturbances.

CONCLUSION
In this paper, the first contribution is the design and derivation of the Adaptive PID controller based on the MIT approach. Then, the performances of a standard PI controller designed on MATLAB and a new model reference adaptive PID controller designed based on MIT technique are compared for a two-tank process subjected to parameters variations and disturbances. The model reference adaptive PID controller can stabilize the closed-loop system when variations of parameters occur at a speed eight times faster than the conventional PI controller, which is a significant improvement.
The designed model reference adaptive PID controller showed outstanding performances and is recommended as control method to be used for the stabilization of the closed-loop system subjected to internal parameters variations and external random disturbances. For future research, the algorithm can be improved to implement multiple model reference methodologies in real-time to push the boundaries of the control algorithm.