summaryrefslogtreecommitdiff
path: root/3432/CH6/EX7.29/Ex7_29.sce
blob: a0c479432f452ee5e3303c89efa06985ca890489 (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//Example 7.29
// A reduced order compensator design for a satellite attitude control

xdel(winsid())//close all graphics Windows
clear;
clc;
//------------------------------------------------------------------
// State space representation
F=[0 1;0 0];
G=[0 1]';
H=[1 0];
J=0;
n=sqrt(length(F));//order of the system

//partioned system
Faa=F(1,1); Fab=F(1,2);
Fba=F(2,1); Fbb=F(2,2);
Ga=G(1);Gb=G(2);

// Desired estimator poles
Pe=[-5];
// Observer gain matrix for system 
L=ppol(Fbb',Fab',Pe);
L=L';
disp(L,"L=" );
//------------------------------------------------------------------
//State feedback control law u=-Kx=-(K+[L*k2 0])[y xc]'; 
k1=1; k2=sqrt(2);
K=[k1 k2];
Kc=K+[L*k2 0];
//------------------------------------------------------------------
//compensator differential equation
//xc_dot=(Fbb-L*Fab)*xb_hat + (Fba - L*Faa)*y + (Gb - L*Ga)*u
//xc_dot=((Fbb-L*Fab)-k2)*xc + [(Fba - L*Faa)-(Gb - L*Ga)*(k1+L*k2)+L*(Fbb-L*Fab)]*y 
Fc=(Fbb-L*Fab)-Gb*k2
Fy=(Fba - L*Faa)-(Gb - L*Ga)*(k1+k2*L)+(Fbb-L*Fab)*L
//compensator transfer function
s=poly(0,'s');
Gest=syslin('c',Fy/(s-Fc))//estimator transfer function
Dcr=-[k1+L*k2+k2*Gest]
disp(Dcr,'Dcr','compensator transfer function')
//------------------------------------------------------------------
//Root locus with reduced order compensator
G=1/s^2;
G=syslin('c',G);
exec('./zpk_dk.sci', -1);
[pl,zr Kp]=zpk_dk(Dcr);

Dcr=poly(zr,'s','roots')/poly(pl,'s','roots')
Dcr=syslin('c',Dcr);
evans(G*Dcr)
zoom_rect([-8 -4  2 4])

f=gca();
f.x_location = "origin"
f.y_location = "origin"
xset("color",2);
h=legend('');
h.visible = "off"

//Title, labels and grid to the figure
exec .\fig_settings.sci; //custom script for setting figure properties
title(['Root locus of a reduced order controller and',"$1/s^2$",...
 "process"],'fontsize',3);
//------------------------------------------------------------------
//Frequnecy response for 1/s^2 and compensated

figure,
bode([-Kp*G*Dcr;G],0.01/2/%pi,100/2/%pi,"rad");
title(["Frequency response","$G(s)=1/s^2$", "with a reduced...
 order estimator"],'fontsize',3)
exec .\fig_settings.sci; //custom script for setting figure properties
legend('Compensated','Uncompensated')
//------------------------------------------------------------------