Professional Documents
Culture Documents
CS LabReport 4
CS LabReport 4
CS LabReport 4
EEE-Control Systems
Lab #04
Class FA18-BSEE-E
Requirements
Software
MATLAB
Methodology
A proportional–integral–derivative controller (PID controller) is the most commonly used
feedback controller in industrial control systems. A PID controller calculates an error
value as the difference between measured output and a desired set point.
The transfer function of the PID controller looks like the following;
In this lab for the designing of PID controller for the given system first of all obtained the
open-loop response and determined what needs to be improved then added a proportional
control to improve the rise time then added a derivative control to improve the overshoot
then added integral control to eliminate the steady state error after that by adjusting the
values of Kp, Ki and Kd obtained the desired overall response.
In lab-tasks first design the PID controller for Mass-Spring Damper Model and then
design the controller for Ball and Beam system according to the given design
requirements.
Conclusion
After this lab I am able to design the PID, PI and PD controller according to the given design
requirements. Also learned that how to adjust the values of Kp, Ki and Kd to get the desired
overall response for the given system.
Lab Report |4
In-Lab Tasks
Task-1: Mass-Spring-Damper Model
Consider the Mass Spring System as discussed in Lab 2, with transfer function
X(s) /Fa(s)= 1/ Ms^2 + bs + k Let the system parameters be, 𝑀 = 1 𝑘𝑔 𝑏 = 10 𝑁.𝑠/𝑚 𝑘 = 20 𝑁/𝑚
𝐹𝑎 = 1𝑁
1. Design a PID controller using any technique learned in this course to achieve the following
Note down the values of proportional, integral and derivative control gains calculated
2.Implement the designed controller in MATLAB and analyse the response of your system
before and after designing the controller. Attach Matlab code and Results.
Solution
%FA18-BEE-093
%task-1
clc
clear all
close all
kp=350
ki=300
kd=50
m=1
b=10
k=20
num=[kd kp ki]
den=[1 0]
num1=[1]
den1=[m b k]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
Lab Report |4
Output
Lab Report |4
As discussed in the previous Lab, the open-loop transfer function of the plant for a ball and beam
System is: X(s) Ɵ (s) = −mgd /L( J/ R^2 + m) 1 /s^2
𝑇𝑠 ≤ 3 𝑠 𝑃𝑂 ≤ 5%
Design a PID Controller to achieve the above criteria. Note down the values of proportional,
integral and derivative control gains calculated.
Implement the designed controller in MATLAB and analyse the response of your system before
and after designing the controller. Attach Matlab code and Results
Solution
%FA18-BEE-093
%task-2
clc
clear all
close all
kp=350
ki=300
kd=50
m=0.111
R=0.015
g=-9.8
L=1.0
d=0.03
J=9.99*10^-6
num=[kd kp ki]
den=[1 0]
num1=[-m*g*d]
den1=[(L*J/R^2)+L*m 0 0]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
Lab Report |4
Output
Lab Report |4
Post-Lab Task
Task-1: Consider a process given below to be controlled by a PID controller,
Solution
%FA18-BEE-093
%postlab-1
%part-a
num=[400]
den=[1 48.5 0]
GP=tf(num,den)
step(GP)
Output
b) Try PI controllers with (𝐾𝑝 = 2,10,100),𝑎𝑛𝑑 𝐾𝑖 = 𝐾𝑝/10. Investigate the unit step
response in each case, compare the results and comment.
Solution
%FA18-BEE-093
%postlab-1
%part-b
clc
clear all
close all
kp=input('enter the value of kp');
ki=input('enter the value of Ki');
kd=input('enter the value of kd');
num=[kd kp ki]
Lab Report |4
den=[1 0]
num1=[400]
den1=[1 48.5 0]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
steadystateerror = abs(dcgain(1 - B))
Output
Lab Report |4
c) Let 𝐾𝑝 = 100,𝐾𝑖 = 10, and add a derivative term with (𝐾𝑑 = 0.1,0.9,2). Investigate the
unit step response in each case, compare the results and comment.
Solution
%FA18-BEE-093
%postlab-1
%part-b
clc
clear all
close all
kp=input('enter the value of kp');
ki=input('enter the value of Ki');
kd=input('enter the value of kd');
num=[kd kp ki]
den=[1 0]
num1=[400]
den1=[1 48.5 0]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
steadystateerror = abs(dcgain(1 - B))
Output
Lab Report |4
d) Based on your results in parts b) and c) above what do you conclude as a suitable PID
controller for this process? Give your justifications.
The PID controller implement in part c is suitable for this process because it has fast warm up
time and accurate set point temperature control and fast reaction to disturbances.
For a 1 rad/sec step input, design a PID controller that satisfies the given criteria:
Solution
%FA18-BEE-093
%postlab-2
clc
clear all
close all
kp=350
ki=300
kd=50
J = 0.01
b = 0.1
K = 0.01
R = 1
Lab Report |4
L = 0.5
num=[kd kp ki]
den=[1 0]
num1=[K]
den1=[J*L (J*R+b*L) (b*R+K^2)]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
steadystateerror = abs(dcgain(1 - B))
Output
Lab Report |4
Task-3: The open-loop transfer function of the DC Motor position is Ɵ /U = K/ s((Js + b)(Ls +
R) + K^2) For a 1 rad/sec step input, design a PID controller
Solution
%FA18-BEE-093
%postlab-3
clc
clear all
close all
kp=350
ki=300
kd=50
J = 0.01
b = 0.1
K = 0.01
R = 1
L = 0.5
num=[kd kp ki]
den=[1 0]
num1=[K]
den1=[J*L (J*R+b*L) (b*R+K^2)]
sys1=tf(num,den)
sys2=tf(num1,den1)
A=series(sys1,sys2)
sys3=1
B=feedback(A,sys3)
step(B)
xlabel('time')
ylabel('amplitude')
pidtool(B,sys1)
steadystateerror = abs(dcgain(1 - B))
Lab Report |4
Output