Fractional-Order Water Level Control Based on PLC: Hardware-In-The-Loop Simulation and Experimental Validation

: An industrial-oriented water tank level control system with PLC- and Simulink-based fractional-order controller realizations is presented. The discrete fractional-order and integer-order PID implementations are realized via the PLC and Simulink simulator. The benefits of the fractional-order PID compared to the integer-order PID control are confirmed by the hardware-in-the-loop (HIL) simulations and experiments. HIL simulations are realized using real-time communication between PLC and Simulink. The fractional-order controller is obtained for a desired phase/gain margin and validated via HIL simulations and experimental measurements.


Introduction
The majority of control systems use simple PI/PD/PID-type feedback loops. Model-based design (MBD) is currently a popular method of system design, and it can be based on physical laws and mathematical equations or performed via identification from experimental data. MBD enables fast and cost-effective development of dynamic systems, including control systems, signal processing systems and communications systems. In fact, designs have advanced a step further, no longer including classical derivative rational-order models, but rather, more elegant fractional-order models and associated tools for the analysis and design of both linear and nonlinear control systems [1,2].
In this context, fractional-order control is becoming increasingly popular in terms of modeling, analyzing and designing control systems. Over the last few decades, the problem of the synthesis and analysis of control systems described by fractional-order differential or difference equations has been considered by a number of authors [3][4][5][6].
Nowadays, fractional-order controllers are successfully used in a wide variety of applications, such as permanent magnet DC motors (PMDC motor) [7], where FOPID (fractional-order proportional-integral-derivative) was used as the self-tuned controller in real time using hyperbolic secant functions of dynamic errors. In particular, in [7], the hardware-in-the-loop (HIL) tests confirm that the proposed control scheme improves the robustness and flexibility of the FOPID control system. The authors of [8] tested fractional-order controllers for a nonlinear inverted pendulum system. The obtained results showed that the FOPID-based controller can achieve smaller overshoot and faster convergence in comparison with the integer-order PID controller. Some general relations between integer-order and fractional-order control methods are given in [9].
In process-based industries, fractional-order approaches can provide more precise and reliable control methods using modern equipment. To give examples, there are applications that focus on binary controllers [10] or fuzzy logic controllers with a supervisory control and data acquisition system (SCADA) [11]. In water level control systems, applications of fractional-order and proportional-integral controllers have yielded promising results, despite nonlinearities introduced by pumps, valves and sensors [12,13]. This paper strongly contributes to the viewpoint that fractional-order calculus facilitates better performance compared to the best performance previously achievable using integer-order calculus in industrial process applications. In particular, in the water level control system, the optimized fractional-order controller can provide some benefits to the system, such as low overshoot, zero steady-state error, short settlingtime, etc. These benefits make it possible to provide process control in optimal conditions and simultaneously minimize the controller's energy. In this work, we present a rigorous study of a fractional-order discrete-time linear PID-type control design for an industrial process. A particular highlight of this paper is the implementation of the fractional-order controller on a programmable logic controller (PLC) and on a Simulink simulator. Furthermore, the integer-order and fractional-order discrete PID controller designs are verified by HIL simulations and experimental measurements. In the HIL setup, the integer-order and fractional-order controllers are realized using the PLC and Simulink simulator. The real-time implementation of the discrete-time PID-type control algorithms from the Simulink environment into the PLC is performed. Next, real-time TCP/IP communication between the PLC and Simulink is realized to obtain the closed-loop connection. HIL results are verified by experimental tests. In the experimental setup, the integer-order and fractional-order PID-type controllers are implemented on the PLC of the MPS R PA compact workstation developed by Festo. The open-loop model of the water tank level was identified based on the time-domain measured characteristics of the water level MPS dynamics. Then, the advantages of the fractional-order PID closed-loop feedback in comparison with the integer-order PID control are illustrated and assessed using the quadratic cost functions. Integer-order PID control is designed based on the same hardware specifications. To show the effectiveness of the fractional-order PID in improving stability margins, the dynamic performance and reference tracking, analyses in both the time-and frequency-domain are performed.
The paper is organized as follows. In Section 2, the identified model of the MPS workstation is described. Section 3 gives an overview of the discrete fractional-order and integer-order controller's approximations. In Section 4, the fractional-order PLC implementation and HIL simulations with TCP/IP communication are presented. Section 5 gives a comparison of the system's respective performance in the frequency-domain. Experimental results and comments are given in Section 6. The paper ends with conclusions. Figure 1 shows the process model of the MPS water level workstation developed by Festo. The water level is the sum of all water that flows into the system, where the outflow flow rate equals the inflow flow rate. In our case, the outflow is set to a constant value of 15%. The command voltage control signal from 0-10 V increases the speed of the centrifugal pump from 0 up to 100%. The water level control loop includes an ultrasonic water level sensor and PLC controller with analog and digital terminals. Particularly, the inherent gains of the PLC A/D and D/A converters are equal to 1/10 V. The ultrasonic sensor level/voltage gain is 1/22 (10 V over 220 mm). The measurement noise is about 0.1 V peak to peak. The open-loop model was identified using the Identification Toolbox of MATLAB based on the time-raw measured water level data. The model fits the estimated data with an accuracy of 93.47%. The identified transfer-function is given by:

System Modeling
where l represents water level and u the controller output (pump effort) within the range 0-100%.

Discrete Fractional-Order and Integer-Order Controller Approximations
In [14], the authors used the classical forward difference operator as the basis for introducing a discrete Riemann-Liouville-type fractional operator. In order to define this operator, firstly note that: Then, the fractional h-sum of order α, α > 0, is defined by: for any n ∈ N 0 . The Riemann-Liouville-type fractional difference operator a ∆ α h for a function x : (hN) α → R is given by (see [14]): where t ∈ (hN) a+(1−α)h . In [15], it was shown that if a = (α − 1)h, then: The discrete-time control law of the PID controller is expressed by the difference operator from Equation (2). Then, the obtained control laws can be written as [16]: where e(t) is control error, t 0 D µ t is the fractional-order differential, λ and µ ∈ R + are either integers or non-integers and k p , k i , k d denote, respectively, the proportional, integral and differential gains.
Approximation of the t 0 D µ t operator by the Grünvald-Letnikov-type operator t 0∆ α h leads to transformation [17]: where h = t−t 0 N is step width, t denotes the interval for fractional-order discretization computations, t 0 is the initial time and N is the amount of the function's discretized points. In our considerations, we assume that t 0 = 0.
In the case of the integer-order parallel form of the PID controller, the discrete-time approximation is given by the forward Euler method with compensator formula: where N is the filter coefficient of the derivative part, in our case N = 1/T s , and determines the pole location of the filter in the derivative action (for the forward Euler rule) z pole = 1 − NT s , for sampling time T s . In order to implement the fractional operator in the PLC, the PSE (power series expansion) discrete approximation method is applied. PSE allows for estimating fractional-order terms with the use of a digital FIR filter. However, the PSE approximant is based directly on the discrete version of the Grünvald-Letnikov operator (7). The discretization of the fractional-order differentiator/integrator s ±α is expressed by the discrete equivalent s = ω(z −1 ) with the shift operator z −1 . In the case of the PSE rule, ω(z −1 ) = (1 − z −1 ) α . Using PSE, the discrete equivalent of the fractional-order operator, for the transfer function G(z) = Y(z) F(z) , is given by: where Y(z) and F(z) are the Z transforms of the output y(jh) and input f (jh) sequences. Based on the short memory principle [18], the discrete approximation of the fractional-order integral/differential operator (ω(z −1 )) ±α , is given by: where L is the memory length and (−1) j ( ±α j ) are the binomial coefficients, Finally, the PSE Euler method is used with an approximation order of five to obtain the discrete fractional-order PID controller (DFOPID). The DFOPID parameters are calculated by solving equations fulfilling the gain and phase crossover frequency according to the desired gain/phase margins (GM/PM). The PM equals φ m = 85 • , and GM is equal to A m = 6, respectively. The optimized gains of the DFOPID controller, which meet the desired, performance are: k p = 11.62, k i = 0.55 and k d = 0.87. The sampling time equals T s = 0.15 s. The DFOPID gains are constant for all results of the simulations and experiments presented in the paper. The system gains are recalculated according to the FOPID discrete approximation, PLC implementation and the Festo MPS specifications (given in Section 2). Therefore, the total feedback gain, including A/D and D/A converters and sensor level gains, is equal to 220 · k p . For the desired GM/PM, the obtained fractional-orders are λ = 0.89 and µ = 1.11. A detailed description of the fractional-order PID design for MPS water level control is given by the author in [19].

Fractional-Order PLC Implementation and HIL Simulations with TCP/IP Communication
The DFOPID controller is implemented in an industrial S7-300 (SIMATIC, Siemens) PLC controller. In PLC, the fractional-order control algorithm code is represented by the FB (function block), which has access to the inherent memory of the DB (data block). The FB with DFOPID controller is called the OB35block (a cyclic interrupt activated periodically at the desired sampling time of 0.15 s). Other parts of the PLC program (communication between the PC and the PLC, management, sensors, etc.) are gathered in the OB1 block. In order to prevent integration windup in the DFOPID controller when the pump is saturated, an anti-windup filter is applied.
Real-time communication between the PLC and MATLAB/Simulink is based on the TCP/IP and UDP protocols. The communication scheme is given in Figure 2. In particular, the TRCV_C and TSEND_C functions of the S7-1200 are used for cycling communication with the Simulink simulator.   Figure 4 gives the HIL simulation results for the integer-order discrete PID controller (DPID), where the DPID is realized by the PLC and by the Simulink simulator. The numerical realization of the discrete-time PID-type controller is implemented on the S7-1200 PLC using the Simulink PLC Coder. We can observe that the Simulink simulator's response has a setting time that is a little longer than the S7-1200's response. The reason is that Simulink uses a different discretization method for the PID function block in comparison with the PLC S7-1200. The absolute value of the dynamic control error is presented in Figure 5.  In order to assess both realizations of the DPID control systems, the quadratic cost functions of the controller outputs u and the control error e(t) = r(t) − l(t), where r(t) is the set-point, are used as follows: The cost functions (11) for both realizations of the DPID control system, calculated using the cumulative numerical integration method, are compared in Figures 6 and 7.  As expected, in the case of the PLC realization, the total energy required by the DPID controller is substantially higher than for the DPID controller realized on the Simulink simulator. Moreover, the DPID controller's implementation on the Simulink simulator has smoother output than the DPID controller implemented on the PLC.

HIL Comparison of the Integer-and Non-Integer Control Systems
In this section, a comparison of the HIL results is given for both the DFOPID and DPID controller implementations provided by the PLC and Simulink simulator. Comparisons of DFOPID with DPID control system implementation on the Simulink simulator together with cost functions are given in Figures 8 and 9.  In particular, Figure 8 presents the system's responses before optimization of the DPID and DFOPID controller's parameters. Figure 9 gives results of the control system's responses for the optimized DPID parameters. The DPID controller is switched to the DFOPID controller at the time of 57 s. We can observe that the DFOPID closed-loop ensures zero overshoot and zero dynamic error in comparison with the DPID controller. Next, the control system's responses for the DPID and DFOPID controller implementations on the PLC and Simulink simulator together with cost functions are given in Figure 10.
In Figure 10, the system outputs for the DPID and DFOPID controller implementations on the Simulink simulator are given for simulation time 0-120 s, and the system outputs of the DFOPID controller realized on the PLC are given for time 120-210 s. The slow set-point changes of the water level, given in Figures 9 and 10, are desirable as they are more realistic in domestic applications. The DPID simulator responses are given for time 0-60 s. At time 60 s, the system is switched to the DFOPID controller and further switched to the DFOPID realization on the PLC at time 120 s. One can observe that the Simulink simulator realization of the DFOPID gives the same results in comparison with the DFOPID implementation on the PLC S7-1200.

System Performances in the Frequency Domain
In this section, integer-and non-integer PID discrete control closed-loop systems are assessed, and the performances are derived in the frequency-domain. The system frequency responses prove that the DPID/DFOPID controllers' tuning based on GM/PM specifications is met. First, the comparison of the integer-and non-integer PID discrete control closed-loop systems is given in the frequency-domain. The discrete-time version of the identified true model (1) together with the feedback DFOPID controller is compared with the integer-order PID closed-loop system. Figure 11a shows the sigma diagrams of the closed-loop systems and the frequency response of the sensitivity function. Particularly, the singular values are calculated for G cl (e jωT s ), where, in the case of the fractional-order system, G cl (z) = DFOPID(z)·G 0 (z) 1+DFOPID(z)·G 0 (z) is the discrete transfer function of the closed-loop system, T s is the sample time and ω is frequencies between zero and the Nyquist frequency of π/T s . The sigma plots of the non-integer-order feedback systems is compared for PM φ m = 65 • (when λ = 1.02 and µ = −0.02) and for φ m = 85 • (when λ = 0.89 and µ = 1.11). The frequency responses for PM = 85 • have smooth trajectories within the entire range of frequencies; whereas, the integer-order PID closed-loop system and DFOPID with PM = 65 • have an eigenvalue peak of 5.3 dB and 14.5 dB, respectively. All systems keep the absolute singular value of one in the low frequency range.
In order to compare the robustness and performances of integer-and non-integer-order feedback loop systems, the sensitivity functions are presented in Figure 11b. In the case of the non-integer-order system, the sensitivity function, S = (I + L DFOPID ) −1 , is calculated for the fractional-order open loop function L DFOPID . The S function is an effective tool related to the robustness and performance of the closed-loop system. As we can expect, the non-integer-order system with the highest PM φ m = 85 • has the smoothness sensitivity plot in the considered frequency range. Therefore, this DFOPID closed-loop system has lower sensitivity to input disturbances compared to the integer-order system. In order to compare the approximation accuracy of the DFOPID controller, the frequency responses of the closed-loop system with PM φ m = 85 • are determined for different orders of the PSE realization and given in Figure 12. One can observe that the approximation order of n = 5 is high enough to get sufficient results.

Experimental Results and Discussions
In this section, experimental results are given according to the DPID and DFOPID controllers' implementations on PLC for the MPS water level setup. The experimental hardware configuration is shown in Figure 13. The MPS station given in Figure 13, developed by Festo, consists of open-loop equipment for water tank level control. Real-time communication between the MPS station and PLC is realized via industrial Ethernet. In order to make the acquisition of the process variables possible, the SCADA system is realized via the TIA portal and WinCC environments. Figure 14 presents the transient responses of the optimized process output variable with the DPID controller output to the step set-point. We can observe that the system's response is sluggish, approximately 1 L/min, which is caused by the low performance of the recirculating pump that is delivering fluid through the piping system. Figures 15 and 16 present, respectively, the set-point responses and controllers' outputs, of the process controlled with DPID and DFOPID realized by PLC. One may observe that the DFOPID closed-loop control system has the desired dynamic performance presented by HIL simulations and experiments, such as small oscillation, settling time and overshoot, whereas the set-point change equals 0-100%. For the high GM/PM system values with orders λ = 0.89 and µ = 1.11, the DFOPID steady-state error is about 6%. However, the steady-state error can be minimized using a different setup of the DFOPID controller. The influence of the GM/PM specifications on the system's performance is given in the box window in Figure 15. The DFOPID controller with λ = 1.02 and µ = −0.02 achieves the best control performance, where the steady-state error tends to zero, the settling time is around 100 s, and the system's overshoot is similar to that of the DPID. The DPID and DFOPID controllers' outputs are compared in Figure 16a, and cost functions of the controllers outputs are given in Figure 16b. In the case of the optimized system with DFOPID controller specification λ = 1.02 and µ = −0.02, the amplitude oscillation of the controller output is smoother in comparison to the DPID controller (see Figure 16a). It is observed that the optimized DFOPID controller has smaller undershoot and overshoot in the transient states than the DPID controller. According to Figure 16b, the controller effort energy given by index J 1 Equation (11), for the optimized system specification λ = 1.02 and µ = −0.02, is relatively 12% lower in comparison with the DPID system. As is expected, in the case of the lowest stability margin φ m = 65 • and A m = 4 (when λ = 1.02 and µ = −0.02), the total energy of the controller output is higher than for the DFOPID controllers referring to the higher GM/PM margins such as φ m = 85 • (when λ = 0.89 and µ = 1.11). However, the higher GM/PM results in the increase of the steady-state error and rising time.

Conclusions
The paper presented a study on discrete-time PLC-and Simulink-based integer-order and fractional-order PID (DPID/DFOPID) control designs for water level process control. The control systems are compared and verified via hardware-in-the-loop (HIL) simulations and experimental measurements. In particular, as an experimental setup, the MPS station with the water tank level closed-loop was used for the DPID and DFOPID controller's validations. The experimental test rig is equipped with Ethernet communication between the PLC and MPS station. The HIL simulation setup providing real-time TCP/IP communication between the PLC and Simulink simulator is presented. In the HIL, both the DPID and DFOPID controllers are implemented on the PLC or Simulink simulator, whereas, the identified open-loop dynamics is represented by the Simulink model. The results of HIL simulations for both controllers' implementations using the PLC and Simulink simulator are compared.
Detailed studies of the DFOPID/DPID control application for the water level system were carried out through a series of HIL simulations, experimental results, cost function calculations and analyses in the frequency-domain. The fractional-order discrete-time water level control system ensures robust stability and sufficient control performance despite the step set-point change. In particular, the optimized FOPID provides a lower overshoot, smaller settling time and zero dynamic error in comparison with the integer-order PID-type controller. High GM/PM values of the system such as A m = 6 and φ m = 85 • (when λ = 0.89 and µ = 1.11) yield a steady-state error of about 6%. However, the optimized DFOPID controller with λ = 1.02 and µ = −0.02 (when φ m = 65 • ) achieves zero steady-state error and small overshoot. Moreover, according to the experimental results, the energy required by the optimized fractional-order controller specification λ = 1.02 and µ = −0.02 is 12% lower than for the integer-order system. To summarize, the simulation and experimental results prove that together with increasing the GM/PM, the controller effort energy is decreasing, but the system has bigger steady-state error.
The paper should be of considerable interest to process industry engineers who provide more elegant and more efficient control system solutions. Moreover, the work presents useful techniques, particularly its practical PLC/Simulink simulator implementation approach. A further goal in this topic is to investigate multiple-input multiple-output (MIMO) water tank fractional-order control. The authors are currently investigating the problem of cross couplings in the system's structure.

Conflicts of Interest:
The authors declare no conflict of interest. The founding sponsors had no role in the design of the study; in the collection, analyses or interpretation of data; in the writing of the manuscript; nor in the decision to publish the results.