3213
|
1 # ------------------------------------------------------------ |
|
2 # dhinfdemo Design of a discrete H_infinity controller. |
|
3 # This is not a true discrete design. The design |
|
4 # is carried out in continuous time while the |
|
5 # effect of sampling is described by a bilinear |
|
6 # transformation of the sampled system. |
|
7 # This method works quite well if the sampling |
|
8 # period is "small" compared to the plant time |
|
9 # constants. |
|
10 # |
|
11 # This is a script file for OCTAVE. |
|
12 # ------------------------------------------------------------ |
|
13 # |
|
14 # continuous plant: |
|
15 # 1 |
|
16 # G(s) = -------------- |
|
17 # (s + 2)(s + 1) |
|
18 # |
|
19 # discretised plant with ZOH (Sampling period = Ts = 1 second) |
|
20 # |
|
21 # 0.39958z + 0.14700 |
|
22 # G(s) = -------------------------- |
|
23 # (z - 0.36788)(z - 0.13533) |
|
24 # |
|
25 # +----+ |
|
26 # -------------------->| W1 |---> v1 |
|
27 # z | +----+ |
|
28 # ----|-------------+ || T || => min. |
|
29 # | | vz infty |
|
30 # | +---+ v +----+ |
|
31 # *--->| G |--->O--*-->| W2 |---> v2 |
|
32 # | +---+ | +----+ |
|
33 # | | |
|
34 # | +---+ | |
|
35 # -----| K |<------- |
|
36 # +---+ |
|
37 # |
|
38 # W1 and W2 are the robustness and performancs weighting |
|
39 # functions |
|
40 |
|
41 # K. Mueller, <mueller@ifr.ing.tu-bs.de> |
|
42 # Technical University of Braunschweig, IfR |
3229
|
43 # $Revision: 2.0.0.2 $ $Date: 1998/12/08 23:29:27 $ |
3213
|
44 # |
|
45 |
|
46 echo off |
|
47 disp(" "); |
|
48 disp(" --------------------------------------------------"); |
|
49 disp(" Discrete H_infinity optimal control for the plant:"); |
|
50 disp(" "); |
|
51 disp(" 0.39958z + 0.14700"); |
|
52 disp(" G(s) = --------------------------"); |
|
53 disp(" (z - 0.36788)(z - 0.13533)"); |
|
54 disp(" --------------------------------------------------"); |
|
55 disp(" "); |
|
56 |
|
57 disp("sampling time:") |
|
58 cmd = "Ts = 1.0;"; |
|
59 disp(cmd); |
|
60 eval(cmd); |
|
61 disp("weighting on actuator value u"); |
|
62 cmd = "W1 = wgt1o(0.1, 200.0, 50.0);"; |
|
63 disp(cmd); |
|
64 eval(cmd); |
|
65 disp("weighting on controlled variable y"); |
|
66 cmd = "W2 = wgt1o(350.0, 0.05, 0.0002);"; |
|
67 disp(cmd); |
|
68 eval(cmd); |
|
69 # omega axis (column vector) |
|
70 ww = vec(logspace(-4.99, 3.99, 100)); |
|
71 |
|
72 disp("Create ZOH equivalent model of a continuous plant"); |
|
73 cmd = "G = tf2sys(2,[1 3 2]); Gd = c2d(G, Ts);"; |
|
74 run_cmd |
|
75 |
|
76 # w-plane (continuous representation of the sampled system) |
|
77 disp("W-plane transform of discrete time system:"); |
|
78 cmd = "Gw = d2c(Gd, \"bi\");"; |
|
79 run_cmd |
|
80 |
|
81 disp(" "); |
|
82 disp(" o building P..."); |
|
83 # need One as the pseudo transfer function One = 1 |
|
84 cmd = "One = ugain(1);"; |
|
85 disp(cmd); |
|
86 eval(cmd); |
|
87 cmd = " psys = buildssic([1 4;2 4;3 1],[3],[2 3 5],[3 4],Gw,W1,W2,One);"; |
|
88 run_cmd; |
|
89 disp(" o controller design..."); |
|
90 cmd = "[K, gfin, GWC] = hinfsyn(psys, 1, 1, 0.1, 10.0, 0.02);"; |
|
91 run_cmd |
|
92 |
|
93 disp(" "); |
|
94 fig_n = 1; |
|
95 yn = input(" * Plot magnitudes of W1KS and W2S? [n]: ","S"); |
|
96 if (length(yn) >= 1) |
|
97 if ((yn(1) == "y") || (yn(1) == 'Y')) |
|
98 disp(" o magnitudes of W1KS and W2S..."); |
|
99 gwx = sysprune(GWC, 1, 1); |
|
100 mag1 = bode(gwx, ww); |
|
101 if (columns(mag1) > 1); mag1 = mag1'; endif |
|
102 gwx = sysprune(GWC, 2, 1); |
|
103 mag2 = bode(gwx, ww); |
|
104 if (columns(mag2) > 1); mag2 = mag2'; endif |
|
105 figure(fig_n) |
|
106 fig_n = fig_n + 1; |
|
107 gset grid |
|
108 loglog(ww, [mag1 mag2]); |
|
109 endif |
|
110 endif |
|
111 |
|
112 Kd = c2d(K, "bi", Ts); |
|
113 GG = buildssic([1 2; 2 1], [], [1 2], [-2], Gd, Kd); |
|
114 disp(" o closed loop poles..."); |
|
115 damp(GG); |
|
116 |
|
117 disp(" "); |
|
118 yn = input(" * Plot closed loop step responses? [n]: ","S"); |
|
119 if (length(yn) >= 1) |
|
120 if ((yn(1) == "y") || (yn(1) == 'Y')) |
|
121 disp(" o step responses of T and KS..."); |
|
122 figure(fig_n) |
|
123 step(GG, 1, 10); |
|
124 endif |
|
125 endif |
|
126 |
|
127 # --------- End of dhinfdemo/kpm |