You are on page 1of 4

PID Controller

PID controller is named after the term it consists, Proportional, Integral and Derivative. It is
commonly used in control system loop.
Here the desired output value is called the Set Point (SP) and measured value is called Process
Variable (PV), and the output of the PID controller is called Manipulated Variable (MV), the
difference between Set Point (SP) and Process Variable (PV) is the error (e).
After calculating the error the controller decides how to set the Manipulated Variable (MV)

The Manipulated Variable is given by the following formula:

: Proportional gain, a tuning parameter

: Integral gain, a tuning parameter
: Derivative gain, a tuning parameter
: Error
: Time or instantaneous time (the present)
: Variable of integration; takes on values from time 0 to the present

Proportional term

The proportional term produces an output value that is proportional to the current error value.
The proportional response can be adjusted by multiplying the error by a constant Kp, called the
proportional gain constant.
The proportional term is given by:
e (t) = SP-PV
If the proportional gain Kp is high, then the system can become unstable.

Integral term
The integral of a signal is the sum of all the instantaneous values that the signal has been, from
whenever you started counting until you stop counting.
So if you are to plot your signal on a graph and your signal is sampled every second, and lets
say you are measuring temperature. If you were to taking the integral of the signal over the first 5
seconds it would look like this:

The green line is your temperature, the red circles are where your control system has
sampled the temperature, and the blue area is the integral of the temperature signal. It is
the sum of the 5 temperature values over the time period that you are interested in. In
numerical terms it is the sum of the areas of each of the blue rectangles, units are not
(13 x 1)+(14x1)+(13x1)+(12x1)+(11x1) = 63 C s

Now, the integral term is given by

The integral term accelerates the movement of the process towards set point and eliminates the
residual steady-state error that occurs with a pure proportional controller. However, since the integral
term responds to accumulated errors from the past, it can cause the present value to overshoot the
set point value

Derivative term
The derivative of the process error is calculated by determining the slope of the error over time
and multiplying this rate of change by the derivative gain Kd. The derivative term is given by

Derivative is just a mathematical term meaning rate-of-change.

Ex. derivative of reactors pressure is same as the rate of change of reactors pressure. Anyone
who has the required data will easily say About 5 PSI every 10 minutes if before 10 minutes
the value was say, 25 PSI and present value is 30 PSI, irrespective of the intermediate value.
So adding derivative action can allow you to have bigger P and I gains and still keep the loop
stable, giving you a faster response.
Derivative action improves the controller action because it predicts what is yet to happen by
projecting the current rate of change into the future.
The units used for derivative action describe how far into the future you want to look. i.e. If
derivative action is 20 seconds, the derivative term will project the current rate of change 20
seconds into the future.
The big problem with Derivative control is that if you have noise on your signal then, this
confuses the algorithm. It looks at the slope of the noise-spike and thinks that the process is
changing quickly, and keeps adding the D term and control output behaves erratically. We can
try and filter the noise out, but it is best advised that, unless PI control is really slow, dont worry
about switching Derivative on.

The PID terms can be calculated in a program as follows

previous_error = 0;
//Calculation of PID terms
error = set_point measured_value;
integral = integral + error*dt;
derivative = (error-previous_error)/dt;
output = Kp*error + Ki *integral + Kd*derivative;
previous_error = error;
goto loop

Kp, Ki and Kd are predefined.