0% found this document useful (0 votes)
47 views12 pages

EEE 4706 Expt 5

The document discusses a control systems engineering lab experiment on studying PID controllers. It provides an overview of PID controllers, explaining that they have proportional, integral and derivative terms. It then presents the transfer function of a PID controller and illustrates how it works in a closed-loop system to minimize error based on feedback. Effects of changing the P, I, and D gains are summarized, and an example problem controlling a spring-mass system with proportional and PD controllers is presented to demonstrate the effects.

Uploaded by

Rummanur Rahad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views12 pages

EEE 4706 Expt 5

The document discusses a control systems engineering lab experiment on studying PID controllers. It provides an overview of PID controllers, explaining that they have proportional, integral and derivative terms. It then presents the transfer function of a PID controller and illustrates how it works in a closed-loop system to minimize error based on feedback. Effects of changing the P, I, and D gains are summarized, and an example problem controlling a spring-mass system with proportional and PD controllers is presented to demonstrate the effects.

Uploaded by

Rummanur Rahad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Islamic University of Technology

Department of Electrical and Electronic Engineering


EEE 4706: Control System Engineering Lab.
Experiment 5: study of PID controller
PID controller stands for proportional (P), derivative (D) and integral (I) controller. In this experiment, we
will study PID controllers and system design using PID controllers. First, we consider a closed loop system.

Here, plant is the system under study. Controller provides necessary excitation to the plant so as to control
the overall closed loop system.
A PID controller has a general three-term transfer function as follows:

( )= + +

+ +
( )=

Here,
=
=
=
First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown
above. The signal e(t) represents the tracking error, the difference between the desired input signal R(t) and
the actual output Y(t). This error signal e(t) will be sent to the PID controller, and the controller computes
both the derivative and the integral of this error signal. The signal u(t) just past the controller is now equal
to the proportional gain (Kp) times the magnitude of the error plus the integral gain (Ki) times the integral
of the error plus the derivative gain (Kd) times the derivative of the error.
Mathematically, the signal u(t) fed to the plant by the controller is given by following time-domain
expression.
( )
( )= ( )+ ( ) +

This signal u(t) will be sent to the plant, and the new output (Y) will be obtained. This new output
(Y) will be sent back again to find the new error signal (e). The controller takes this new error
signal and computes its derivative and its integral again. This process goes on and on.
Note: You can also have P controller, I controller, D controller, PI controller and PD controller.

The characteristics of P, I, and D controllers

A proportional controller (Kp) will have the effect of reducing the rise time and will reduce, but
never eliminate, the steady-state error. An integral control (Ki) will have the effect of eliminating
the steady-state error, but it may make the transient response worse. A derivative control (Kd)
will have the effect of increasing the stability of the system, reducing the overshoot, and
improving the transient response. Effects of each of controllers Kp, Kd, and Ki on a closed-loop
system are summarized in the table shown below.

RISE TIME OVERSHOOT SETTLING TIME S-S ERROR


Kp Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Eliminate
Kd Small Change Decrease Decrease Small Change

Note: These correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent of
each other. In fact, changing one of these variables can change the effect of the other two. Thus,
instead of treating this table as a verdict, you should use it as a heuristic guide when you perform
simulation to find the values of Kp, Ki and Kd.

Homework (you do NOT have to submit this one):

Many of the observations in the above table are empirical (experimental). However, some of them
can be explained by the theory you have studied in EEE 4705. Try to verify the table wherever
possible. For example, insertion of Ki eliminates S-S error. You can verify this observation.
Insertion of Ki term essentially adds a pole in the system. What would happen to steady-state error
when a pole is inserted to the system? Can you explain it from the order-of-system point of view?
Some of the observations in this table can be explained using root-locus theory.

Example Problem

Suppose we have a simple mass, spring, and damper problem.


The modeling equation of this system is

( ) ( )
( )= + + ( )

The transfer function is given by (you must verify at our own)

( ) 1
=
( ) + +

We assume following values of the parameters:

M = 1Kg, b = 10 Ns/m, k = 20N/m and F = 1N.

First, let us see the response of the system using the following simulation code.

num = 1;
M = 1; b = 10; k = 20;
den = [M b k];
step(num,den)
title('respose of the open loop system')

Now, you can check the rise time, steady-state error and other parameters from the diagram. To
do this, right click on any white segment of the plot. Select ‘characteristics’ and select your desired
parameter. For example, if you wish to compute the rise time, select ‘rise time’ and you will see
that a pair of grid-lines has appeared in the diagram. Take your cursor over the blue dot and it will
show the value of rise-time. (This lab note was prepared using MATLAB r2010a, for other
versions this might differ)

respose of the open loop system


0.05

0.045
System: sys
0.04 Rise Time (sec): 0.884

0.035

0.03
Amplitude

0.025

0.02

0.015

0.01

0.005

0
0 0.5 1 1.5 2 2.5
Time (sec)
Using this technique, we see that 0.05 is the final value of the output to a unit step input. This
corresponds to the steady-state error of 0.95 which is significantly huge (95%). Furthermore, the
rise time is about one second, and the settling time is about 1.5 seconds. Let's design a controller
that will reduce the rise time, reduce the settling time, and eliminates the steady-state error.

Control of the spring-mass system using feedback:

First, insert a feedback in the system and simulate the response.

[numC denC] = cloop(num,den);


figure
step(numC,denC);
title('response of the system in the closed loop')

response of the system in the closed loop


0.05

0.045

0.04

0.035

0.03
Amplitude

0.025

0.02

0.015

0.01

0.005

0
0 0.5 1 1.5 2 2.5
Time (sec)

We see that some of the parameters, in fact, got worsened. So, we will insert a controller in the
forward path of the system. First, we use a proportional controller.

Control of the spring-mass system using proportional controller:

Insertion of a proportional term in the forward path changes the overall open loop transfer function
to

( ) 1
=
( ) + +
Assume that we are using a gain of 300. At this point, we are using arbitrary gains values. Later,
we will move to more sophisticated method.

Kp = 300;
num = Kp;
M = 1; b = 10; k = 20;
den = [M b k];

[numC denC] = cloop(num,den);


figure
step(numC,denC);
title('response with a proportional term')

response w ith a proportional term


1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4
Time (sec)

The above plot shows that the proportional controller reduced both the rise time and the steady-
state error, increased the overshoot, and decreased the settling time by small amount.

To reduce the overshoot, we insert a derivative term in our controller. So, now we have a
proportional-derivative controller in our system.

Control of the spring-mass system using proportional-derivative (PD) controller:

Now, our overall open-loop transfer function is

( ) 1
=( + )
( ) + +

Assume a derivative gain of 10.

Kp = 300;
Kd = 10;
num = [Kd Kp];
M = 1; b = 10; k = 20;
den = [M b k];

[numC denC] = cloop(num,den);


figure
step(numC,denC);
title('response with a PD controller')

response w ith a PD controller


1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6
Time (sec)

This plot shows that the derivative controller reduced both the overshoot and the settling time,
and had small effect on the rise time and the steady-state error.

Control of the spring-mass system using proportional-integral (PI) controller:

Before going into a PID control, let's take a look at a PI control. From the table, we see that an
integral controller (Ki) decreases the rise time, increases both the overshoot and the settling
time, and eliminates the steady-state error.

For a PI controller, the overall open loop transfer function is given by

( ) 1
=( + )
( ) + +

( ) +
=
( ) + +
Assume an integral gain of 70.

Kp = 300;
Ki = 70;
num = [Kp Ki];
M = 1; b = 10; k = 20;
den = [M b k 0];

[numC denC] = cloop(num,den);


figure
step(numC,denC);
title('response with a PI controller')

response w ith a PI controller


1.4

1.2

0.8
Amplitude

0.6

0.4

0.2

0
0 0.5 1 1.5 2 2.5 3 3.5
Time (sec)

We have reduced the proportional gain (Kp) because the integral controller also reduces the
rise time and increases the overshoot as the proportional controller does (double effect). The
above response shows that the integral controller eliminated the steady-state error.

Control of the spring-mass system using PID controller:

Now, we will add all terms of a PID controller in our system. So, the overall open loop transfer
function of the system will be as follows:

( ) 1
=( + + )
( ) + +

( ) 2
+ + 1
=( )
( ) + +
( ) 2
+ +
=
( ) + +

We will use the values of Kp=350, Ki=300, and Kd=50. These value were obtained using many
trials and errors. In later sections, we will use a better method.

Kp = 350;
Ki = 300;
Kd = 50;
num = [Kd Kp Ki];
M = 1; b = 10; k = 20;
den = [M b k 0];

[numC denC] = cloop(num,den);


figure
step(numC,denC);
title('response with a PID controller')

response w ith a PID controller


1

0.9

0.8

0.7

0.6
Amplitude

0.5

0.4

0.3

0.2

0.1

0
0 0.5 1 1.5 2 2.5
Time (sec)

When you are designing a PID controller for a given system, follow the steps shown below to
obtain a desired response.

1. Obtain an open-loop response and determine what needs to be improved


2. Add a proportional control to improve the rise time
3. Add a derivative control to improve the overshoot
4. Add an integral control to eliminate the steady-state error
5. Adjust each of Kp, Ki, and Kd until you obtain a desired overall response.

Note: please keep in mind that you do not need to implement all three controllers (proportional,
derivative, and integral) into a single system, if not necessary. For example, if a PI controller gives
a good enough response (like the above example), then you don't need to implement derivative
controller to the system. Keep the controller as simple as possible.

Code for performing trails for selections of Kp, Kd and Ki:

You need to perform many rounds of trails to select the appropriate values of Kp, Kd and Ki.
Instead of running the codes separately over and over again, you can automate the process and
make it user-friendly.

M = 1; b = 10; k = 20;
Kd = 100; Kp = 100; Ki = 100;

while(1)
num = [Kd Kp Ki];
den = [M b k 0];
step(num,den)

i = input('Does the system fulfill the design objectives? [1/0]');


if i == 1
break
else
Kp = input('change the Kp');
Ki = input('change the Ki');
Kd = input('change the Kd');
end
end

Automatic tuning of PID controller using Simulink:

The process of selection of parameters in PID is tedious. Using Simulink this task can be
accomplished in a much easier way.

1. Build the model of the given system in Simulink.

PID(s) tf(1,[1 10 20])

Step PID Controller spring-damper system Scope

2. Now, double click the PID controller box. Following window will appear.
Here, the default value of the controller gains are given. You can also change the controller to a PI
or PD as needed.

3. Click on the “Tune” button to for graphical tuning of the parameters. A new window will
appear. Click on the arrow sign next to ‘Show parameters’ on window.

This window shows the parameters of the system such as rise time, overshoot etc along with Kp,
Kd, Ki values of the PID controller on the right side. You can tune the system by using the
interactive tuner on the bottom.
4. You can change the shape of the response by interactive tuning. You will see the responses
without tuning (“block response” with default PID parameters) and with the tuned
parameters. Corresponding controller gain values are seen on the right.

5. If you have found a desired and controlled response, select ‘Apply’. Now, again double-
click on the PID controller block in your model to see that the appropriate gain values have
been selected. Finally, from the scope see that the response is indeed the selected response.

Assignment: (submit printed/hand-written copies)

1. Using a PID controller, control a DC motor system (see previous class lecture) for less than
5% overshoot, less than 1 second rise time, less than 5 second settling time and less than
1% S-S error. Perform this task by manual method using MATLAB coding. Report the
controller gain values. Then use Simulink to perform the same task and report the values.
2. Discuss the reason of reduction (or elimination) of steady-state error when a Ki term is
added to the controller function.
Optional Project
We have semi-automated the trial and error process of finding the controller gain values using a
rudimentary code containing a while loop. Can you build a MATLAB GUI that does the following
tasks?

a. Receives the numerator and denominator coefficients of the transfer function from the
user. It should be flexible enough to take the coefficients in the factored format as well
e.g.: (s+1)/(s+2)(s+3). In that case, it will perform the convolution in the background
to expand the factors.
b. It will accept the values of desired overshoot, rise time, settling time and steady-state
error.
c. It will plot the step response of the system in closed loop inserting a PID controller in
the forward path. It will also show the current values of overshoot, rise time, settling
time and steady-state error.
d. It will compare the values in step b and step c and use the table in the page 2 of this lab
note to guide the user with such instructions: “increase Kp”, “decrease Ki” etc.
e. It will keep repeating the step d until the design requirements are met.
f. Feel free to insert any number of features/ modifications to the GUI.

You must NOT use Simulink for this purpose. It might not be possible to design such a system
with perfection since the table in page 2 is not accurate all the time. But, try your best.

To submit this “optional project”, talk to any of your class teachers.

Rifat Ahmed
Lecturer
EEE, IUT

You might also like