# Why PID control gains need to be positive in feedback control

This blog post explains why PID control gains need to be positive. It is important to understand how PID controller works first. The post will consider stability analysis of each control action, i.e. proportional, integral and derivative control individually. Examples and figures are used to demonstrate the result. Tuning of PID controller will be left for a future blog post.

1. Proportional controller

Suppose an error system is as follows

where e is the error, A is the system parameter and u is the control input. A proportional controller is given below

The closed loop system of (1) and (2) is

The solution of the ordinary differential equation in (3) is well known and can be represented as

t0 is the initial time and e(t0) is the the initial value of the error. Depending on the sign of A-Kp in the exponential term, (4) will be exponentially unstable if A-Kp is positive and exponentially stable if A-Kp is negative.

For example, if A-Kp=1 in (3), i.e.

then (4) becomes

For t0=0, e(0)=1, (6) becomes

Simulation results of both systems (5) and (7) are given in the plot below

Figure 1 shows the error is unstable due to closed-loop control gain A-Kp> 0. If A-Kp=-1 is negative, then (3) becomes

and (4) becomes

For t0=0, e(0)=1, simulation of the systems (8) and (9) are shown as follows

Figure 2 shows the error is stable due to closed-loop control gain A-Kp< 0.

It has been demonstrated that the control gain Kp in (2) needs to be selected such that the closed loop system gain A-Kp < 0 in (3) is negative in order for the closed loop system to be stable. Kp therefore needs to be a positive value.

2. Integral controller

Suppose the controller (2) now has an integral term as below

The closed-loop system (1) and (10) becomes

To analyse the stability of (11), let’s introduce a Lyapunov function

It is easy to see V > 0 is positive for any non-zero e(t), and a negative value of V̇ < 0 will ensure V→ 0 and e(t)→ 0 eventually. Taking the derivative of (12)

substitute (11) into (13)

For the first term in (14), 2e(t)(A-Kp)e(t) < 0 for A-Kp < 0. It has been shown in previous section that A-Kp < 0 is required for the solution (4) to converge to zero. We now only look at the second integral term. It follows that if e(0)=0 then

In discrete time the term -2Kie(s)ė (s) in (15) can be expressed

where e(k) is the value at current time step and e(k-1) is the value at the previous time step, Ts is the simulation discrete step size and is a positive value. The sign of (16) can be found out as follows:

Assume Ki > 0, then

It has just been shown above that (16) will always be negative when |e(k)|> |e(k-1)| or e(k) and e(k-1) are of different sign. If |e(k)|< |e(k-1)|, the error approaches to zero from either positive or negative side. Reformulating (15) there always exists a positive value Ωi(Ki)> 0 for Ki> 0 that

It has been shown that both terms in (14) are negative, and

Solution of (18) can be presented similarly to (4)

if A-Kpi(Ki)t<0 for t=0, then as time t becomes larger, A-Kpi(Ki)t will become more negative and V→ 0 in (19) and hence e(t)→ 0 . It is now clear to see that the integral control gain Ki >0 is required for the error to be reduced. The integral term minimizes the steady state error as time becomes larger.

A simulation of the closed loop system (11) with A+Kp=-1 and Ki=-1 is shown below

It is shown in the figure that the closed loop system (11) shows an initial overshoot at 2 seconds and then converges to zero as time becomes larger. Between 8 seconds and 20 seconds the steady state error decreases due to integral control.

3. Differential controller

The controller (10) with an additional differential term is

The closed-loop system (1) with (20) becomes

The derivative of the Lyapunov function

is

Substitute (21) into (23)

We now only analyse the derivative term. It turns out the derivative term with Kd in (24) can be analysed like (16) but without the integral term in (17). There exists a Ωd(Kd)>0 such that

Compare (25) and (17), the derivative control energy does not increase with time unlike integral control, but it has a larger control gain at the beginning of the control. Figure 4 shows control performance between P, PI and PID control for a step input. How to tune PID for a specific application would require more techniques to achieve desired control performance. A future post will be written to explain that aspect in more detail.

In summary, it has been shown why all PID control gains need to be positive in order to stabilize a system, otherwise the system will be unstable as shown.

Written by: Xiaoran Han – Project Engineer

Please get in touch if you have any questions or have got a topic in mind that you would like us to write about. You can submit your questions / topics via: Tech Blog Questions / Topic Suggestion.