annotate scripts/control/dhinfdemo.m @ 3431:99ab64f4a09d

[project @ 2000-01-14 03:53:03 by jwe]
author jwe
date Fri, 14 Jan 2000 04:12:41 +0000
parents 8625164a0a39
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3398
0f515bc98460 [project @ 1999-12-18 04:21:28 by jwe]
jwe
parents: 3397
diff changeset
1 ## Copyright (C) 1996, 1998 Kai P. Mueller
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
2 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
3 ## This file is part of Octave.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
4 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
6 ## under the terms of the GNU General Public License as published by the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
8 ## later version.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
9 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
13 ## for more details.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
14 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
15 ## You should have received a copy of the GNU General Public License
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
3236
98e15955107e [project @ 1999-03-05 07:17:10 by jwe]
jwe
parents: 3229
diff changeset
18
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
19 ## ------------------------------------------------------------
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
20 ## dhinfdemo Design of a discrete H_infinity controller.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
21 ## This is not a true discrete design. The design
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
22 ## is carried out in continuous time while the
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
23 ## effect of sampling is described by a bilinear
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
24 ## transformation of the sampled system.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
25 ## This method works quite well if the sampling
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
26 ## period is "small" compared to the plant time
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
27 ## constants.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
28 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
29 ## This is a script file for OCTAVE.
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
30 ## ------------------------------------------------------------
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
31 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
32 ## continuous plant:
3425
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
33 ## 1
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
34 ## G(s) = --------------
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
35 ## (s + 2)(s + 1)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
36 ##
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
37 ## discretised plant with ZOH (Sampling period = Ts = 1 second)
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
38 ##
3425
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
39 ## 0.39958z + 0.14700
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
40 ## G(s) = --------------------------
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
41 ## (z - 0.36788)(z - 0.13533)
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
42 ##
3425
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
43 ## +----+
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
44 ## -------------------->| W1 |---> v1
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
45 ## z | +----+
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
46 ## ----|-------------+ || T || => min.
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
47 ## | | vz infty
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
48 ## | +---+ v +----+
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
49 ## *--->| G |--->O--*-->| W2 |---> v2
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
50 ## | +---+ | +----+
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
51 ## | |
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
52 ## | +---+ |
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
53 ## -----| K |<-------
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
54 ## +---+
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
55 ##
3425
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
56 ## W1 and W2 are the robustness and performancs weighting
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
57 ## functions
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
58
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
59 ## K. Mueller, <mueller@ifr.ing.tu-bs.de>
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
60 ## Technical University of Braunschweig, IfR
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
61
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
62 echo off
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
63 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
64 disp(" --------------------------------------------------");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
65 disp(" Discrete H_infinity optimal control for the plant:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
66 disp(" ");
3425
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
67 disp(" 0.39958z + 0.14700");
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
68 disp(" G(s) = --------------------------");
8625164a0a39 [project @ 2000-01-13 08:31:37 by jwe]
jwe
parents: 3398
diff changeset
69 disp(" (z - 0.36788)(z - 0.13533)");
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
70 disp(" --------------------------------------------------");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
71 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
72
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
73 disp("sampling time:")
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
74 cmd = "Ts = 1.0;";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
75 disp(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
76 eval(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
77 disp("weighting on actuator value u");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
78 cmd = "W1 = wgt1o(0.1, 200.0, 50.0);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
79 disp(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
80 eval(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
81 disp("weighting on controlled variable y");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
82 cmd = "W2 = wgt1o(350.0, 0.05, 0.0002);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
83 disp(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
84 eval(cmd);
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
85 ## omega axis (column vector)
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
86 ww = vec(logspace(-4.99, 3.99, 100));
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
87
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
88 disp("Create ZOH equivalent model of a continuous plant");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
89 cmd = "G = tf2sys(2,[1 3 2]); Gd = c2d(G, Ts);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
90 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
91
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
92 ## w-plane (continuous representation of the sampled system)
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
93 disp("W-plane transform of discrete time system:");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
94 cmd = "Gw = d2c(Gd, \"bi\");";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
95 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
96
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
97 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
98 disp(" o building P...");
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
99 ## need One as the pseudo transfer function One = 1
3213
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
100 cmd = "One = ugain(1);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
101 disp(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
102 eval(cmd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
103 cmd = " psys = buildssic([1 4;2 4;3 1],[3],[2 3 5],[3 4],Gw,W1,W2,One);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
104 run_cmd;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
105 disp(" o controller design...");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
106 cmd = "[K, gfin, GWC] = hinfsyn(psys, 1, 1, 0.1, 10.0, 0.02);";
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
107 run_cmd
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
108
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
109 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
110 fig_n = 1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
111 yn = input(" * Plot magnitudes of W1KS and W2S? [n]: ","S");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
112 if (length(yn) >= 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
113 if ((yn(1) == "y") || (yn(1) == 'Y'))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
114 disp(" o magnitudes of W1KS and W2S...");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
115 gwx = sysprune(GWC, 1, 1);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
116 mag1 = bode(gwx, ww);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
117 if (columns(mag1) > 1); mag1 = mag1'; endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
118 gwx = sysprune(GWC, 2, 1);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
119 mag2 = bode(gwx, ww);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
120 if (columns(mag2) > 1); mag2 = mag2'; endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
121 figure(fig_n)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
122 fig_n = fig_n + 1;
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
123 gset grid
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
124 loglog(ww, [mag1 mag2]);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
125 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
126 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
127
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
128 Kd = c2d(K, "bi", Ts);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
129 GG = buildssic([1 2; 2 1], [], [1 2], [-2], Gd, Kd);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
130 disp(" o closed loop poles...");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
131 damp(GG);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
132
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
133 disp(" ");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
134 yn = input(" * Plot closed loop step responses? [n]: ","S");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
135 if (length(yn) >= 1)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
136 if ((yn(1) == "y") || (yn(1) == 'Y'))
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
137 disp(" o step responses of T and KS...");
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
138 figure(fig_n)
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
139 step(GG, 1, 10);
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
140 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
141 endif
ba1c7cdc6090 [project @ 1998-11-06 16:15:36 by jwe]
jwe
parents:
diff changeset
142
3381
69b167451491 [project @ 1999-12-15 20:48:10 by jwe]
jwe
parents: 3284
diff changeset
143 ## --------- End of dhinfdemo/kpm