PLC based model predictive control for industrial process control

Article history: Received 3 January 2017 Received in revised form 24 March 2017 Accepted 31 March 2017 This paper presents the real-time implementation of model predictive control technique on programmable logic controller for industrial process control. Firstly, temperature of water is regulated in liquid tank at desired temperature and then level of water in filling bottles is controlled through PWM based flow control valve. The simulations of MPC for temperature and level control are presented in MATLAB by first developing the system model of water tank. The simulation results have shown that MPC effectively regulates both temperature and level of water. Finally, MPC is real time implemented on PLC and provides better real-time control of these two variables.


Introduction
*In the industrial automation field, various hardware and software architectures and accesses are currently in use for implementing control applications (Colla et al., 2009). To fulfill high control performance requirements in industry the control methods are mostly based on the proportional, integral and derivative (PID) controller which is widely used since the last few decades (Rathore et al., 2015). It is combination of three terms Proportional, Integral and Derivative and it is mostly used to influence the time-domain response of vast range of dynamic systems (Aslam et al., 2016a). Because of its reliability and tuning issues using it in different environments is a challengeable task and most of the control processes operate at constraints. PID is not abile to work within the predetermined constraints without violating them (Aslam et al., 2016a;Huyck et al., 2012). Model Predictive Control (MPC) is the solution for that and has become a widely-applied control technique in process industry for the control of slow dynamic systems i.e. chemical industries, paper industries etc. The key feature of MPC is to repeatedly solve an optimization problem based on available measurements of the current state of the process (Huyck et al., 2012).One critical challenge in MPC implementation is the high computational burden required for optimization of control signal and even it becomes more critical for systems with fast sampling time (Li et al., 2013). Mostly embedded systems have limited computational power and it is not feasible to implement MPC on it (Maciejowski, 2002). Programmable Logic Controller (PLC) has high computational power and it provides best choice to implement MPC. PLC can be programmed in numerous programming languages i.e. Function Block Diagram (FBD), Statement List (STL), and Ladder Logic Diagram (LAD). LAD is the most famous PLC programming language and it uses components like elements used in a line diagram format to describe hard-wired control (Lashin, 2014). In this research work simulations of MPC are presented for temperature and level control at different set-points by first developing the state space model of liquid tank for both temperature and level control systems and finally MPC is real-time implemented on PLC by using ladder logic programming for both temperature and level control in tank and bottles respectively and the results are displayed on HMI. In section 2 system modeling and implementation of MPC is done. Section 3 elaborates the PLC operation. Section 4 and 5 presents the simulation results and hardware implementation respectively. Finally conclusion is presented in section 6.

Implementation of MPC
Model predictive control (MPC) refers to a class of control algorithms that utilizes process model to predict the future response of a plant. At each sampling interval MPC attempts to optimize future plant behavior by computing a sequence of future controlled inputs. The first input in the optimal sequence is applied to the plant while rest of sequence is ignored and this entire calculation is repeated at every sampling instant (Qin and Badgwell, 2003). The basic structure of MPC is shown in Fig. 1 Implementation of MPC is based on system model and optimizer. Optimizer is a mathematical function which optimizes the control signal by minimizing the cost function in presence of constraints. These control signals as future inputs are send to system model of the plant to get predicted output. The difference between the predicted output and reference value in form of errors is sent to optimizer which optimizes the future input and this procedure will remain continue.

System modeling
Perfection of MPC depends on how well dynamics of a system have been captured. In this research work two industrial process variables temperature and level are controlled. The system model of whole process is shown in Fig. 2. MPC is implemented on PLC to regulate these two variables. Resistive heating element is used as an actuator to provide heat to liquid tank and PT100 thermocouple is used to measure temperature and provides feedback to PLC. After acquiring the desired temperature of water filling of bottles start and flow of water is controlled by regulating the Pulse Width Modulation (PWM) based flow control valve, while level of water is measured by weight cell as 1Kg of water is equal to 1 liter of water therefore weight cell is used to measure level and provides feedback to PLC. The State Space Model (SSM) of liquid tank for temperature control and level control are presented below. The performance of heating process depends on the induction, maintenance and control. There are number of heating techniques used now a day in domestic and industrial processes i.e. direct heating, indirect heating, electric arc heating etc. (Aslam et al., 2016a). In this research work direct resistance heating technique is employed in which immersion rod is dipped in the water tank. The heating capacity of immersion rod is based on its wattage power and the required wattage power for the immersion rod is calculated by the equation (Liuping, 2009) (Eq. 1): where is the heater wattage, is the weight of water, is the specific heat of water, T is the change in temperature, and T is the time required to raise temperature at desired level. In this case is 33lb, is 1 Btu/lb/F, T is 140 F, and T is1 hours. By putting the values in above equation, the required wattage is calculated as: = 88 * 1 * 140 3412 * 1 = 1.8 The required power of immersion rod is 1.8KW so 2KW heating rod is selected. This immersion rod is used to regulate the temperature of water tank system by using MPC. Effectiveness of MPC is based on the precision of system model of liquid tank Performance of MPC depends on how well the dynamics of system have been captured. The system model of water tank is shown in Fig. 3 (Aslam et al., 2016b).

Fig. 3: System model
Where is the input power, C 1 is the energy in the tank, ρis the density of water, V is the volume, T1 is the water temperature in the tank, Tin is the inlet temperature, U is the thermal conductivity, and W is the mass flow rate of water. The parameter values of liquid tank are shown in Table 1. Specific Heat Capacity C = 4200J/Kg-K 5 Thermal Conductivity The thermodynamic equation for water tank is shown below (Eq. 2) by taking Laplace of above equation it becomes (Eq. 3) accepted that = (Eq. 4) solving for T1(s) above equation becomes (Eq. 5) τ is the time delay between an excitation of heating element and the response of temperature sensor (Eq. 6).
apply Laplace transformation to above equation it becomes (Eq. 7) by putting 1 ( ) in above equation, the transfer function becomes (Eq. 8) by putting the values of parameters from Table 1 The transfer function obtained is discretized by sampling interval of 10 sec to convert it in discretetime state-space model as shown in equation below (Aslam et al., 2016b) (Eqs. 11 and 12) The above two equations represent the State Space Model (SSM) of the liquid tank that will be used in Fig. 1 to implement MPC for temperature control of water tank.

System model for level control
Fluid level control in a tank is a very common application in process industries. Consider a liquid tank as shown in Fig. 2 with water flowing in and flowing out as well. The output of tank is the level of water represented in terms of height h and input to the system is flow in rate (fin) of water. The flow out (fout) of water depends on the pressure in the tank as shown by Eq. 13 Where ρ is density of water, g is the gravitational acceleration, h is height of water in tank and R is the proportionality constant related to outlet pipe shape and for simplicity it is considered 1 and above relation becomes The rate of change of volume in tank with uniform cross sectional area can be related with rate of change in height of water in tank and also with the difference between flow in and flow out by the Eq. 14.
Where, A is uniform cross sectional area of tank. By putting the value of fout in Eq. 14 it becomes the first order differential equation represented by Eq. 15 By dividing the above equation by ρg the Eq. 15 becomes The above relation can be represented in terms of time constant and gain K by the following equation Where, = and = 1 . The transfer function 1 st order model of the system is shown in Eq. 18 The parameters of liquid tank for system model of level control are shown in Table 2. By putting the values of parameters in Eq. 18 the actual transfer function for level control system is shown in Eq. 19 The transfer function obtained is discretized by sampling interval of 10 sec to convert it in discretetime state-space model as shown in Eqs. 20 and 21:  Gravitational Acceleration g = 9.8ms 2

Optimization
MPC optimizes the control vector ∆ by minimizing the cost function in presence ofconstraints as shown in Eq. 22 (Aslam et al., 2016b).
Where the first term in Eq. 22 reduces the difference between the set-point and the output, while second term gives importance to change in control signal ∆U magnitude. R ̅ is a diagonal matrix and R ̅ = r w I N c ×N c . r w ≥ 0is a user defined tuning parameter for desired closed loop performance. When rw = 0 is used in cost function no importance is given to change in control signal and for large value of rw results in careful attention to change in control signal. The optimization of control vector is shown in Eq. 23.
where F and are the vectors shown below There are three major types of constraints two of them are applied at the control signal and change in control signal respectively while, the third one is applied at the output of the system. These constraints are of the form given below (Aslam et al., 2016c).
Traditionally, the constraints are imposed on the whole control vector and all constraints are expressed in terms of vector ∆ as shown in Eq. 25.
Rearranging the above equation in a compact matrix form by relating C1 and C2 to appropriate matrices and subject to constraints for control signal as shown in Eqs. 26a and 26b.
where, and are column vectors with Ncelements of u min and u max similarly for change in control signal constraints are (Eq. 27) Again ∆ and ∆ are column vectors with Nc elements. Similarly, output constraints are presented in terms of ∆ (Eq. 28) After minimizing the cost function for optimization of control vector, ∆ is subjected to the inequality constraints by Eq. 29 Transform the above equation in more compact form as shown in equation below and use it to find an optimized control without violating the constraints (Eq. 30).

∆ ≤
Where, M is a vector of constraints with its rows equal to number of constraints and columns equal to dimension of ∆U (Aslam et al., 2016c).

Simulations based analysis
PLC is a special form of microprocessor-based controller as it uses programmable memory to store instructions and to implement functions such as logic, sequencing, timing, counting and arithmetic in order to control processes. PLCs have been an integral part of factory automation and industrial processes control for decades. They control a wide variety of applications from simple lightning functions to complex environmental systems and complex chemical plants. T also provides variety of analog and digital input output (I/O) interfaces, signal processing capability, data conversion and various communication protocols. The working operation and basic features of used PLC is elaborated in following section

Basic PLC operation and specification
The basic operation of PLC is very simple and based on the Scan Cycle loop. It consists of four steps input scan, program scan, output scan and housekeeping as shown in Fig. 4 (Netto and Bagri, 2013). The housekeeping step is executed at both start and end of operation cycle by self-checking the hardware and software to rectify or indicate any fault. In input scan PLC looks at each input card to determine if it is ON or OFF and saves this information in data table for use in next step. This makes the process faster and avoids cases where an input changes from the start to the end. In program scan PLC executes the instruction one at a time and finally in output scan after execution of program output registers are updated in this way PLC performs operation. The features of Delta DVP20EX2 module are summarized in Table 3.

Simulation results
Simulations of MPC for temperature and level control of water are developed by first acquiring the state-space model (SSM) of water tank then include the design parameters Nc, Np, reference point and constraints. Finally, the cost function subject to constraints is minimized to optimize control vector which is further applied to SSM to get predicted output and this procedure continues until the desired set point is achieved. Flow chart of MPC implementation is shown in Fig. 5.

Temperature control simulation results
Results of temperature control of the water are presented at three set-points 50 °C, 60 °C and 70 °C respectively in Fig. 6. The simulation results have shown that MPC effectively regulates the temperature at desired set-points.

Level control simulation results
Results of level control of the water are also presented at three set-points 250ml, 500ml and 1000mlin Fig. 7. The simulation results have shown that MPC effectively regulates the water level at desired set-points.

Hard results
The hardware implementation consists of Human Machine Interface (HMI) for input and Output results display, PLC for processing MPC, Water process tank as plant, sensors for feedback and a power supply. The PLC receives the actual temperature from Process tank as feedback from temperature sensor (pt100) and then PLC uses MPC algorithm to generate Pulse Width Modulation (PWM) to control the power of immersion road to regulate temperature. once the temperature meets desired value then filling of bottles start and MPC generates PWM pulses for PWM-controlled flow valve to regulate the water level and the weight cells ends the feedback to PLC to compute the required PWM to regulate desired water levels.

Block diagram
The Block Diagram of the industrial process control is shown in Fig. 8. It consists of an input transducer to transform the desired input reference to a form compatible with the PLC so, it can generate required PWM for PWM based control valve using MPC algorithm. Output transducers measures temperature and level and convert it into the form used by the controller and according to these feedbacks controller calculate PWM using MPC and display unit shows the result of reference value and actual values of these two parameters.

Human-Machine Interface (HMI)
Human-Machine interface (HMI) is a software application of PLC used to give commands to PLC

Update feedback Xf
End and it is also used to display the output results of a system. In this industrial process automation HMI is used to give different set-points of temperature and water level and is also used to display the results of regulated variables. .

Programmable Logic Controller (PLC)
DVP20EX2 is a 2 nd generation Programmable Logic Controller. There are number of programming languages of PLC. Ladder logic is used in this research work to implement MPC to regulate both temperature and level of water as an application of industrial process control

Process plant
The water tank is used in this project as a system model for regulation of temperature with heating immersion rod of 2000 Watt and filling bottles of different volumes are used for regulation of water level with PWM based flow control valve.

Sensors
Pt100 is used as an output transducer for transmitting tank's temperature back to controller. It is a Platinum resistance thermometer (PRT) that offers excellent accuracy over a wide temperature range (from -200 to +850 °C). Relationship between temperature and resistance is approximately linear over a small temperature range. A weight cells is a transducer which converts force into a measurable electrical output, strain gage based load cell is used in this project. Strain gage load cell have accuracy within 0.03% to 0.25% of full scale. In case of water 1liter=1kg so, it is used to transmit the level of water in bottles to controller.

PLC flowchart
Real-time implementation of MPC on PLC is done by first initializing the PLC then providing temperature and level set-points from HMI. After that MPC for temperature and level control is implemented by using Ladder Logic. Finally, PWM is generated to regulate the power of both heating rod and flow control valve and indirectly control temperature and level. PLC implementation flow chart is shown in Fig. 9.

Results
The combined hardware results for temperature and level control are presented in three cases on HMI. They are 60°C and 500mL, 70°C and 1000mL and 80°C and 1500mL.

60°C and 500ml
MPC is implemented on PLC to initially regulate the temperature at 60°Cin water tank then filling of bottles start and 500ml bottle is filled. The results are shown in Fig. 10. a b Fig. 10: Temperature and level regulation at 60°C and 500mL Fig. 10a shows that MPC effectively regulates the desired temperature and Fig. 10b shows both temperature and level are regulated. Level has some steady state error and it is due to the initial empty bottle weight of 32 grams. HMI results also show the duty cycle of 128msec after reaching the desired temperature.

70° and 1000ml
MPC is implemented to regulate the temperature at 70°C and fill bottle at 1000 ml. The results are shown in Fig. 11. a b Fig. 11: Temperature and Level regulation at 70°C and 1000ml Fig. 11a shows that MPC effectively regulates the desired temperature and Fig. 11b shows both temperature and level are regulated. Level has some steady state error and it is due to the initial empty bottle weight of 32 grams. HMI results also show the duty cycle of 202msec after reaching the desired temperature

80° and 1500ml
MPC is implemented to regulate the temperature at 80°C and fill bottle at 1500 ml. The results are shown in Fig. 12. Fig. 12a shows that MPC effectively regulates the desired temperature and Fig. 12b shows both temperature and level are regulated. Level has some steady state error and it is due to the initial empty bottle weight of 32 grams. HMI results also show the duty cycle of 237msec after reaching the desired temperature.

Conclusion
In this research work MPC is implemented on PLC for temperature and level regulation of water in tank and bottles respectively. MPC is an optimization based control technique and provides effective controlling in comparison to other control techniques but it has high computational burden so PLC is best solution for MPC in industrial process control. First simulations of MPC are presented in MATLAB for both temperature and level control at different set-points and MPC convincingly regulate both variables. Finally, MPC is real-time implemented on PLC to regulate both temperature and level and results are displayed on HMI. The results have shown that MPC effectively regulates temperature of water in tank and level in bottles at different set-points. a b Fig. 12: Temperature and Level regulation at 80°C and 1500ml