Debian Codegraph @

texmf-dist/doc/latex/circuit-macros/examples/dpv/controlDPV.m4

raw
1 .PS
2 # controlDPV.m4
3 gen_init(svg_font(Times,11bp__))
4 linewid = linewid*0.8
5 circlerad = 0.25/2
6 bw = boxwid/2
7 bh = boxht/2
8 maxpsht = 15
9
10 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
11
12 PID: [
13 {"svg_it(r(s))" above ljust}
14 arrow
15 S1: circle
16 line right "svg_it(e(s))" above
17 { arrow right ; box ht bh wid bw "svg_it(K)svg_sub(P)"
18 arrow right linewid-circlerad ; S2: circle }
19 { line up linewid ; arrow right ; box ht bh wid bw "svg_it(K)svg_sub(D)s"
20 line to (S2,Here) ; arrow to S2.n }
21 { line down linewid ; arrow right ; box ht bh wid bw "svg_it(K)svg_sub(I)/s"
22 line to (S2,Here) ; arrow to S2.s }
23 arrow right from S2.e "svg_it(u(s))" above
24 box "svg_it(G(s))"
25 arrow right ; "svg_it(y(s))" above rjust at Here+(0,2pt__)
26 line down boxht*3/2 from last arrow.c then left last arrow.c.x-S1.x
27 arrow to S1.s
28 "svg_it(-)" rjust at Here+(-2bp__,-2bp__)
29 ]
30 "(a) svg_it(PID) control" below ljust at PID.sw+(0,-5pt__)
31
32 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
33
34 # https://tex.stackexchange.com/questions/575592/how-to-create-a-controls-system-diagram
35 Observer: [
36 define(`thickarrow',`arrow thick 3 wid 7bp__')
37 define(`thickline',`line thick 3')
38 fillval = 0.6
39 boxwid = 0.3
40 boxht = 0.4
41 circlerad = 0.1
42 {"svg_it(r)" above ljust}
43 R: arrow
44 S: circle fill
45 {"svg_thinsp`'svg_it(-)" below ljust at S.s
46 "svg_it(+)" above rjust at S.w+(2bp__,0)}
47 { PLT: box invis fill 0.9 wid 3.1 ht 1.2 with .nw at Here+(0.3,boxht*3/4)
48 "svg_it(Plant)" at PLT.sw above ljust }
49 U: arrow right 0.4
50 {"svg_it(u)" at last arrow+(2bp__,0) above }
51 Bp: box fill "svg_it(B)"
52 thickarrow right 0.4
53 Sp: circle fill
54 {"svg_thinsp`'svg_it(+)" below ljust at Sp.s
55 "+" above rjust at Sp.w+(2bp__,2bp__)}
56 thickarrow right 0.4
57 {"svg_bf(x)" at last arrow + (0,7bp__); "." at last "".n +(0,textoffset)}
58 Ip: box fill "svg_it(I/s)"
59 thickarrow right 1
60 {"svg_bf(x)" at last arrow + (0,7bp__) }
61 Cp: box fill "svg_it(C)"
62 # print Cp.e.x - Bp.w.x + 0.2
63 thickline right 0.4
64 Yp: thickarrow
65 {"svg_bf(y)" at last arrow + (0,7bp__) }
66 Ap: box fill "svg_it(A)" with .n at Ip.s+(0,-boxht/2)
67 thickarrow <- from Ap.e right 0.4 then up Ip.y-Ap.y
68 thickarrow from Ap.w to (Sp,Ap) then to Sp.s
69 # print PLT.n.y-Ap.s.y+0.1
70 #
71 K: box fill "svg_it(K)" at Ap + (0,-boxht*3/2)
72 arrow from K.w to (S,K) then to S.s
73 {OBS: box invis fill 0.9 wid 4.3 ht 1.8 with .nw at (S.w,K.s)-(0.1,0.1)
74 "svg_it(Observer)" at OBS.sw ljust above }
75 Io: box fill "svg_it(I/s)" at K + (0,-boxht*3/2)
76 thickarrow <- from Io.w left 0.4
77 {"svg_bf(x)" at last arrow + (0,7bp__); "svg_circ" at last ""
78 "." at last "".n above}
79 Sxo: circle fill
80 {"svg_thinsp`'svg_it(+)" below ljust at Sxo.s
81 "svg_it(+)" above rjust at Sxo.w+(2bp__,2bp__)}
82 thickarrow <- left 0.4
83 SLo: circle fill
84 {"svg_thinsp`'svg_it(+)" below ljust at SLo.s
85 "svg_it(+)" above rjust at SLo.w+(2bp__,2bp__)}
86 thickarrow <- left 0.4
87 Bo: box fill "svg_it(B)"
88 arrow from 1/4 between U.start and U.end up boxht*3/4 \
89 then left 2*boxht then down Bp.y-Bo.y+boxht*3/4 then to Bo.w
90 Ao: box fill "svg_it(A)" with .n at Io.s+(0,-boxht/2)
91 thickline from Io.e right 0.4
92 {thickarrow <-> from K.e to (Here,K.e) then to (Here,Ao) then to Ao.e
93 thickarrow from Ao.w to (Sxo,Ao.w) then to Sxo.s }
94 Xhat: Here
95 Co: box fill "svg_it(C)" at (Cp,Here)
96 thickarrow right 0.4
97 {"svg_bf(y)" at last arrow + (0,7bp__); "svg_circ" at last ""}
98 { thickarrow from Xhat to Co.w }
99 {"svg_it(x)" at last arrow + (0,7bp__); "svg_circ" at last "" }
100 Syo: circle fill
101 {"svg_it(+)" above ljust at Syo.n
102 "svg_it(-)" above rjust at Syo.w+(2bp__,2bp__)}
103 thickarrow <- from Syo.n to (Syo,Cp)
104 Lo: box fill "svg_it(L)" with .n at Ao.s+(0,-boxht/2)
105 # print Io.n.y+0.1 - (Lo.s.y-0.1)
106 thickarrow from Syo.s down Syo.s.y-Lo.y then to Lo.e
107 thickarrow from Lo.w to (SLo,Lo.w) then to SLo.s
108 ] with .nw at last [].sw+(0,-0.5)
109
110 Eqns: [ {"svg_it(r)" above ljust}
111 ex = textht*2/3
112 define(`DDt',`svg_frac(svg_it(d):1*ex,svg_it(dt):2*ex)')
113 arrow
114 S: circle
115 "svg_it(-)" below rjust at S.s
116 arrow <- down linewid/2 from S.s
117 box ht bh wid bw "svg_it(K)"
118 arrow <- down linewid/2
119 line right linewid
120 {"svg_hat(svg_bf(x))" at last line.c above }
121 Obs:box wid linewid*5 ht boxht*5/4
122 [ DDt; "svg_hat(svg_bf(x)) svg_it(= (A-LC)) svg_hat(svg_bf(x))
123 svg_it(+ Bu + L)svg_bf(y)" wid 1.5 ljust ] at Obs
124 "svg_it(Observer)" above ljust at Obs.sw
125 arrow <- right linewid/2 from 3/4<Obs.se,Obs.ne>
126 line to (Here,S)
127 {"svg_it(u)" above at Here+(linewid/2,0)}
128 arrow from S.e to Here+(linewid,0)
129 Plant: box wid boxwid*3/2 ht boxht*5/4
130 [ DDt; "svg_bf(x) svg_it(= A) svg_bf(x) svg_it(+ Bu)" wid 0.8 ljust
131 "svg_bf(y) svg_it( = C) svg_bf(x)" wid 0.6 ljust \
132 at last "".w + (0,-textht*2) ] at Plant+(0,0.05)
133 "svg_it(Plant)" above ljust at Plant.sw
134 arrow right from Plant.e
135 "svg_it(y)" above rjust at Here+(0,2pt__)
136 move to last arrow.c
137 line to (Here, 1/4<Obs.se,Obs.ne>)
138 arrow to (Obs.e,Here)
139 ] with .nw at last [].sw+(0,-0.1)
140 "(b) Plant with feedback from a full-order observer" \
141 below ljust at Eqns.sw+(0,-5pt__)
142
143 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
144
145 ifelse(0,1,`
146 Multiblock: [
147 boxht = 0.4
148 boxwid = boxht
149
150 define summer { circle
151 {line from last circle.nw to last circle.se
152 line from last circle.sw to last circle.ne
153 "svg_it($1)" at 0.6 between last circle and last circle.n
154 "svg_it($2)" at 0.6 between last circle and last circle.s
155 "svg_it($3)" at 0.6 between last circle and last circle.e
156 "svg_it($4)" at 0.6 between last circle and last circle.w }
157 }
158
159 arrow "svg_it(E`'svg_sub(1))" above
160 S1: summer(,-,,+)
161 linewid = boxwid/2
162 arrow "svg_epsilon" above
163 [box "svg_it(H)svg_sub(1)"; arrow; box "svg_it(H)svg_sub(2)"]
164 arrow
165 S2: summer(-,,,+)
166 arrow
167 T: [box "svg_it(H)svg_sub(3)"; arrow; box "svg_it(H)svg_sub(4)"]
168 line
169 Y: Here
170 arrow
171 "svg_it(S)svg_sub(1)" above
172 R1: box "svg_it(R)svg_sub(1)" at (T.x,T.y+boxht*3/2)
173 arrow from Y to (Y,R1) then to R1.e
174 arrow from R1.w to (S2,R1) then to S2.n
175 "svg_it(n)svg_sub(1)" ljust at S2.n+(0,boxht/2)
176 left
177 Rf: [box "svg_it(R)svg_sub(2)"; arrow; box "svg_it(R)svg_sub(3)"] \
178 at ((S1.x+T.x)/2,T.y-boxht*3/2)
179 arrow from T to (T,Rf) then to Rf.e
180 arrow from Rf.w to (S1,Rf) then to S1.s
181 "svg_it(n)svg_sub(2)" at S1.s+(0,-boxht/2) ljust
182 ] with .nw at Eqns.sw + (0,-0.3)
183 "(c) A multiblock example" below ljust at Multiblock.sw+(0,-5pt__)
184
185 # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
186
187 Nonlinear: [boxwid = boxwid*3/2; boxht = boxht*3/2
188 thicklines_
189 boxwid = boxwid*0.6
190 boxht = boxht/2
191 R: box "reference" "svg_it(R)"
192 arrow right linewid*4/3
193 {"svg_it(y)svg_sub(c)[ref]" at last arrow+(0,textht/3) above }
194 Gh: box "\"i`'nverse\"" "of svg_it(G)"
195 arrow from Gh.s down "svg_it(y)svg_sub(m)[ref]" ljust
196 E: circle
197 arrow from E.e right "svg_it(e)" above
198 box "stabilizer" "svg_it(K)"
199 arrow "svg_delta`'u" above
200 D: circle
201 line from Gh.e to (D,Gh.e) "svg_it(u)[ref]" above
202 arrow to D.n
203 arrow from D.e right "svg_it(u)" above
204 G: box "plant" "svg_it(G)"
205 arrow <- from G.n up boxht/2; "disturbance svg_it(z)" above
206 arrow right from G.e + (0,boxht/4); "svg_it(y)svg_sub(c)" wid 0.2 ljust
207 arrow right from G.e + (0,-boxht/4); "svg_it(y)svg_sub(m)" ljust
208 move to last arrow.c
209 arrow down Here.y-G.s.y+boxht*2/3 then left Here.x-E.x then to E.s
210 "svg_it(-)" rjust below
211 arrow <- down from R.s
212 "svg_it(W) control input" at Here - (0,0.1)
213 UL:R.nw +(-boxht/2,boxht/2)
214 UR:(D.e,UL) + (0.1,0)
215 line dashed from UL to UR then to (UR,G.s+(0,-boxht*3/2))
216 line dashed to (Gh.w,Here) "Controller" above
217 line dashed to (Here,Gh.s+(0,-boxht/2))
218 line dashed to (UL,Here) then to UL
219 ] with .nw at last [].sw + (0,-0.3)
220 "(d) Nonlinear feedforward (for performance) and small-signal feedback
221 (for stability)" below ljust at Nonlinear.sw+(0,-5pt__)
222 ')
223 # Gimbal.m4
224 # https://tex.stackexchange.com/questions/734796/how-to-create-a-gimbal-model-for-one-axis-using-tikz
225
226 #gen_init
227 #svg_font(sans-serif,9bp__)
228 Gimbal: [
229 textht = 9bp__
230 circlerad = 8bp__
231 linewid = linewid*4/3
232 toffset = textht*3/2
233 textoffset = textht/2
234
235 Ir: arrow right_ linewid*3/2
236 { "Current" ljust at Ir.start+(0,toffset) "reference" ljust
237 "svg_it(i)svg_sub(reference)" ljust at Ir.start-(0,toffset*2/3) }
238 Ka: box "svg_it(K)svg_sub(a)"
239 { "Current" at Ka.s -(0,toffset) "amplifier gain" }
240 arrow right_ linewid*3/2
241 { "Motor" at last arrow+(0,toffset) "current" }
242 Kt: box "svg_it(K)svg_sub(t)"
243 { "Motor torque" at Kt.s -(0,toffset) "constant" }
244 arrow
245 S1: circle; {"-" at S1.n above ljust; "+" at S1.w above rjust }
246 arrow
247 GI: box #"\frac{1}{J`'svg_sub(s)}";
248 { "svg_it(1)" at GI above
249 "svg_it(J)svg_sub(s)" wid toffset*5/4 at GI below
250 line right_ last "".e.x - last "".w.x with .c at GI }
251 arrow "svg_omega`'svg_sub(h)" above
252 { "Gimbal inertia" at GI.s -(0,toffset) }
253 S2: circle at Here+(0,3/2*boxht)
254 {"-" at S2.e above ljust; "+" at S2.s below rjust }
255 { arrow <- right_; "svg_omega`'svg_sub(b)" above rjust }
256 arrow left_ from S2.w to (GI.e,S2)
257 Bv: box "svg_it(B)svg_sub(v)"
258 arrow left_ "svg_it(T)svg_sub(viscous)" below
259 S3: circle "+"
260 { arrow <- from S3.w; "svg_it(T)svg_sub(ext)" above ljust }
261 arrow from S3 to S1 chop
262 Fc: box ht boxht*1.7 at Bv+(0,boxht*7/4)
263 arrow from S2.n to (S2,Fc) then to Fc.e
264 arrow from Fc.w to (S3,Fc) then to S3.n
265 "svg_it(T)svg_sub(friction)" at (S3,Fc) above
266 [ Orig: Here; V: arrow thick 0.4 from Orig up_ Fc.ht*5/12
267 H: arrow thick 0.4 right_ Fc.wid*5/6 with .c at Orig
268 line thick 1.2 up Fc.ht/2 with .c at Orig
269 spline 0.55 thick 1.2 down_ boxht/5 right_ boxht/9 \
270 then right_ boxwid/9 then right_ boxwid/4 up_ boxwid/8
271 { "svg_it(F)svg_sub(c)svg_ensp" above }
272 spline 0.55 thick 1.2 from last line.start up_ boxht/5 left_ boxht/9 \
273 then left_ boxwid/9 then left_ boxwid/4 down_ boxwid/8
274 { "svg_emsp`'svg_it(-F)svg_sub(c)" below }
275 ] with .Orig at Fc
276 Gl: box wid boxwid*7/4 with .e at GI.e+(0,-boxht*2)
277 { "svg_omega`'svg_sub(g)svg_sup(2)" at Gl above
278 "svg_it(s)svg_sup(2) + 2`'svg_zeta`'svg_omega`'svg_sub(g)s +
279 svg_omega`'svg_sub(g)svg_sup(2)" at Gl below
280 line right_ Gl.wid*7/8 with .c at Gl }
281 { "Gyro lowpass" at Gl.s -(0,toffset) }
282 arrow from Gl.e to (S2,Gl) then to S2.s
283 Gd: box wid boxwid*2 at (Kt,Gl)
284 { "svg_small((svg_it(d)svg_sup(2)/12)s`'svg_sup(2) - (svg_it(d)/2)s + 1,85)" \
285 at Gd above
286 "svg_small((svg_it(d)svg_sup(2)/12)s`'svg_sup(2) + (svg_it(d)/2)s + 1,85)" \
287 at Gd below
288 line right_ Gd.wid*7/8 with .c at Gd }
289 { "Gyro delay" at Gd.s -(0,toffset) }
290 arrow left_ from Gl.w to Gd.e
291 arrow left_ from Gd.w chop 0 chop
292 S4: circle "+"
293 {"Gyro noise" at (S4,last ""); arrow from last "".n to S4.s }
294 Rm: arrow left_ from S4.w to (Ir.start,S4)
295 { "Rate" ljust at Here+(0,toffset) "measurement" ljust }
296 "svg_omega`'svg_sub(measured)" ljust at Here-(0,toffset*2/3)
297
298 # command "</g>"
299 ] with .nw at last [].sw + (0,-0.25)
300 "(c) Single-axis gimbal model" below ljust at Gimbal.sw+(0,-5pt__)
301
302 command "</g>"
303 .PE