summaryrefslogtreecommitdiff
path: root/2048/CH9/EX9.18/ibm_pp_sat.sce
blob: 21ab344c399624b5be8b483efba473bacfdcbed3 (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
75
76
77
78
79
80
81
82
83
84
// Anti windup control (AWC) of IBM Lotus Domino server, studied in Example 9.16 on page 357. It can be used for the follwoing situations: with and without saturation, and with and without AWC.
// 9.18

exec('pp_im2.sci',-1);
exec('desired.sci',-1);
exec('zpowk.sci',-1);
exec('cosfil_ip.sci',-1);
exec('polsplit3.sci',-1);
exec('polmul.sci',-1);
exec('polsize.sci',-1);
exec('xdync.sci',-1);
exec('rowjoin.sci',-1);
exec('left_prm.sci',-1);
exec('t1calc.sci',-1);
exec('indep.sci',-1);
exec('seshft.sci',-1);
exec('makezero.sci',-1);
exec('move_sci.sci',-1);
exec('colsplit.sci',-1);
exec('clcoef.sci',-1);
exec('polyno.sci',-1);
exec('cindep.sci',-1);
exec('poladd.sci',-1);

//  Transfer function
B = 0.47; A = [1 -0.43]; k = 1; 
[zk,dzk] = zpowk(k);
 
// Transient specifications
rise = 10; epsilon = 0.01; Ts = 1;
phi = desired(Ts,rise,epsilon);

// Controller design
delta = [1 -1]; // internal model of step used
[Rc,Sc,Tc,gamm,F] = pp_im2(B,A,k,phi,delta);

// Study of Antiwindup Controller

key = x_choose(['Simulate without any saturation limits'; 
         'Simulate saturation, but do not use AWC'; 
         'Simulate saturation with AWC in place'; 
         'Simulate with AWC, without saturation limits'],...
         ['Please choose one of the following']);

if key ==0
  disp('Invalid choice');
  return;
elseif key == 1
  U = 2; L = -2; P = 1; F = Rc; E = 0; PSc = Sc; PTc = Tc;
elseif key == 2
  U = 1; L = -1; P = 1; F = Rc; E = 0; PSc = Sc; PTc = Tc;
else
  if key == 3 // Antiwindup controller and with saturation
     U = 1; L = -1; 
  elseif key == 4 // Antiwindup controller, but no saturation
     U = 2; L = -2;
  end
  P = A;
  dF = length(F) - 1;
  PRc = convol(P,Rc); dPRc = length(PRc) - 1;
  [E,dE] = poladd(F,dF,-PRc,dPRc);
  PSc = convol(P,Sc); PTc = convol(P,Tc);
end

// Setting up simulation parameters for stb_disc_sat
t_init = 0; // first step begins
st = 1; // height of first step
t_init2 = 500; // second step begins
st2 = -2; // height of second step
t_final = 1000; // simulation end time
st1 = 0; // no disturbance input
C = 0; D = 1; N_var = 0;

[PTcp1,PTcp2] = cosfil_ip(PTc,1); // PTc/1
[Fp1,Fp2] = cosfil_ip(1,F); // 1/F
[Ep,Fp] = cosfil_ip(E,F); // E/F
[PScp1,PScp2] = cosfil_ip(PSc,1); // PSc/1
[Bp,Ap] = cosfil_ip(B,A); // B/A
[zkp1,zkp2] = cosfil_ip(zk,1); // zk/1
[Cp,Dp] = cosfil_ip(C,D); // C/D