#### Abstract

The proportional-integral-derivative (PID) is still the most common controller and stabilizer used in industry due to its simplicity and ease of implementation. In most of the real applications, the controlled system has parameters which slowly vary or are uncertain. Thus, PID gains must be adapted to cope with such changes. In this paper, adaptive PID (APID) controller is proposed using the recursive least square (RLS) algorithm. RLS algorithm is used to update the PID gains in real time (as system operates) to force the actual system to behave like a desired reference model. Computer simulations are given to demonstrate the effectiveness of the proposed APID controller on SISO stable and unstable systems considering the presence of changes in the systems parameters.

#### 1. Introduction

A challenging problem in designing a PID controller is to find its appropriate gain values (i.e., proportional gain , integral gain , and derivative gain ) [1]. Moreover, in case where some of the system parameters or operating conditions are uncertain, unknown, or varying during operation, a conventional PID controller would not change its gains to cope with the system changes. Therefore a tuning method is needed. Various PID controller tuning techniques have been reported in the literature. It is classified into two groups, offline tuning methods as Zeigler-Nichols method and online tuning methods or adaptive PID. APID can tune the PID gains to force the system to follow a desired performance even with the existence of some changes in system characteristics [2].

Adaptive control has been commonly used during the past decades specially the model reference adaptive control (MRAC). Its objective is to adapt the parameters of the control system to force the actual process to behave like some given ideal model which is demonstrated in [3, 4]. There are two main categories of adaptive control. * Indirect*. It starts with controlled system identification and then uses those estimated parameters to design the controller as presented in [5–7]. * Direct*. This is more practical than indirect method. It uses a parameter estimation method to get the controller parameters directly the same as introduced in [8, 9].

An adaptive PID controller is presented in [10] using least square method which is an offline parameter estimation method. On the other hand, an optimal self-tuning PID controller is introduced in [5] using RLS to estimate the model from its dynamic data. RLS is a recursive algorithm for online parameter estimation that is frequently used because it has a fast rate of convergence. In [11] an online type of controller parameter tuning method is presented by utilizing RLS algorithm. It develops the standard offline fictitious reference iterative tuning FRIT method to be used as a modified estimation error for RLS algorithm. Also the controllers in [11–13] present online tuning based on input and output data of the system.

In the case of unstable systems, few researchers study the behaviour of the adaptive PID techniques on unstable systems and examine its ability to stabilize them as verified in [14–17].

In this paper, the direct method of adaptive control is considered. RLS algorithm is used as adaptation mechanism to tune the PID gains automatically online to force the actual process to behave like the reference model. The proposed approach has also the ability to stabilize the unstable system. Adding some parameters variations in actual process during its operation time confirms the proposed controller adaptation capability and robustness against process variation in both stable and unstable cases.

The structure of this paper is as follows. In Section 2, the problem statement is presented. In Section 3, an APID controller and its adaptation mechanism using RLS are introduced. The proposed technique is applied to numerical examples in Section 4 and its results show its ability in tracking the reference input signal using APID controller for both stable and unstable systems even when the considered system suffers from changes of its parameters. Finally, in Section 5, the conclusion and some suggestions for further work are presented.

#### 2. Problem Formulation

Consider a system shown in Figure 1, where is a process that is modeled as a single-input and single-output linear system, is a PID controller, and denotes a parameter vector to be tuned in the controller. Also, , , , and denote the control input, output, reference signal, and error signal, respectively.

In conventional control, the PID controller can be expressed as

Note that, approximately, the transfer function of integrator can be expressed as .

Simply, the controller transfer function [11] can be expressed as

Define

So (2) can be rewritten in the form

In most of practical applications, the actual structure of the controlled system is unknown or varying. Therefore, the adaptive mechanism is used for self-adjustment of the PID gains to achieve the best tracking performance. The proposed technique controls the motion of both stable and unstable systems to follow the ideal trajectory provided by a designer defined reference model .

#### 3. APID Controller Using RLS

The proposed controller objective is to find the coressponding controller parameters (PID gains) using RLS algorithum as adaptation mechanism such that the closed-loop transfer function is more or less equal to the reference model transfer function. In other words, the reference output tends to be equal to the plant output as follows:

So it can be written as where is a given model reference transfer function which represents the ideal closed-loop dynamics.

Hence, (6) can be written as

Applying the controller transfer function to both sides of the above equation results in and becomes

Now the modified estimation error of RLS can be defined as

This means that

Based on the RLS algorithms, we tune the parameters which are the PID gain values so that the following performance index is minimized:

On the other hand, in order to apply the classical equations of the RLS estimation algorithm used to find the parameters , a modified estimation error can be expressed as where .

To build the RLS algorithm using the 2nd-Level S-Function in Matlab, the first term in right hand side of (13) has to be rewritten as where and is a vector which contains all parameters of PID gains.

RLS is an algorithm which recursively finds the optimal estimate of the controller parameter by using [3]. Thus, considering (14), the proposed RLS update laws will be as follows: where is the adaptation gain and is the covariance matrix.

According to the above RLS algorithm equations, the controller parameters are updated at each time. Thus, variation of the controller parameters may be large at the start of algorithm, at the time when plant characteristics change rapidly, and at the time when the set-point reference is changed. Due to this, the system may stop working steadily.

In order to avoid such a problem and reduce the variation of the controller parameters is filtered by a low-pass filter which can be defined as where is a sufficiently small positive constant. So is changed reasonably.

#### 4. Numerical Examples

In order to illustrate the main features of the proposed APID using RLS, simulation examples are now presented. The following examples cover stable and unstable systems cases and consider the changes in the system parameters during simulation time.

##### 4.1. Stable SISO System

Consider the plant used in [11]

Let the sampling time be and let the reference model be

The reference input signal is chosen to be a delayed square wave.

The proposed technique in Section 3 is applied. The initial controller parameters and the initial correlation matrix are set to be and , respectively also consider and .

In order to evaluate the proposed control method to plant uncertainties, we consider the case where there exists a change in one of the system poles at 155 s (i.e., the pole changes to ); moreover the gain of the plant is doubled suddenly at 225 s.

The output by the proposed APID using RLS controller is shown in Figure 2 and it is compared with the controller presented in [11] and conventional PID. In the proposed controller the PID gains are tuned adaptively despite the variation of gain and poles of plant, and good tracking performance is maintained. It is clear from the figure that the proposed APID using RLS controller has superior performance as it has smaller overshoot at the beginning of the simulation than the controller in [11] and the conventional PID could not handle either the gain change or the pole change.

##### 4.2. Unstable SISO System

Now, consider that the unstable system stated in [18] is a simple SISO model of inverted pendulum

And reference model can be expressed as where natural frequency and damping ration .

The reference input signal is chosen to be a delayed square wave.

The proposed technique in Section 3 is applied and the initialization parameters are set to be and , also consider .

It is shown in Figure 3 that the proposed APID using RLS controller can stabilize the system and achieve good tracking performance despite the fact that the gain of the plant is doubled suddenly at 155 s and the system’s unstable pole is changed at 255 s. On the contrary the conventional PID and the controller presented in [11] with the same initial parameters failed to stabilize the system.

#### 5. Conclusions

In this paper, adaptive PID (APID) controller is proposed using RLS algorithm which updates the PID gains automatically online to force the actual system to behave like a desired reference model. Numerical examples have been shown to confirm the tracking capability of the proposed controller when it is applied to both stable and unstable systems. It also proves the efficiency of the controller during the changes of system parameters during operation of system. Moreover comparisons are made between the proposed APID and the adaptive controller presented in [11] and the conventional PID. This work can be further extended to drive the stability analysis for the proposed APID controller for SISO systems. Also, as a further research, the APID controller technique demonstrated in this paper can be modified to be applicable for MIMO systems and then its behavior can be investigated in the presence of some variations in system parameters.

#### Conflict of Interests

The authors declare that there is no conflict of interests regarding the publication of this paper.