Design and Implementation of Model Predictive Control Based PID Controller for Industrial Applications

: Advanced control approaches are essential for industrial processes to enhance system performance and increase the production rate. Model Predictive Control (MPC) is considered as one of the promising advanced control algorithms. It is suitable for several industrial applications for its ability to handle system constraints. However, it is not widely implemented in the industrial ﬁeld as most ﬁeld engineers are not familiar with the advanced techniques conceptual structure, the relation between the parameter settings and control system actions. Conversely, the Proportional Integral Derivative (PID) controller is a common industrial controller known for its simplicity and robustness. Adapting the parameters of the PID considering system constraints is a challenging task. Both controllers, MPC and PID, merged in a hierarchical structure in this work to improve the industrial processes performance considering the operational constraints. The proposed control system is simulated and implemented on a three-tank benchmark system as a Multi-Input Multi-Output (MIMO) system. Since the main industrial goal of the proposed conﬁguration is to be easily implemented using the available automation technology, PID controller is implemented in a PLC (Programable Logic Controller) controller as a lower controller level, while MPC controller and the adaptation mechanism are implemented within a SCADA (Supervisory Control And Data Acquisition) system as a higher controller level.


Introduction
Industrial processes have become more complex and contain several control loops. The Proportional Integral Derivative (PID) controller is considered the most popular control loop for field engineers and plant operators due to its simple structure. Approximately 1/3 of control loops in plants utilize traditional PID controllers, while the other loops need to be enhanced through advanced control techniques [1]. In a typical plant, control loops are complex and require advanced control algorithms for lower costs and better performance. As a result, the tuning of the PID controller becomes challenging for field engineers especially for a process with multiple interacting loops, time delays, constraints, nonlinearities and uncertainties [2].
Several PID controller-tuning methods have been presented in the literature [3][4][5]. Many are based on the analysis of system responses to test signals and empirical rules, for instance, the Zigler-Nicholes and Cohen-Coon methods [6,7]. Some of the tuning methods use the modified PID controller such as Fractional Order PID [8,9] and Internal Model Control [10,11]. Artificial intelligence techniques could be used to adapt PID gains such as Fuzzy PID [12,13], Genetic Algorithm [14,15] and Neural Network [16]. Additionally, other advanced PID tuning techniques are available based on multi-objective optimization [17] or predictive control [18,19]. The adaptation techniques of the PID controller based on the advanced control theory, stated before, achieve the required target. However, most techniques remain in the research phase and have not been applied in industries mainly due to human and technology constraints. Moreover, most of these techniques are designed for a single control loop. Hence, it is necessary to design an adaptation technique that can be practically implemented in the industry for multiple PID loops for Multi-Input Multi-Output (MIMO) system.
Industrial plants can increase the profit and product quality and decrease the overall costs through the implementation of appropriate process control and optimization tools, which is known as Advanced Process Control (APC) and can be implemented by advanced automation system technology such as Distributed Control System (DCS). The APC covers different control techniques such as feed-forward control, cascade control, time delay compensators, supervision, multivariable, nonlinear and Model Predictive Control (MPC), adaptive algorithms and so forth [20]. To deal with the APC, three major factors should be considered as shown in Figure 1. In the industrial field, the majority of operators are familiar with traditional control techniques rather than advanced control approaches, these approaches require more qualifications and expertise. Nevertheless, the APC algorithms require advanced automation technology and devices in contrast to traditional control techniques. Thus, the main challenge of APC remains to be the controller design through a combination of the existing automation technology and field operators' knowledge as illustrated in Figure 1. The application of advanced control theory should be in a simple manner to facilitate the understanding and executability of the APC by field engineers and plant operators.
Since the industrial automation system is constructed in a multi-leveled or hierarchal structure [21,22], the advanced control algorithm can be applied centrally or distributed among different levels of automation hierarchy of the industrial plant to meet the APC challenges. Consequently, most advanced control theory is performed in a hierarchical control structure in various applications, for example, power system [23] and robotics [24]. MPC is an APC algorithm that has significant advantages, particularly for the MIMO system with constraints [25][26][27][28]. Regardless of the MPC effectiveness, it is still applied at the supervisory level for most industrial applications in optimizing the set point of the process instead of regulating the control loop due to human constraints and computational burden [29][30][31]. As stated above, PID remains preferred for industrial control loops as it is elementary and comprehensible by field engineers. The classical tuning of PID control is deemed ineffective in controlling industrial plants. This suggests that adopting the PID controller based on the APC technique is necessary. For this purpose, a combination of PID and MPC is recommended to be implemented in industrial applications. The PID controller adaptation based on MPC was introduced in References [32,33] for a Single-Input Single-Output (SISO) system without constraints. In this paper, the proposed technique adapts PID gains for MIMO with constraints based on MPC. This technique is applied in two stages: (1) Designing an MPC controller that achieves the required performance for a constrained MIMO system; (2) Identifying PID gains that give a similar performance of MPC by employing the Recursive Least Square (RLS) identification method.
The control task is implemented in a hierarchal control configuration of two levels as shown in Figure 2. Since the PID controller must satisfy a rapid response time for the controlled process, it will be implemented in the lower level, such as Programable Logic Controller (PLC) or other individual controllers. In contrast, the adaptation mechanism rate is slower than the sampling one of the process. Hence, the MPC control loop and the adaptation algorithm will be executed at the upper controller level such as SCADA system. This configuration allows the proposed technique to be suitable for different industrial processes. To validate the proposed technique, an experimental nonlinear MIMO three-tank system is used to implement the proposed technique as it is a common benchmark that simulates many industrial processes, for example, wastewater treatment stations, petroleum refining plants and so forth. Other uses include testing and validating different control techniques and strategies [34].
Therefore, the main contributions of this paper are summarized as (1) Design an adaptation technique of PID for MIMO considering process constraints, human and existing technology constraints as well; (2) Integrate MPC, as one of the effective APC techniques, with PID to adapt its loop instead of adjusting the setpoint only; (3) Implement the control algorithm in a hierarchical structure considering the human background and industrial technology constraints, functionality and computational burden; (4) Validate the proposed technique on an experimental benchmark using industrial automation technology.
The remaining of this paper is organized as follows. Section 2 shows the proposed algorithm. Section 3 illustrates the simulation results of the proposed technique for the three-tank system. The experimental system and results are described in Section 4 and the conclusion is discussed in Section 5.

The Proposed Algorithm
The focus of the proposed method is to develop an online tuning mechanism of PID controllers for MIMO systems with constraints that can be implemented using industrial automation technology considering the human background. The algorithm is sectioned into two parts: Firstly, the control vector is computed using MPC; Secondly, PID controllers' parameters are computed using the MPC output based on the RLS identification method.

MPC Design
MPC is applied for several industrial applications, which require higher performance and more robustness. The control signal is obtained by minimizing the cost function given by References [35,36]: subject to a discrete state-space model: where * * * is the error, * is the system output, * is the system reference, * is the system input, Q * and R * are weighting matrices, * is the system states, A * , B * , C * , D * are the system parameters, ny is the prediction horizon value, nu is the control horizon value, m is the number of inputs, l is the number of outputs and n is the number of states. The recursive form of the model over the prediction horizon ny is given by: where: 1 * * is the predicted system states, * * is the system input, 1 * * is the system output, and P * * , H * * * , P * * , H * * * are the system parameters over the prediction horizon ny. The minimization of (1) with respect to without considering the variable constraints is given by: where L * * I * ∶ O * * , Im*m is an identity matrix and Om*(m*ny-m) is a zero matrix, * * is the system reference, Q * * * and R * * * are weighting matrices.
Solving the constrained optimization problem is considered one of MPC's main aspects. System constraints can be represented in the inputs, inputs rates, outputs and states such as: .
Since the output and are functions of the control input , then the state and output constraints can be presented generally as additional constraints for the input in the form of: where W * and * are representing the system constraints parameters according to constraints number nc. The softening constraints method is one of the constraint handling methods and it requires a lower computational burden than other approaches [37,38]. In this method, the violation between the input signal and their constraints is merged into the cost function such as: where S * is the weighting matrix. Considering the maximum input constraint: * then f = and W(k) = I, where * is the upper boundary of the control signal. The control signal that minimizes the function (12) is given by: where * * and S * * * are the maximum limits of control signal and weighting matrix over the control horizon 1. The proper selection of the weighting matrices Q and R ) is essential for the controller design to penalize the states or control inputs. Larger weighting values means more restricted variables. A design approach can be used to obtain the optimum values for the weighting factors [39]. By obtaining the control signal, u(k)MPC, it is required to adjust the PID controllers' gains to satisfy the same behavior of MPC.

PID Controller Tuning
The general representation of the MIMO system is illustrated in Figure 3 employing C * as a MIMO controller. In the case of PID controller it will be: where the number of PID controllers is l*m and the total number of PID gains is the triple of l*m. The continuous control signal is obtained from: where is the error, , and are the proportional, integral and derivative controller parameters for controller 1,2, … due to error signal 1,2, … . The discrete form of (16) can be represented as: where 2 are the error and Ts is the sampling time, then: The adaptation of PID gains is achieved using the RLS identification method based on MPC which will be implemented in the supervisory level controller; for example, DCS or SCADA system. As for the realization of PID, it will be executed in the field level controller (i.e., PLC) as illustrated in Figure 4. The RLS is considered an effective technique for estimating the parameters of a linear regression system. The identified PID model can be obtained by Reference [40]: , where θ is a column vector of parameters to be estimated from observations and , while is the noise. Then, a quadratic cost function based on the sum of the squares of the difference between the observed output and model predictions is obtained as follows: where αk is a weighting scalar coefficient. In the case of a linearized system, such as the three-tank system in Section 3, a forgetting technique is used by forgetting the old samples [40] that make the weighting scale coefficient adaptable and it is obtained by: where is the forgetting factor, K is the estimation length, k is the sample number and is the nominal scale factor for sample number k. The updated parameters are given by: By applying the identification algorithm on the PID model in (18), considering: 1 . The controller parameters in (23) will be estimated according to (20) and the number of initial samples in the recursive formula should be equal or greater than the number of PID gains to be estimated. To guarantee the proposed controller stability, let Uo ⊆ ℛ m is the possible control signal subspace which satisfies (11), where MPC ∈ Uo= {u|W and Ҡ ⊆ ℛ 3m is the subspace of all possible values of PID controller parameters, . , in (23). Since terminal constraints ensure the stability of the MPC controller as discussed in Reference [34], then to ensure the stability of the adapted PID controller based on MPC is: where PID is the control signal of the PID controller in (17). The control algorithm is computed based on the flow chart in Figure 5.

Simulation
The proposed control technique has been tested on the experimental three-tank system shown in Figure 6. For the three-tank system, the control problem is to maintain the levels at predefined values. The system is linearized around the operating point using Taylor expansion by considering the assumption L1>L3>L2. As illustrated in Figure 6, the system consists of three identical cylindrical tanks with equal cross-section area At. These tanks are connected by two pipes of the same crosssection area Ap and have the same outflow coefficient μ13 and μ32. The nominal outflow is located at the second tank and it has the same cross-section area as the coupling pipe between the cylinders but with a different outflow coefficient μ20. Two pumps control the inlet flow to the first and second tanks, whereas the third tank is uncontrollable. So, it is affected by the level in the two end tanks. Pumps flow rates are q1 and q2 respectively in m 3 /s with the same maximum flow rate Qmax.
, (29) where represents the flow rate from tank m to tank n (m, n=1, 2, 3 and m ≠ n). Using Torricelli law, it is equal to: where is the gravity constant, then: The linearized state-space model parameters are given by: L10, L20 and L30 are the operating points of the three levels, respectively. The controller input vector is , while the system output vector and the system state vector are equal to . Since the system is relatively slow and has a time constant of 50 s, the sampling time has been chosen to be 1 s. After discretizing the model using the forward Euler approximation method and substituting by the system parameters in given Table 1, the model will be:   8 show the three tank levels response and input flow rates of the PID controller. The gains of PID are adapted using the classical reference tracking method [42] and are mentioned in Table 2. Figures 9 and 10 show the system levels' response and input flow rates of the PID controller based on MPC. The latter provides a faster response than the standalone PID, for example, the first tank level reaches the steady-state after 200 s taking into consideration the maximum flow rate, while it takes 400 s for the PID controller. Also, an overshoot has been observed for the levels' response of the PID controller. For example, the first tank has an overshoot of 2.23 %, while it is about 0.5 % for MPC based PID controller. A leakage disturbance has been imposed on the system at the sample of 600 and released after 100 s. MPC based PID exhibits a more robust behavior and full stabilization at the system operating points faster than the PID controller as illustrated in the figures. The prediction and control horizons of the MPC controller are calibrated to 10 samples, while the sampling time is 1 s as illustrated in Table 3. The adaptive PID gains based on the MPC controller are shown in Figure 11. The online adaptation for PID gains started after 10 s, as the RLS method adopts few samples to calculate the initial PID gains.

System Description
The experimental setup is represented in Figure 12. It is fully designed and implemented in the Automatic Control Laboratory of the Electrical and Control Engineering department within the AASTMT facilities. It consists of three identical square glass tanks, that is, not cylindrical as in the theoretical model. The first and second tanks are fed from the reservoir tank by two AC pumps controlled by Siemens SINAMICS G110-120 W drivers. The third tank is also connected to the first and second tanks by intermediated on/off valves. The discharge of the three tanks is controlled through an on/off valve attached to the second tank. Each tank has a manual valve to simulate the tank leakage. In addition, minimum and maximum level sensors are implemented for level safety. Moreover, a continuous level measurement for the three tanks is obtained through analogue pressure sensors. The necessary calibration process of the pressure sensors is performed. The pump drivers are connected to the PLC through Universal Serial Interface (USS) communication protocol. USS is a serial protocol developed by Siemens Company to control its AC and DC drives. It is an access approach based on the master and slave concept for communications via a serial bus to read/write process data on the drives and to read/adjust drive parameters over the bus [43]. The relations between flow rate and pump speed, in RPM, are given by: 2 * 10 * 1 * 10 (m 3 /s) 2 * 10 * 9 * 10 (m 3 /s).
The pump's operation could be more reliable based on [44]. As discussed earlier, the PID controller is implemented at the PLC, while its parameters are computed through the MPC controller at SCADA. Then, the parameters will be sent to the PLC through the communication network. To maintain the hierarchical control system structure, the MPC controller and the adaption task are implemented on a PC through Laboratory Virtual Instrument Engineering Workbench (Lab VIEW) software as the higher control level. Lab VIEW is a system design software and development platform used for graphical programming language from National Instruments Company. Alternatively, the PID control task is executed at Siemens PLC S7-1200 as a lower control level through Siemens Totally Integrated Automation (TIA) Software.
TIA is an engineering platform that integrates PLC controllers, HMI and motor drives in addition to other components for different automation tasks. The drives' output voltages are applied to the motors through three-phase contactors. In case of driver's failure, pumps can be operated directly online through interlocked contactors with the drivers' contactors. The control cabinet is shown in Figure 13, it is equipped with Siemens KTP600 Basic color PN HMI for local system monitoring and control. The communication between PC and PLC relies on National Instruments Open Platform Communication (OPC) server through an Ethernet communication protocol. OPC is a standard interface for communicating different data sources including factories' field devices, laboratories' equipment and databases. Many industrial data acquisition and control devices, such as PLCs and Programmable Automation Controllers (PACs), are designed to work with the OPC foundation standard. The overall automation configuration is demonstrated in Figure 14.

Results
The experimental results have been obtained by employing Lab VIEW software. The MathScript Module has been used to develop the proposed algorithm structure through its built-in libraries and functions, for example, DCS Module, to maintain the PC SCADA system. One of the SCADA screens is shown in Figure 15. Different experiments have been carried out to obtain sufficient measurements to identify three-tank system parameters. The sampling time has been calibrated to be 1 s, while the system time constant is 48 s. After substituting by the system parameters given in Table 4, the statespace model for the experimental system is:    Figures 16 and 17 show the three-tank levels response and input flow rates of the PID controller with fixed gains, which are listed in Table 5. Figures 18 and 19 represent the tank levels response and input flow rates of MPC or MPC based PID controller. MPC based PID shows a faster response for the two end tanks, the settling times are about 150 s for the first tank and 50 s for the second tank. On the other hand, the settling times for the PID controller are about 700 s for both tanks. A steady state error by 5 % of the third tank level for both controllers is observed, as it is uncontrollable state.     Additionally, no overshoots have been observed for the tank's levels using MPC based PID controller, while for the PID controller, they are 10.9 % for the first tank and 13.3 % for the second tank. Besides, MPC based PID inputs satisfy the maximum flow rate constraints and reach the steadystate at the identified operating points in Table 4. A comparison between PID, MPC and MPC based PID for the first tank is illustrated in Table 6. The MPC calculation parameters are similar to the simulation parameters listed in Table 3, while the MPC based PID adaptable gains are illustrated in Figure 20. The RLS method requires more samples to calculate the initial experimental PID gains rather than the simulation case, so the online adaptation for PID gains started after 200 s. Input I Input II

Conclusions
The usage of automation systems and APC approaches are necessary for better performance, superior quality, and lower manufacturing costs. However, the human factor and the current automation technology should be considered during the implementation of the APC techniques. The adaptation of PID controllers for a MIMO system with constraints using an MPC controller is proposed. The proposed algorithm is executed in a hierarchical structure of two levels, one to implement PID controllers and the other to identify the PID controller gains using RLS to obtain the same performance of MPC. The proposed technique overcomes the limitation of both standalone PID and MPC controllers. It has been validated for a three-tank system as a MIMO nonlinear system with constraints. The simulation results show the effectiveness of the proposed technique. After that, it has been implemented for an experimental three-tank system setup. The experimental results show a superior transient performance of the MPC controller over the conventional PID controller without noticeable overshoot. Furthermore, MPC and MPC-based PID controllers have similar results; this reflects the effectiveness of the real implementation of the adaptation technique.