[go: up one dir, main page]

0% found this document useful (0 votes)
47 views12 pages

FCS Lab

This document contains the lab tasks and code for analyzing a feedback control system. It includes code to model and simulate a RLC circuit, a mass-spring system, and a second order system. It also contains the transfer functions and block diagrams for the systems. Differential equations are provided for the mass-spring system. Plots of the simulation outputs are included to show the behavior of the state variables over time for the RLC circuit and position/velocity for the mass-spring system.

Uploaded by

dfdafdsfasdg
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)
47 views12 pages

FCS Lab

This document contains the lab tasks and code for analyzing a feedback control system. It includes code to model and simulate a RLC circuit, a mass-spring system, and a second order system. It also contains the transfer functions and block diagrams for the systems. Differential equations are provided for the mass-spring system. Plots of the simulation outputs are included to show the behavior of the state variables over time for the RLC circuit and position/velocity for the mass-spring system.

Uploaded by

dfdafdsfasdg
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/ 12

NED University of Engineering & Technology Department

of Electrical Engineering

LAB TASKS OF FEEDBACK CONTROL SYSTEMS(EE-374)

Group Members:
Talha Amjad EE -18159 Sec : D
Muzammil Mehmood EE - 18157 Sec : D
Haris Zafar EE - 18160 Sec : D
Bilal Hussain Alvi EE - 18165 Sec : D
CODE:
First we create this file:
function dXdt=rlc_ckt(t,X)
R1=5; % (Kg)
R2=8; % (Kg)
L1=2; % (Nsec/m)
L2=1; % (N)
C=7; % (N/m)
dXdt(1,1)=(-R1/L1)*X(1)-(1/L1)*X(3)+1/L1;
dXdt(2,1)=-(R2/L2)*X(2)-(1/L1)*X(3);
dXdt(3,1)=(1/C)*X(1)-(1/C)*X(2);
Then, we Create a file to type the code name with file name rlc_ckt1:
clear all
close all
clc
X0=[0;0;0];% (Initial speed and position)
[t,X]=ode45('rlc_ckt',[0 50],X0);
figure;
subplot(2,1,1);
plot(t,X(:,1),'r');
hold;
plot(t,X(:,2),'b');
%hold;
plot(t,X(:,3),'g');
xlabel('Time(t)');
ylabel('Position xb / Speed Vb');
legend('i1', 'i2','vc');
title('Plot of RLC Circuit');
grid;
Explanation of State Variables:
There are three state variables in a system i.e; i1, i2 and vc. After the calculation of
these state variables and by graph we can say that initially when t=0s all three state
variables are zero but when the time will t>0s then all state variables will increase and
after sometime i1 and i2 will decrease by time but the vc variable will increase with
respect to time.

OUTPUT :
Q2) Plot the Equations of Mechanical Systems of Lab 3 and Check the
equations for Displacement or Velocity?
Solution:
Code:
First we Create a file with name lab_2:
function dXdt=mass_spring_system (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;
Then, Create second file with name lab_21 to type following code:
clear all;
close all;
clc;
X0=[0;0;0;0]; % (Initial xb, Vb, xa, Va)
[t,X]=ode45('lab_2',[0 200],X0);
figure;
subplot(2,1,1);
plot(t,X(:,1),'g');
hold;
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),'g');
hold;
plot(t,X(:,4),'r');
xlabel('Time(t)');
ylabel('Position xa / Speed Va');
title('Mass spring system');
legend('xa', 'Va');
grid;
Output Graph:
Q3)

Differential Equations For The System:


Differential Equation of system is,
�2 �(�) ��(�)
� +� + �� � = �� (�)
�� ��

Transfer Functions For the above system is:


�(�) �
��� �������� = = 2
�(�) �� + �� + �
�(�) 1
��� �������� = = 2
�(�) �� + �� + �
Parameter of system are given below,
M=10 kg
K=7 N/m
B=23 N.s/m.

�(�) �
��� �������� = =
�(�) 10�2 + 7� + 23
�(�) 1
��� �������� = =
�(�) 10�2 + 7� + 23
MODEL:

RESPONSE:
Code:

For the First Part of Question:


close all;
clear all;
clc;
n=[0 0 30];
d=[1 5 30];
% 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 30 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+30]');
xlabel('Time');
ylabel('Amplitude');
Response of System:
Code:
For the Second Part of Question:
n=[30];
d=[1 5 30];
t=0:0.001:15;
r=sin(t)+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)=sint+e-
0.2t');
xlabel('Time');
ylabel('Amplitude');

System Response:
Code :
s=tf('s');
G1=tf(1,[1 10]);
G2=tf(1,[1 1]);
G3=tf([1 0 1],[1 4 4]);
G4=tf([1 1],[1 6]);
H1=tf([1 1],[1 2]);
H2=1;
P1=feedback(series(G2,G4),G3);
P2=feedback(G1,H1);
sys=feedback(series(P1,P2),H2)
figure()
pzmap(sys)
Transfer Function :

POLE & ZERO MAP:

You might also like