0% found this document useful (0 votes)
20 views26 pages

Lab Manual 07 LCS 44

This document discusses designing PID controllers for various systems using MATLAB. It presents the code and output for several parts that apply PID control to different transfer functions to achieve desired step responses. Tuning of the PID parameters is explored using hit and trial and Ziegler-Nicholas methods to meet rise time, overshoot and settling time specifications.

Uploaded by

msania654
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)
20 views26 pages

Lab Manual 07 LCS 44

This document discusses designing PID controllers for various systems using MATLAB. It presents the code and output for several parts that apply PID control to different transfer functions to achieve desired step responses. Tuning of the PID parameters is explored using hit and trial and Ziegler-Nicholas methods to meet rise time, overshoot and settling time specifications.

Uploaded by

msania654
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/ 26

LAB NO 7

P, PI, PD and PID controller design using MATLAB

PART# 1

%Tahreem Ali
%20-EE-44
H=1;
den=[1 10 20];
num=1;
Gs=tf(num,den);
GH=feedback(Gs,1);
step(GH);
stepinfo(GH)
suptitle('Tahreem Ali 20-EE-44')
STEP RESPONSE:

Steady state = ss = 0.047


Steady state error = e(t) = 1 – ss
So, e(t)= 1 – 0.047 = 0.953

Rise Time Tr 0.833 s

Settling Time Ts 1.49s

%Overshoot %OS 0%

Steady State error e(t) 95.3%


PART#02

%Tahreem Ali
%20-EE-44
num=[1];
den=[1 10 20];
Gs=tf(num,den)
H=1;
kp=36;
ki=77.6;
kd=0;
C=pid(kp,ki,kd)
sys=feedback(Gs*C,H)
step(sys)
stepinfo(sys)
suptitle('Tahreem Ali 20-EE-44')

STEP RESPONSE:
PART#3 AND 04

CODE: OUTPUT:
%19-EE-006
%NARMEEN ZIA
num=[1];
den=[1 10 20];
Gs=tf(num,den)
H=1;
kp=36;
ki=77.6;
kd=0;
C=pid(kp,ki,kd)
sys=feedback(Gs*C,H)
step(sys)
hold on;
step(Gs)

IMPLEMENTATION USING SIMULINK


Uncompensated:

Compensated
PART#01
%Tahreem Ali
%20-EE-44
H=1;
den=[1 1 0];
num=3;
Gs=tf(num,den);
GH=Gs*H;
step(GH);
stepinfo(GH)
suptitle('Tahreem Ali 20-EE-44')
Rise Time Tr NaN

Settling Time Ts NaN

%Overshoot %OS NaN

Steady State error e(t) -inf


STEP RESPONSE;

PART#02

%Tahreem Ali
%20-EE-44
num=[3];
den=[1 1 0];
Gs=tf(num,den)
H=1;
kp=8;
ki=0;
kd=3.2;
C=pid(kp,ki,kd)
sys=feedback(Gs*C,H)
step(sys)
stepinfo(sys)
suptitle('Tahreem Ali 20-EE-44')
STEP RESPONSE:

ANALYSIS:
We observed that the steady state error was reduced to zero by using a PD Controller. Setting
time has been set to 1s as mentioned in the question by keeping the overshoot percentage less
than 15%
PART#03
%Tahreem Ali
%20-EE-44
num=[3];
den=[1 1 0];
Gs=tf(num,den)
H=1;
kp=8;
ki=0;
kd=3.2;
C=pid(kp,ki,kd)
sys=feedback(Gs*C,H)
step(sys)
stepinfo(sys)
hold on;
step(Gs)
legend('compensated','uncompensated')
suptitle('Tahreem Ali 20-EE-44')

OUTPUT:
PART#04

IMPLEMENTATION USING MATLAB

CODE: OUTPUT:
%20-EE-44
%Tahreem Ali
num=[3];
den=[1 1 0];
Gs=tf(num,den)
H=1;
kp=8;
ki=0;
kd=3.2;
C=pid(kp,ki,kd)
sys=feedback(Gs*C,H)
step(sys)
stepinfo(sys)
hold on;
step(Gs)
legend('compensated','
uncompensated')
suptitle('Tahreem Ali
20-EE-44')
IMPLEMENTATION USING SIMULINK

UNCOMPENSATED:
COMPENSATED:

PART#01,02
%Tahreem Ali
%20-EE-44
Hs=1
num=[1]
den=[44 22 88]
%M=ROLL NUMBER=44
%B=HALF OF ROLL NUMBER=22
%K=TWICE OF ROLL NUMBER=88
GH=tf(num,den)
step(GH)
stepinfo(GH)
suptitle('Tahreem Ali 20-EE-44')

TRANSFER FUNCTION:

STEP RESPONSE:
PART#03
Now connect the system in closed loop with H = 1 and tune PID parameters to
achieve no overshoot, fast rise time with no steady state error
CODE:
%Tahreem Ali
%20-EE-44
clc
clear all
Hs=1
num=[1]
den=[44 22 88]
GH=tf(num,den)
step(GH)
hold on
kp=75
ki=27
kd=9
controller=pid(kp,ki,kd)
sys=feedback(GH*controller,Hs)
step(sys)
step(GH)
stepinfo(sys)
legend('system response without controller','system response with controller')
suptitle('Tahreem Ali 20-EE-44')
OUTPUT:

---------------------------------------------------------------------------------------
PART#01

CODE:

%Tahreem Ali
%20-EE-44
num=[5];
den=[1 52.2 110.4 20];
Gs=tf(num,den)
step(Gs)
stepinfo(Gs)
suptitle('Tahreem Ali 20-EE-44')
STEP RESPONSE:

PART#02
%Tahreem Ali
%20-EE-44
num=[5];
den=[1 52.2 110.4 20];
Gs=tf(num,den);
step(Gs)
stepinfo(Gs)
H=1;
kp=120;
ki=20;
kd=239;
C=pid(kp,ki,kd)
TF=tf(C);
sys=feedback(Gs*TF,H)
step(sys)
suptitle('Tahreem Ali 20-EE-44')

OUTPUT:
PART#03
%Tahreem Ali
%20-EE-44
num = [5];
den = [1 52.2 110.4 20];
Gs = tf(num,den)
H = 1;
Ku = 1130;
Pu = 0.6;
Ti = Pu/2;
Td = Pu/3;
Kp = Ku/5;
Ki = (2/5)*(Ku/Pu);
Kd = (Ku*Pu)/15;
C = pid(Kp, Ki, Kd)
sys = feedback(Gs*C, H)
step(sys);
suptitle('Tahreem Ali 20-EE-44')
PART#04

PARAMETERS: HIT AND TRIAL ZIEGLER NICOLAS

Rise Time 0.0718 0.206

Settling Time 3.55 4.77

%Overshoot 0% 45%

Steady State error 0 0

ANALYSIS:
We observed that we can obtain the desired value of system parameters by changing the values
of P, I and D using a PID controller. Hit and trial method requires a lot of time while Ziegler
method is easy and can be implemented in less time.

PART#05
%Tahreem Ali
%20-EE-44
num = [5];
den = [1 52.2 110.4 20];
Gs = tf(num,den)
H = 1;
Kp = 120;
Ki = 20;
Kd = 239;
C = pid(Kp, Ki, Kd)
sys = feedback(Gs*C, H)
Kuu = 1130;
Puu = 0.6;
Ti = Puu/2;
Td = Puu/3;
Kpp = Kuu/5;
Kii = (2/5)*(Kuu/Puu);
Kdd = (Kuu*Puu)/15;
Cc = pid(Kpp, Kii, Kdd)
sys1 = feedback(Gs*Cc, H)
stepinfo(Gs)
stepinfo(sys)
stepinfo(sys1)
step(Gs);
hold on
step(sys)
step(sys1)
legend('Uncompensated', 'Compensated - Hit & Trial', 'Compensated - ZIEGLER');
suptitle('Tahreem Ali 20-EE-44')
STEP RESPONSE:

UNCOMPENSATED HIT AND TRIAL ZIEGLER NICHOLAS


PART#06
IMPLEMENTATION USING SIMULINK:

Uncompensated response:

Compensated Response:
COMMENTS:
The tuning of PID controller made it possible to reach the suitable values of Kp, Ki, and kd
where these values yield the rise time, overshoot, and settling time in the constrained range. The
output response is almost near to follow the input square wave response, which is evident from
the plot. Initially, we increased the value of kp which increased the overshoot while reduced the
steady state error to some extent then we changed the value of ki in order to reduce the steady
state error, but it also introduced the overshoot and rise the settling time. In the end, to overcome
the over shoot we changed the value of kd to get the output response close to input response

LESSONS LEARNT AND STUDENT COMMENTS:


In this lesson we learnt about PID controllers, how they can change the output of a system. We
learnt how to obtain a system response of desired system parameters by changing the values of P
, I and D of a controller. We achieved this using two methods:

• Hit and Trial Method

• Ziegler Nicholas Method


Moreover, we compared the uncompensated and compensated response

You might also like