0% found this document useful (0 votes)
28 views

Control-System-Lab-6 New

Uploaded by

salah g
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Control-System-Lab-6 New

Uploaded by

salah g
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Design of Proportional - Integral - Derivative (PID) controller

Aim : To design Proportional- Integral- Derivative Controller.

Key MATLAB commands used are: tf , step , pid , feedback , pidtool , pidtune

In this , we will consider the following unity feedback system:

The transfer function of a PID controller is found by taking the Laplace transform of Eq.(1).

(2)

= Proportional gain = Integral gain = Derivative gain

We can define a PID controller in MATLAB using the transfer function directly, for example:

Kp = 1;
Ki = 1;
Kd = 1;

s = tf('s');
C = Kp + Ki/s + Kd*s
C =

s^2 + s + 1
-----------
s

Continuous-time transfer function.

Alternatively, we may use MATLAB's pid controller object to generate an equivalent contin

C = pid(Kp,Ki,Kd)
C =

1
Kp + Ki * --- + Kd * s
s

with Kp = 1, Ki = 1, Kd = 1
The control signal ( ) to the plant is equal to the proportional gain ( ) times the magnitude of
the error plus the integral gain ( ) times the integral of the error plus the derivative gain ( )
times the derivative of the error.

This control signal ( ) is sent to the plant, and the new output ( ) is obtained. The new output ( )
is then fed back and compared to the reference to find the new error signal ( ). The controller
takes this new error signal and computes its derivative and its integral again, ad infinitum.

The transfer function of a PID controller is found by taking the Laplace transform of Eq.(1).

(2)

= Proportional gain = Integral gain = Derivative gain

We can define a PID controller in MATLAB using the transfer function directly, for example:

Kp = 1;
Ki = 1;
Kd = 1;

s = tf('s');
C = Kp + Ki/s + Kd*s
C =

s^2 + s + 1
-----------
s

Continuous-time transfer function.

Alternatively, we may use MATLAB's pid controller object to generate an equivalent contin

C = pid(Kp,Ki,Kd)
C =

1
Kp + Ki * --- + Kd * s
s

with Kp = 1, Ki = 1, Kd = 1

Continuous-time PID controller in parallel form.

Let's convert the pid object to a transfer function to see that it yields the same result as above:

tf(C)
ans =

s^2 + s + 1 -----------
s

Continuous-time transfer function.

The Characteristics of P, I, and D Controllers


A proportional controller ( ) will have the effect of reducing the rise time and will reduce but
never eliminate the steady-state error. An integral control ( ) will have the effect of
eliminating the steady-state error for a constant or step input, but it may make the transient
response slower. A derivative control ( ) will have the effect of increasing the stability of the
system, reducing the overshoot, and improving the transient response.

The effects of each of controller parameters, , , and on a closed-loop system are


summarized in the table below.

CL RESPONSE RISE TIME OVERSHOOT SETTLING TIME S-S ERROR


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

Note that these correlations may not be exactly accurate, because , , and are dependent on
each other. In fact, changing one of these variables can change the effect of the other two. For
this reason, the table should only be used as a reference when you are determining the values for
, and .

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

The modeling equation of this system is

(3)
Taking the Laplace transform of the modeling equation, we get

(4)

The transfer function between the displacement and the input then becomes

(5)

Let

M = 1 kg
b = 10 N s/m
k = 20 N/m
F = 1 N

Plug these values into the above transfer function

(6)

The goal of this problem is to show you how each of , and contributes to obtain

Fast rise time


Minimum overshoot
No steady-state error
Open-Loop Step Response
Let's first view the open-loop step response. Create a new m-file and run the following code:

s = tf('s');
P = 1/(s^2 + 10*s + 20);
step(P)
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the output to an
unit step input. This corresponds to the steady-state error of 0.95, quite large indeed.
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 eliminate the
steady-state error.

Proportional Control
From the table shown above, we see that the proportional controller (Kp) reduces the rise time,
increases the overshoot, and reduces the steady-state error.

The closed-loop transfer function of the above system with a proportional controller is:

(7)

Let the proportional gain ( ) equal 300 and change the m-file to the following:

Kp = 300;
C = pid(Kp)
T = feedback(C*P,1)

t = 0:0.01:2;
step(T,t)
C =

Kp = 300

P-only controller.

T =

300
----------------
s^2 + 10 s + 320

Continuous-time transfer function.

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

Proportional-Derivative Control
Now, let's take a look at a PD control. From the table shown above, we see that the derivative
controller (Kd) reduces both the overshoot and the settling time. The closed-loop transfer
function of the given system with a PD controller is:
(8)

Let equal 300 as before and let equal 10. Enter the following commands into an m-file and
run it in the MATLAB command window.

Kp = 300;
Kd = 10;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)

t = 0:0.01:2;
step(T,t)
C =

Kp + Kd * s

with Kp = 300, Kd = 10

Continuous-time PD controller in parallel form.

T =

10 s + 300
----------------
s^2 + 20 s + 320

Continuous-time transfer function.


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

Proportional-Integral Control

Now, let's take a look at a PD control. From the table shown above, we see that the derivative
controller (Kd) reduces both the overshoot and the settling time. The closed-loop transfer
function of the given system with a PD controller is:

(8)

Let equal 300 as before and let equal 10. Enter the following commands into an m-file and
run it in the MATLAB command window.

Kp = 300;
Kd = 10;
C = pid(Kp,0,Kd)
T = feedback(C*P,1)

t = 0:0.01:2;
step(T,t)
C =
Kp + Kd * s

with Kp = 300, Kd = 10

Continuous-time PD controller in parallel form.

T =

10 s + 300
----------------
s^2 + 20 s + 320

Continuous-time transfer function.

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

Proportional-Integral-Derivative Control

v 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 the given system, the closed-loop transfer function with
a PI control is:
(9)

Let's reduce the to 30, and let equal 70. Create an new m-file and enter the following
commands.

Kp = 30;
Ki = 70;
C = pid(Kp,Ki)
T = feedback(C*P,1)
t = 0:0.01:2;
step(T,t)
C =

1
Kp + Ki * ---
s

with Kp = 30, Ki = 70

Continuous-time PI controller in parallel form.

T =

30 s + 70
------------------------
s^3 + 10 s^2 + 50 s + 70

Continuous-time transfer function.


PID Design Method for DC Motor Speed
Control
From the main problem, the dynamic equations and the open-loop transfer
function of the DC Motor are:

and the system schematic looks like:

For the original problem setup and the derivation of the above equations,
please refer to the Modeling a DC Motor page.

With a 1 rad/sec step input, the design criteria are:

 Settling time less than 2 seconds


 Overshoot less than 5%
 Steady-stage error less than 1%

Now let's design a PID controller and add it into the system. First create a
new m-file and type in the following commands (refer to the Modeling page
for the details of getting these commands).
J=0.01;
b=0.1;
K=0.01;
R=1;
L=0.5;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
Recall that the transfer function for a PID controller is:

Proportional control
Let's first try using a proportional controller with a gain of 100. Add the
following code to the end of your m-file:
Kp=100;
numa=Kp*num;
dena=den;

To determine the closed-loop transfer function, we use the cloop command.


Add the following line to your m-file:
[numac,denac]=cloop(numa,dena);

Note that numac and denac are the numerator and the denominator of the
overall closed-loop transfer function.

Now let's see how the step response looks, add the following to the end of
your m-file, and run it in the command window:
t=0:0
step(numac,denac,t)
title('Step response with Proportion Control')

You should get the following plot:


PID control
From the plot above we see that both the steady-state error and the
overshoot are too large. Recall from the PID tutorial page that adding an
integral term will eliminate the steady-state error and a derivative term will
reduce the overshoot. Let's try a PID controller with small Ki and Kd.
Change your m-file so it looks like the following. Running this new m-file
gives you the following plot.

J=0.01;
b=0.1;
K=0.01;
R=1;
L=0.5;
num=K;
den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];

Kp=100;
Ki=1;
Kd=1;
numc=[Kd, Kp, Ki];
denc=[1 0];
numa=conv(num,numc);
dena=conv(den,denc);
[numac,denac]=cloop(numa,dena);
step(numac,denac)
title('PID Control with small Ki and Kd')
Tuning the gains
Now the settling time is too long. Let's increase Ki to reduce the settling
time. Go back to your m-file and change Ki to 200. Rerun the file and you
should get the plot like this:

Now we see that the response is much faster than before, but the large Ki
has worsened the transient response (big overshoot). Let's increase Kd to
reduce the overshoot. Go back to the m-file and change Kd to 10. Rerun it
and you should get this plot:
So now we know that if we use a PID controller with

Kp=100,
Ki=200,
Kd=10,

all of our design requirements will be satisfied.

You might also like