Implementation of PID autotuning procedure in PLC controller

. In this paper, we present the automatic PID tuning procedure based on the Method of Moments and AMIGO tuning rules. The advantage of the Method of Moments is that the time constant and transport delay are estimated at the areas rather than on the individual points. This results in high resistance to the measurement noises. The sensitivity to measurement noises is a serious problem in other autotuning methods. The second advantage of this method is that it approximates plant during identification process to first order model with time delay. We combined the Method of Moments with the AMIGO tuning rules and implemented this combination as a stand-alone autotuning procedure in Siemens S7-1200 PLC controller. Next, we compared this method with two built-in PID autotuning procedures which were available in Siemens S7-1200 PLC controller. The procedure was tested for three types of plant models: with lag-dominated, balanced, and delay-dominated dynamics. We simulated the plants on a PC in Matlab R2013a. The connection between the PC and PLC was maintained through a National Instruments data acquisition board, NI PCI-6229. We conducted tests for step change in the set point, trajectory tracking, and load disturbances. To assess control quality, we used IAE index. We limited our research to PI algorithm. The results prove that proposed method was better than two built-in tuning methods provided by Siemens, oscillating between a few and even a dozen percent in most cases. The proposed method is universal and can be implemented in any PLC controller.


Introduction
A proportional-integral-derivative (PID) controller is still the most widely used algorithm in industrial applications [1].Individual terms can be activated or deactivated to create P, PI, PD, and PID controller type but the most common amongst them is PI.The biggest problem with commissioning PID algorithm is a controller tuning process.Manual tuning can be time consuming.It also requires specialised knowledge and experience in the field of control engineering.The research conducted in the 1990's found that 80% of PID applications were badly tuned [2].For this reason, more and more PID controllers are equipped with autotuning function.Many controller manufacturers as well as scientists are trying to develop new, more accurate and efficient autotuning procedures.
In this paper, we present the procedure for automatic tuning of the PID controller based on the Method of Moments, as a method of system identification, and the AMIGO tuning rules.The advantage of the Method of Moments is that the parameters of model are estimated at the areas rather than on the individual points.This results in high resistance to the measurement noises.We implemented Method of Moments + AMIGO as a standalone autotuning procedure in Siemens S7-1200 PLC controller.Next, we compared the method with two built-in PID autotuning procedures which were available in Siemens S7-1200 PLC controller.

PID autotuning
The tuning process of the PID controller is based on determining the value of the parameters of the controller.Selection of controller parameters is a difficult task; therefore, any manufacturers decide to implement special procedures to make tuning process automatically.This is called autotuning.
There are many different autotuning procedures but generally autotuning has two major phases: control object identification and controller parameters calculation.The most common approach in the first phase is to build a model of control object.Model should be as simple as it is possible, e.g.first order model with time delay (FOTD).Equations used to calculate the controller parameters, based on model parameters, are called tuning rules.The literature is abundant in different tuning rules, e.g.O'Dwyer in [3] shows 649 controller tuning rules dedicated for FOTD model only.
Autotuning methods can be divided into two groups.The first group uses step response, and the second is based on relay method.In the PLCs both methods are available.Siemens S7-1200 PLC controller can be an example with two autotuning procedures: Pretuning and Fine Tuning implemented in it.
The Pretuning procedure is based on the step response.Firstly, the controller is turned into manual mode and controller output u is forced to a value set by ITM Web of Conferences 15, 05009 (2017) the user.Secondly, value of plant output y is observed until it reaches the point of inflection.Finally, the Chien-Hrones-Reswick tuning rules are used to calculate the parameters of the controller [4], [5].
The Fine Tuning procedure uses the relay method developed by Åström and Hägglund, which is based on the Ziegler-Nichols Ultimate Cycling method [6], [7].The method involves a series of oscillations of the plant output y.Oscillations are forced by switching the controller output u between two values.The controller parameters are calculated with Ziegler-Nichols tuning rules.The relay method is still being developed.Currently, researchers are focused on asymmetric relay autotuning and adaptation the method to plants with more input and output signals such as TITO [8].
In this paper, we compare two build-in autotuning procedures with combination of Method of Moments and AMIGO tuning rules.The Method of Moments is a system identification technic based on the step response characteristic.In this method, the plant is modelled by FOTD model (1).
where The static gain is calculated by equation where: y --increase of plant output, u --increase of controller output.Calculation of time constant T and time delay L is not as simple as static gain K and requires estimation of additional variables: area A 0 (integrated distance between steady-state of step response y 1 and plant output y), time T ar (average residence time), and area A 1 (area under the step response up to time T ar ) according to equations (3-7) where: y 1 --steady-state of plant step response, y --plant output.
After FODT model parameters estimation, calculation of controller parameters is performed with AMIGO tuning rules.These rules are well described in [7].We used PI algorithm thus our controller had two parameters: proportional gain K p and reset time T i .
where: T i -reset time.All autotuning procedures, i.e.Pretuning, Fine Tuning, and Method of Moments + AMIGO, were implemented in PLC controller.The first and the second procedure are available in S7-1200 PLC controller as a build-in functions.We implemented the third procedure by ourselves in the form of function block.We have programmed the PLC controller in ladder diagram language in TIA Portal V13 software.To calculate the integrals from equations ( 3) and ( 5) we used rectangle rule.The sampling period was 20 ms.PID algorithm, a build-in function, is implemented in S7-1200 PLC controller as a technological function available in a standard library.The function block name is PID_Compact.According to manual PID algorithm is described as [4]:

T s u s K by y y y cy y T s aT s
where: b --proportional term weighting, y ref --set point, a --derivative delay coefficient, T d --derivative time, c --derivative term weighting.
The values of coefficients a, b, and c were estimated automatically during Pretuning and Fine Tuning process.In Method of Moments + AMIGO autotuning procedure we set them to a constant value equal 1.We limited our research to PI algorithm so T d =0.
We simulated the plants in Matlab&Simulink.Communication between PLC and Matlab&Simulink was maintained throughout data acquisition board in the way depicted in the fig.Autotuning procedures were tested with tree plants described by transfer functions (11-13).P 1 is a lagdominated plant, P 2 is balanced, while P 3 is delaydominated plant [9].
To compare results of autotuning procedures three scenarios were prepared: step change in the set point, trajectory tracking, and load disturbances.Fig. 3 shows changes of set point signal in all scenarios.In the first case, step change of set point was applied in the 10th second to a value of 7V and the next step was applied in the 110th second to a value of 3V.Test lasted 210 s.In the second scenario, the set point was changed according to trajectory of response of the first order system (5s+1) -1 to step change to value of 7V.In the 100th second another trajectory was applied.It was response of the first order system (25s+1) -1 to step change to value of 3V.Test lasted 250 s.In the last scenario step change of set point was applied in the 5th second to a value of 5V, remaining constant to the end of experiment.Next, in the 155th second the load disturbance of value of 1V was applied to a plant input, i.e. controller output signal u.Test lasted 305 s.We compared all autotuning procedures from control performance point of view.To assess control quality, we used Integral Absolute Error (IAE) index:

Results
Tables 1, 2, and 3 show results for lag-dominated plant P 1 , balanced plant P 2 , and delay-dominated plant P 3 , respectively.The tables include controller parameters calculated by each autotuning procedures and values of control quality index IAE for step change, trajectory tracking, and load disturbances scenario.
After system identification process, by means of Method of Moments, plants P 1 , P 2 , and P 3 were modelled by M 1 , M 2 , and M 3 models described by following transfer functions 0.12 1 ( ) All tested methods allow to tune the PID controller so that in each testing scenario tuned systems reached the steady state after set point change or load disturbance.There was no case of unstable system and the overshoots were small.
Results for lag-dominated plant (P 1 ) show the value of IAE index for Method of Moments + AMIGO was smaller by 3.3%, 30.6%, and 7.1% for step change in the set point, trajectory tracking, and load disturbances, respectively compare to Pretuning procedure.In the case of balanced plant (P 2 ) proposed procedure allows to achieve control performance index smaller by 9.2%, 28.2%, and 3.25% for step change in the set point, trajectory tracking, and load disturbances respectively compare to Fine Tuning procedure.However, the greatest advantage of described procedure can be seen for delay-dominated plant (P 3 ).The value of IAE index was smaller by 44.4% (step change in the set point), 44.7% (trajectory tracking), and 42.7% (load disturbances) in comparison to Fine Tuning procedure.

Conclusions
Our goal was to implement combination of Method of Moments and AMIGO as a new autotuning procedure to PLC controller.We also compared this method with two built-in PID autotuning procedures which were available in Siemens S7-1200 PLC controller.The results show that control loops tuned by proposed method has lower values of control quality index.
In future works we will focus on minimising the errors of integrals calculation caused by the rectangle rule.The trapezoidal rule should give better approximation.The source code in ladder diagram language be optimised to reduce the controller memory occupation.

0 A 1 Fig. 1 .
Fig. 1.Graphical interpretation of parameters calculated in the Method of Moments.

Fig. 2
Fig. 2 presents scheme of data collection.Key elements used in our research were: -PLC controller Siemens SIMATIC S7-1200, -Data acquisition board National Instruments NI-6226, -Matlab&Simulink software.All autotuning procedures, i.e.Pretuning, Fine Tuning, and Method of Moments + AMIGO, were implemented in PLC controller.The first and the second procedure are available in S7-1200 PLC controller as a build-in functions.We implemented the third

2 .
All signals, i.e. set point y ref , plant output y, and controller output u, were voltage signals from the range 0-10V.

Fig. 3 .
Fig. 3. Changes of set point signal in tree scenarios.

Table 1 .
Controller parameters and control performance assessed for plant P 1 .

Table 2 .
Controller parameters and control performance assessed for plant P 2 .Plant and controller output for plant P 2 .

Table 3 .
Controller parameters and control performance assessed for plant P 3 .Plant output and controller output for plant P 3 .