-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClosed_loop_tf.m
52 lines (41 loc) · 1 KB
/
Closed_loop_tf.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
close all;
%Liquid level control system block diagram transfer functions
%Pump transfer function
Kpm=2; % pump gain
tp=0.2; % time constant
Gpm=tf([0, Kpm],[tp, 1]);
%Valve transfer function
Kv=2.2e-3; % valve gain
x =2; %position of valve
Gv=tf([0, Kv*x],1);
%Tank transfer function
Kt=24.2; % Tank gain
tt=3.3; % time constant
Gt=tf([0, Kt],[tt, 1]);
%Level sensor transfer function
Kl=1; % sensor gain
Gl=tf([0, 1],1);
% Block reduction
OLTF= Gpm*Gv*Gt; % open loop transfer function
CLTF = feedback(OLTF, Gl); %closed loop transfer function
step(CLTF) % step response of un-forced system
title('Un-forced CLS')
stepinfo(CLTF)
% Design of controller
s = tf('s');
figure(1);
rlocus(CLTF) % root locus of system
PD = s + 9.21; % Proportional derivative controller
TF1 = PD * CLTF;
figure(2);
rlocus(TF1)
K = 116.5; % controller gain
TF2 = K * TF1;
TF3 = feedback(TF2,1); % closed loop controller transfer function
figure(3);
step(TF3)
title('Forced CLS')
stepinfo(TF3)
%Stability
figure(4);
margin(TF2) % Bode plot