0% found this document useful (0 votes)
4 views46 pages

Ic Lab File Complete

The document outlines various practical tasks involving MATLAB simulations for control systems, including polynomial computations, mechanical systems modeling, circuit analysis, and system responses to different inputs. Each practical task includes objectives, function files, script files, and results, demonstrating the application of control theory concepts. Additionally, it discusses stability analysis using the Routh-Hurwitz criterion and the characteristics of proportional, integral, and derivative controls.

Uploaded by

Ibad Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
4 views46 pages

Ic Lab File Complete

The document outlines various practical tasks involving MATLAB simulations for control systems, including polynomial computations, mechanical systems modeling, circuit analysis, and system responses to different inputs. Each practical task includes objectives, function files, script files, and results, demonstrating the application of control theory concepts. Additionally, it discusses stability analysis using the Routh-Hurwitz criterion and the characteristics of proportional, integral, and derivative controls.

Uploaded by

Ibad Ahmed
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 46

Task: Practical 01

Task
Consider the two polynomials:

Use MATLAB to compute:

a. 𝑝(𝑠)∗𝑞(𝑠)

b. Roots of 𝑝(𝑠) and 𝑞(𝑠)

c. 𝑝 (-1) and 𝑞 (6)

Use MATLAB command to find the partial fraction:

Script File

Result
Question 01
Question 02

Practical 02

Objective
Implement the designing and analysis of mathematical models of physical control systems.

Cruise Speed
Function File

Script File

Result

Spring Mass System


Function File

Script File

Result
Practical 03

Objective
Build the mathematical modelling of Multiple-Element Mechanical Translation System.

Function File
function dXdt=labexperimnt3 (t,X)
Fa=300; %(N)
M1=750; %(Kg)
M2=750; %(Kg)
B1=20; %(Nsec/m)
B2=20; %(Nsec/m)
B3=30; %(Nsec/m)
K1=15; %(N/m)
K2=15; %(N/m)
dXdt(1,1)=X(2);
dXdt(2,1)=-K2/M2*X(1)-((B1+B2)/M2)*X(2)+B3*X(4)/M2;dXdt(3,1)=X(4);
dXdt(4,1)=B3/M1*X(2)-K1/M1*X(3)-((B1+B3)/M1)*X(4)+Fa/M1;

Script File

clear all;
close all;
clc;
X0= [0;0;0;0]; % (Initial xb, Vb, xa, Va)
[t,X]=ode45('labexperimnt3',[0 200],X0);figure;
subplot(2,1,1);
plot(t,X(:,1));
plot(t,X(:,2),'r');
xlabel('Time(t)');
ylabel ('Position xb / Speed Vb');
title ('Mass spring system');
legend ('xb', 'Vb'); grid;
subplot (2,1,2);
plot(t,X(:,3)); hold;
plot(t,X(:,4),'r');
xlabel('Time(t)');
ylabel('Position xa / Speed Va');
title ('Mass spring system');
legend ('xa', 'Va');
grid;
Result

Observation
Task: Practical 03

Task
There is a mechanical rotational system consist of one flywheel J1 is attached by a flexible shaft Kr to ground
and has an applied torque Ꞇa. a second flywheel J2 is driven by friction between the two flywheels Br1. The
second flywheel also has friction to the ground Br2.

Function File
function[dXdt]=functionlab3(t,X)
Ta=300;
J1=750;
J2=750;
Br1=20;
Br2=20;
Kr=15;
dXdt(1,1)=X(2);
dXdt(2,1)=((-Br1/J1)*X(2))+((Br1/J1)*X(4))-((Kr/J1)*X(1))+(Ta/J1);
dXdt(3,1)=X(4);
dXdt(4,1)=((Br1/J2)*X(2))-(((Br1+Br2)/J2)*X(4));
end

Script File
clc,clear all
X0=[0;0;0;0];
[t,X]=ode45('functionlab3',[0,200],X0);
figure;
subplot(2,1,1);hold;
plot(t,X(: , 1) , 'r' );
plot(t,X(: , 2) , 'b' );
xlabel(‘Time(t)' );
ylabel(‘Ang disp/Ang velocity w1');
title('mechanical rotational sys');
grid;
hold;
subplot(2,1,2);hold;
plot(t,X(:,3));
plot(t,X(:,4))
grid;
xlabel('Time(t)');
ylabel( 'Ang disp /Ang velocity w2');
title('mechanical rotational sys');
grid

Result
Practical 04

Objective
Write the function and program of the following circuit diagram. Also explain the plots of the
respective state variables.
Function File
function dXdt=RLC(t,X)
e=60; % (V)
R=10; % (Ohm)
L=1; % (H)
C=10; % (F)
dXdt(1,1) =(1/C)*X(2);
dXdt(2,1) =(-1/L)*X(1)-(R/L)*X(2)+(1/L)*e;

Script File
clear all;
close all;
clc;
X0= [0 0];
[t,X]=ode45('RLC',[ 0 500],X0);
subplot (2,1,1);
plot(t,X(:,1));
legend('Vc');
grid on;
title('Vc');
subplot (2,1,2);
plot(t,X(:,2),'r');
legend('i');
grid on;
title('i');
Result
Task: Practical 04

Task
Write the function and program of the following circuit diagram. Also explain the plots of the respective state
variables.

Function File
function dXdt=lab4(t,X)
e=60; % (V)
R1=10;
R2=10; % (Ohm)
L1=1;
L2=1; % (H)
C=10; % (F)
dXdt(1,1)=((-R1/L1).*X(1))-((1/L1).*X(3))+(e/L1);
dXdt(2,1)=((X(3)/L2))-((R2/L2).*X(2));
dXdt(3,1)=((X(1)/C)-(X(2)/C));

Script File
clear all;
close all;
clc;
X0= [0 0 0];
[t,X]=ode45('lab4',[ 0 500],X0);
subplot (3,1,1);
plot(t,X(:,1));
legend('Vc');
grid on;
title('Vc');
subplot(3,1,2);
plot(t,X(:,2),'r');
legend('i');
grid on;
title('i');
subplot (3,1,3);
plot(t,X(:,3),'r');
legend('e');
grid on
title('e')
Result
Practical 05

Objective
Implement the performance of First order and Second order systems and development of Time
response specification’s function.

Function File

Script File

Result
Task: Practical 05

Task
Given the values of .3re 5R and C, obtain the unit step response of the first order system. a)
R=2KΩ and C=0.01F b) R=2.5KΩ and C=0.003F Verify in each case that the calculated time
constant (τ=RC) and the one measured from the figure as 63% of the final value are same.
Obtain the steady state value of the system.

Script File
clear all;
close all;
clc;
wn=1;
zeta=0.1;
num=wn^2;
den=[1 (2*zeta*wn) wn^2];
step(num,den);
[x,y]=ginput(1);
hold on
wn=1;
zeta=0.3;
num=wn^2;
den=[1 (2*zeta*wn) wn^2];
step(num,den);
hold on
wn=1;
zeta=0.7;
num=wn^2;
den=[1 (2*zeta*wn) wn^2];
step(num,den);
hold on
wn=1;
zeta=1;
num=wn^2;
den=[1 (2*zeta*wn) wn^2];
step(num,den);

Result
Practical 06
Objective:
Try the process to generate the response of Control System to Ramp and Arbitrary Inputs.
Part A:
To calculate the ramp response of the given transfer function.

Script File
close all; clear all; clc;
n= [0 0 30];
d= [1 5 6];
% The ramp response can be obtained by using step command for transfer
% function divided by s.The transfer function G1(s)=G(s)/s.
n1=[0 0 0 30];
d1= [1 5 6 0];
[y,x,t]=step(n1,d1);
% To plot output y vs time t and t vs t i.e ramp signal on same graph window.
v=[0 10 0 10];
plot(t,y);
axis(v);
hold on;
plot(t,t);
grid;
title ('Plot of unit ramp response of G(s)=[30]/[s^2+5s+6]');
xlabel('Time');
ylabel ('Amplitude');
legend('y,t=input,t,t=output')

Part B
To calculate the transfer function for the closed loop control system. Obtain the response of
the system for an input r (t) =e^-0.2t, for t=0 to 9 sec, in steps of 0.15 sec

Script File
clc,clear,close all
n=[1 5];
d=[1 2 3 5];
t=[0:0.15:9];
r=exp(-0.2*t);
y=lsim(n,d,r,t);
plot(t,r,'-',t,y,'o'); grid;
title('plot of the sysytem for arbitrary input r(t)=e-0.2t');
xlabel('Time');
ylabel('Amplitude')

Result
PART A

Part B
Task: Practical 06

Task
Obtain the ramp response of the following transfer function.

Obtain the response of the system for an input and comment your result

Script File
clear all;close all;clc;
%Transfer function
n = [0 0 30];
d = [1 5 6];
%Ramp response for transfer function
%G1(s)=G(s)/s
n1 = [0 0 0 30];
d1 = [1 5 30 0];
[y,x,t] = step(n1,d1);
%Plotting output y vs time t & t vs t i.e ramp signal on same graph window
v = [0 10 0 10];
subplot(2,1,1);
plot(t,y,'b'); %System response
axis(v);
hold on;
plot(t,t,'r--'); %Ramp signal
grid;
title('Plot of System for Arbitrary Input (G(t)=30/(s^2+5*s+6))’);
xlabel('Time'); ylabel('Amplitude');

%System for Arbitrary Input r(t)


t = [0:0.001:15];
r = sin(t) + exp(-0.2 * t);
y=lsim(n,d,r,t);
subplot(2,1,2);
plot(t,r,'b',t,y,'r--');
grid on;
title('Plot of System for Arbitrary Input (r(t)=sin(t)+e^(-0.2t))’);
xlabel('Time'); ylabel('Amplitude');
Result
Task: Practical 07

Task
Example 1:
clear,clc, close all
numg=[1]; deng=[500 0 0]; sysg=tf(numg,deng);
numh=[1 1]; denh=[1 2]; sysh=tf(numh,denh);
sys=series(sysg,sysh);
sys

Example 2:
clear,clc,close all
numg=[1]; deng=[500 0 0]; sys1=tf(numg,deng);
numc=[1 1]; denc=[1 2]; sys2=tf(numc,denc);
sys3=series(sys1,sys2);
sys=feedback(sys3,[1])

Example 3:
clear,clc,close all
numg=[1]; deng=[500 0 0]; sys1=tf(numg,deng);
numh=[1 1]; denh=[1 2]; sys2=tf(numh,denh);
sys = feedback(sys1,sys2);
sys
Task 01: Script File

clear,clc,close all
num1=[1 0];
den1=[0 1];
sys1=tf(num1,den1);
sys2=tf(num1,den1);
sys3=series(sys1,sys2);
num2=[0 1];
den2=[1 0];
sys4=tf(num2,den2);
sys5=parallel(sys3,sys4);
sys6=feedback(sys5,[1]);
sys7=sys4;
sys8=series(sys6,sys7);
sys9=feedback(sys8,sys1)
Result

Task 02: Script File

clear,clc
sys1=tf([0 0 1],[1 0 0]);
sys2=tf([0 50],[1 1]);
sys3=tf([1 0],[0 1]);
sys4=tf([0 2],[1 0]);
sys5=tf([0 2],[0 1]);

sys6=feedback(sys2,sys4);
sys7=parallel(sys3,sys5);
sys8=series(sys7,sys6);
sys9=series(sys8,sys1);
sys10=feedback(sys9,[1])

Result
Lab File: Practical 08

Example Code:
clc,clear
K= 0:0.5:20; % 0 < K < 20
for i=1: length(K) % for loop
q= [1 2 4 K(i)];
p(:,i)=roots(q);
end
figure (1)
plot(real(p),imag(p),'x'),grid on
xlabel('Real axis')
ylabel('lmaginary axis')
gtext('K < 7')
gtext('K = 7')
gtext('K > 7')
k=4
num=1; den=[1 2 4 k];
sysg=tf(num,den);
sys=feedback(sysg,1);
pole(sys) % poles of closed loop system
step(sys,100)

Results:
Step Response:
• K = 7, Marginally Stable

• K > 7, Unstable System

• K < 7, Stable System


Task: Practical 08

Task1
Consider the closed loop system shown in figure 3. Find the range of gain K that willcause
system to be stable, unstable and marginally stable. Plot step response for three values of K.
Script File

clc,clear
K= 0:0.5:20; % 0 < K < 20
for i=1: length(K) % for loop
q= [1 5 (K(i)-3) K(i)];
p(:,i)=roots(q);
end
figure (1)
plot(real(p),imag(p),'x'),grid on
xlabel('Real axis')
ylabel('lmaginary axis')
gtext('K = 4')
gtext('K < 4')
gtext('K > 4')
k=4; %value of K
num=1; den=[1 5 k-3 k];
sysg=tf(num,den);
sys=feedback(sysg,1);
pole(sys) % poles of closed loop system
figure(2)
step(sys,100);
Step Response:

K= 4, Marginally Stable System

K > 4, Stable System


K < 4, Unstable System

Task2
Given the forward-path transfer function of unity-feedback control system

Apply the Routh-Hurwitz criterion to determine the stability of the closed-loop system asa
function of K. Determine the value of K that will cause sustained constant-amplitude
oscillations in the system. Determine the frequency of oscillations.

Script File:
clc,clear
K=0:0.5:20; % 0 < K < 20
for i=1:length(K)
q=[1 2+K(i) 30*K(i) 200*K(i)];
p(:,i)=roots(q);
end
figure(1);
plot(real(p),imag(p),'x');
grid on
xlabel('Real axis');
ylabel('lmaginary axis');
gtext('K = 14/3');
gtext('K > 14/3');
gtext('K < 14/3');
k=14/3;
num=[k 30*k 200*k];
den=[1 2 0 0];
sysg=tf(num,den);
sys=feedback(sysg,1);
pole(sys);
figure(2);
step(sys,100);

14
• K= , Marginally Stable
3
14
• K> , Stable System
3

14
• K< , Unstable System
3
Lab File: Practical 09
Objective:
Trace the characteristics of the each of proportional (P), the integral (I), and the
derivative (D) controls and obtain a desired respons by using them.

Script File:
clear,clc,close all
num=1;
den=[1 10 20];
plant= tf(num,den);
step(plant)
hold on

Kp1=300;
contr1=Kp1;
sys_cl1=feedback(contr1*plant,1); %by default –ve feedback
t=0:0.01:2;
step(sys_cl1,t)

Kp2=300;
Kd1=10;
contr2=tf([Kd1 Kp2],1);
sys_cl2=feedback(contr2*plant,1);
step(sys_cl2,t)

Kp3=30;
Ki1=70;
contr3=tf([Kp3 Ki1],[1 0]);
sys_cl3=feedback(contr3*plant,1);
step(sys_cl3,t)

Kp4=350;
Ki2=300;
Kd4=50;
contr=tf([Kd4 Kp4 Ki2],[1 0]);
sys_cl4=feedback(contr*plant,1);
step(sys_cl4,t)
Results:

Observation
Overshoot
CL Reponse Rise Time Settling time S-S error
Time
Kp 0.0728 0.18 0.772 0.062
Kp and Ki 0.408 0.81 0.618 0
Kp and Kd 0.0779 0.17 0.29 0.062
Kp,Ki and Kd 0.0549 - 0.831 0
Task: Practical 10

Task
Use the plant given

This is a second order system with two real poles located at -5 and -6. Our goal is to speed up
the closed-loop system response so that the two percent settling time is less than 1 second,
produce aposition error of 0.1 or less, and keep percent overshoot less than 10%. To keep
things reasonable, keep the gain, 𝑘𝑘 less than 10 for all designs.
Now make a PID controller with real zeros at -7 and -8. Determine the rootlocus for this
system. Find a value of on this root locus so that percent overshoot is less than 2% and the
settling time is less than 0.02 seconds. (Remember tokeep 𝑘𝑘 < 10.) Save the step response and
the controller that produced it.

Root Locus Plot


Comment
The Percentage overshoot is less than 2% and the settling time is also less than 0.02s. Also, K<10
Task: Practical 11

Task:

Consider the forward-path transfer functions of unity-feedback control system as:

1. Using MATLAB, find frequency response and step response of the system.
2. With the help of MATLAB, determine bandwidth and rise time of the system.
3. For the stated values of zeta and natural frequency in the table below, find bandwidth
and rise time.
4. Analyse the obtained results and find a relationship between time-domain and
frequency domain parameters.
5. Discuss their effect on pole-zero map.

Script File
clear,clc,close all
n=4;
d=[1 3 4];
bode(n,d)
grid on
w_n= input('Enter natural frequency: ');
zeta = input('Enter damping ratio: ');
if zeta >=0.707
M_r=1;
w_r = 0;
else
M_r=1/(2*zeta*sqrt(1-zeta^2));
w_r= w_n* sqrt(1-2*zeta*zeta);
end
BW=w_n*sqrt((1-2*zeta*zeta) +sqrt(4*zeta^4-4*zeta^2+2))
figure
sys=tf(n,d);
step(sys)
grid on
Result
Observation
wn=2
ζ BW Tr

0.1 3.085 0.563

0.2 3.019 0.6028

0.4 2.74 0.732

0.7 2.02 1.06

1 1.287 1.679

ζ=0.75

ωn BW Tr

1 0.9396 2.28
2 1.879 1.14

5 4.69 0.457
10 9.395 0.228

20 18.79 0.114

Time-domain and frequency domain parameters are inversely proportional to one another.
Effect on Pole Zero Map:
The poles are on the left side of the system thus indicating a stable system.
Task: Practical 12
Task:

Design control system for ball and beam system for


the stated requirements.
1. Figures with plots of open loop and closed-loop
step responses.
2. Controller parameters, gain, pole(s), and zero(s),
for each of the controller design along with their
response and compare.
3. Report properly with MATLAB codes and
respective plots based on root locus and bode
methods.
Results:
For very small value of k=0.087, the root locus and overdamped response is shown:
For medium value of k=2.1275, the root locus and under-damped response is shown:
Script File

The obtained root locus is:

The closed loop poles (when gain k=2) are identified as:
-0.371, -1, -0.815+2.18j, and -0.815-2.18j.

You might also like