Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Lab Report CS 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

EEE325– Control Systems

Lab # 04
Design of Proportional-Integral-Derivative (PID) Controller using
MATLAB

Name Ubaid Ur Rehman

Registration Number FA18-BEE-121

Class FA18-BSEE-E

Instructor’s Name Sir Abubakar Talha Jalil

1
LAB #4: Design of Proportional-Integral-Derivative (PID) Controller
using MATLAB
Objective
• To Design PID Controller for different systems
Required:
Software
• MATLAB/LABVEIW

Methodology
In this lab we learn how to design the PID controller using MATLAB. A PID controller calculates an error
value as the difference between measured output and a desired set point. The controller attempts to
minimize the error by adjusting the process control inputs. The transfer function of the PID controller looks
like the following

In this lab while desigining PID controller we follow the following step to obtain a desired step
Obtain an open-loop response and determine what needs to be improved
Add a proportional control to improve the rise time
Add a derivative control to improve the overshoot
Add an integral control to eliminate the steady-state error
Adjust each of 𝐾𝑝,𝐾𝑖,𝑎𝑛𝑑 𝐾𝑑 until you obtain a desired overall response
In this lab we are given with mass spring system with transfer function and had to design a PID controller
to achieve Fast Rise Time, Minimum Overshoot, No Steady-State Error we also design the ball and beam
system .we are given with their transfer function and had to design the PID controller to achieve the given
criteria Implement the designed controller in MATLAB and analyse the response of your system before
and after designing the controller
Lab tasks
Task 1
Mass-Spring-Damper Model
clc
clear all
close all
m=1
b=10
k=20
fa=1
num=[1]
denum=[m b k]
sys2=tf(num,denum)

kd=50
kp=350
ki=300
num1=[kd kp ki]
denum1=[0 1 0]
sys1=tf(num1,denum1)

sys3=series(sys1,sys2)
sys4=feedback(sys3,1,-1)
stepinfo(sys4)
abs(dcgain(1-sys4))
step(sys4)
output

Task 2
Design problem: Ball and Beam System

clc
clear all
close all
m=0.111
r=0.015
g=-9.8
l=1
d=0.03
j=9.99*10^-6
num=[0 0 (-1)*m*g*d]
denum=[l.*(j/r^2+m) 0 0]
sys=tf(num,denum)
kd=5
kp=75
ki=20
num1=[kd kp ki]
denum1=[0 1 0]
sys1=tf(num1,denum1)
sys2=series(sys1,sys)
sys3=feedback(sys2,1,-1)
stepinfo(sys3)
abs(dcgain(1-sys3))
post task
task 1
clc
clearall
closeall
kp1=2
kp2=10
kp3=100
ki1=kp1/1
0
ki2=kp2/1
0
ki3=kp3/1
0 kd=.9
p1=pid(kp1,ki1,kd)
p2=pid(kp2,ki2,kd)
p3=pid(kp3,ki3,kd)
num=[400]
denum=[1 48.5 0]
system=tf(num,denum)
system1=p1.*system
system2=p2.*system
system3=p3.*system
sys1=feedback(system1,1)
sys2=feedback(system2,1)
sys3=feedback(system3,1)
step(system)
figure
subplot(311)
step(sys1)
subplot(312)
step(sys2)
subplot(313)
step(sys3)
stepinfo(system)
stepinfo(sys1)
stepinfo(sys2)
stepinfo(sys3)
output
Part c
clc
clearall
closeall
kp=100
ki=10
kd1=0.1
kd2=0.9
kd3=2
p1=pid(kp,ki,kd1)
p2=pid(kp,ki,kd2)
p3=pid(kp,ki,kd3)
num=[400] denum=[1
48.5 0]

system=tf(num,denum)
system1=p1.*system
system2=p2.*system
system3=p3.*system
sys1=feedback(system1,1)
sys2=feedback(system2,1)
sys3=feedback(system3,1) step(system)
figure subplot(311) step(sys1)
subplot(312) step(sys2)
subplot(313) step(sys3)
stepinfo(system)
stepinfo(sys1)
stepinfo(sys2)
stepinfo(sys3
task 2
clc clearall
closeall
kp=50
ki=3
kd=0.5
p=pid(kp,ki,kd)
K=1
b=10
R=0.01
5 L=1.0
J=9.99*10^-6
num=[K]
denum=[J*L (J*R+b*L) (b*R + K*K)]
system=tf(num,denum) system1=p.*system
sys=feedback(system1,1) step(system)
figure step(sys)
stepinfo(system)
stepinfo(sys)
error_before =abs(dcgain(1-system))
error_after=abs(dcgain(1-sys))

task 3
clc
cleara
ll
closea
ll
kp=100
0
ki=100
0
kd=100
0
p=pid
(kp,k
i,kd)
R=0.0
15
g=9.8
L=1.0
d=0.3
J=9.99*10^-6
num=[1]
denum=[J*L ((J*R)+(L*b)) R*b 1 ]
system=tf(num,denum)
system1=p.*system
sys=feedback(system1,1)
step(system)
figure

step(sys)
stepinfo(system) stepinfo(sys) error=abs(dcgain(1-sys))
CONCLUSION
We learn about the PID controller and how to design in MATLAB. In this lab we learn how to design
different PID controller of different system which include mass spring damper model, ball and beam
system.it also helped to familiarization with systems, their types and transfer function. With the
help of LabVIEW different systems and their combinations were observed and their responses of
different types of inputs were observed. LabVIEW helped to construct the equivalent
mathematical model of a complicated system

You might also like