CS LabReport 4

You might also like

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

Lab Report |4

EEE-Control Systems

Lab #04

Design of Proportional-Integral-Derivative (PID) Controller using


MATLAB

Name Muhammad Afzaal

Registration Number FA18-BEE-093

Class FA18-BSEE-E

Instructor’s Name Sir Abubakar Talha Jalil


Lab Report |4

LAB # 4: Design of Proportional-Integral-Derivative (PID)


Controller using MATLAB
Objectives
 Learn how to design PID controller for different systems.

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;

Kp + Ki/s+ Kds = Kds^2 + Kps + Ki/ s here

𝐾𝑝 = 𝑃𝑟𝑜𝑝𝑜𝑟𝑡𝑖𝑜𝑛𝑎𝑙 𝐺𝑎𝑖𝑛 𝐾𝑖 = 𝐼𝑛𝑡𝑒𝑔𝑟𝑎𝑙 𝐺𝑎𝑖𝑛 𝐾𝑑 = 𝐷𝑒𝑟𝑖𝑣𝑎𝑡𝑖𝑣𝑒 𝐺𝑎𝑖𝑛

 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

Fast Rise Time, Minimum Overshoot and No Steady-State Error

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

Task-2: Design Problem: Ball & Beam System

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

The design criteria for this problem are:

𝑇𝑠 ≤ 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,

Gp(s) = 400 /s(s + 48.5)

a) Obtain the unit step response of 𝐺𝑝(𝑠).

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.

Task-2: The open-loop transfer function of the DC Motor speed is

Ɵ̇ /U= K /(Js + b)(Ls + R) + K^2

For a 1 rad/sec step input, design a PID controller that satisfies the given criteria:

 Settling time less than 2 seconds


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

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

 Settling time less than 0.04 seconds


 Overshoot less than 16%
 No steady-state error
 No steady-state error due to a disturbance

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

You might also like