summaryrefslogtreecommitdiff
path: root/graphics/circuit_macros/examples/control.m4
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/circuit_macros/examples/control.m4')
-rw-r--r--graphics/circuit_macros/examples/control.m493
1 files changed, 85 insertions, 8 deletions
diff --git a/graphics/circuit_macros/examples/control.m4 b/graphics/circuit_macros/examples/control.m4
index 62d92291ac..400b8873ac 100644
--- a/graphics/circuit_macros/examples/control.m4
+++ b/graphics/circuit_macros/examples/control.m4
@@ -30,6 +30,81 @@ S1: circle
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
+# https://tex.stackexchange.com/questions/575592/how-to-create-a-controls-system-diagram
+Observer: [
+ define(`thickarrow',`arrow thick 3 wid 7bp__')
+ define(`thickline',`line thick 3')
+ fillval = 0.6
+ boxwid = 0.3
+ boxht = 0.4
+ circlerad = 0.1
+ {"$r$" above ljust}
+R: arrow
+S: circle fill
+ {"$-$" below ljust at S.s; "$+$" above rjust at S.w+(2bp__,0)}
+{ OLP: box invis fill 0.9 wid 3.1 ht 1.4 with .nw at Here+(0.3,boxht*5/4)
+ "\sf plant" at OLP.nw below ljust }
+U: arrow right 0.4
+ {"$u$" at last arrow+(2bp__,0) above }
+Bp: box fill "$B$"
+ thickarrow right 0.4
+Sp: circle fill
+ {"$\;+$" below ljust at Sp.s; "$+$" above rjust at Sp.w+(2bp__,2bp__)}
+ thickarrow right 0.4
+ {"`$\dot{\mathbf x}$'" at last arrow + (0,7bp__)}
+Ip: box fill "$I/s$"
+ thickarrow right 1
+ {"$\mathbf x$" at last arrow + (0,7bp__) }
+Cp: box fill "$C$"
+# print Cp.e.x - Bp.w.x + 0.2
+ thickline right 0.4
+Yp: thickarrow
+ {"$\mathbf y$" at last arrow + (0,7bp__) }
+Ap: box fill "$A$" with .n at Ip.s+(0,-boxht/2)
+ thickarrow <- from Ap.e right 0.4 then up Ip.y-Ap.y
+ thickarrow from Ap.w to (Sp,Ap) then to Sp.s
+# print OLP.n.y-Ap.s.y+0.1
+#
+K: box fill "$K$" at Ap + (0,-boxht*3/2)
+ arrow from K.w to (S,K) then to S.s
+ {OBS: box invis fill 0.9 wid 4.3 ht 1.8 with .nw at (S.w,K.s)-(0.1,0.1)
+ "\sf observer" at OBS.sw ljust above }
+Io: box fill "$I/s$" at K + (0,-boxht*3/2)
+ thickarrow <- from Io.w left 0.4
+ {"`$\dot{\hat{\mathbf x}}$'" at last arrow + (0,7bp__)}
+Sxo: circle fill
+ {"$\;+$" below ljust at Sxo.s; "$+$" above rjust at Sxo.w+(2bp__,2bp__)}
+ thickarrow <- left 0.4
+SLo: circle fill
+ {"$\;+$" below ljust at SLo.s; "$+$" above rjust at SLo.w+(2bp__,2bp__)}
+ thickarrow <- left 0.4
+Bo: box fill "$B$"
+ arrow from 1/4 between U.start and U.end up boxht \
+ then left 2*boxht then down Bp.y-Bo.y+boxht then to Bo.w
+Ao: box fill "$A$" with .n at Io.s+(0,-boxht/2)
+ thickline from Io.e right 0.4
+ {thickarrow <-> from K.e to (Here,K.e) then to (Here,Ao) then to Ao.e
+ thickarrow from Ao.w to (Sxo,Ao.w) then to Sxo.s }
+Xhat: Here
+Co: box fill "$C$" at (Cp,Here)
+ thickarrow right 0.4
+ {"$\hat{\mathbf y}$" at last arrow + (0,7bp__) }
+ { thickarrow from Xhat to Co.w }
+ {"$\hat{\mathbf x}$" at last arrow + (0,7bp__) }
+Syo: circle fill
+ {"$\;+$" above ljust at Syo.n; "$-$" below rjust at Syo.w+(2bp__,-2bp__)}
+ thickarrow <- from Syo.n to (Syo,Cp)
+Lo: box fill "$L$" with .n at Ao.s+(0,-boxht/2)
+# print Io.n.y+0.1 - (Lo.s.y-0.1)
+ thickarrow from Syo.s down Syo.s.y-Lo.y then to Lo.e
+ thickarrow from Lo.w to (SLo,Lo.w) then to SLo.s
+] with .nw at last [].sw+(0,-0.3)
+ "(b) Single-input plant with feedback from a full-order observer" \
+ below ljust at Observer.sw+(0,-5pt__)
+
+# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
+
+ifelse(0,1,`
Observer: [ {"$r$" above ljust}
arrow
S: circle
@@ -53,13 +128,14 @@ Plant: box wid boxwid*3/2 ht boxht*5/4 \
move to last arrow.c
line to (Here, 1/4<Obs.se,Obs.ne>)
arrow to (Obs.e,Here)
-] with .nw at PID.sw+(0,-0.5)
- "(b) Output feedback with a full-order observer" below ljust \
- at Observer.sw+(0,-5pt__)
+] with .nw at last [].sw+(0,-0.5)
+')
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
+ifelse(1,1,`
Multiblock: [
+boxht = 0.4
boxwid = boxht
circlerad = boxht*0.4
@@ -95,8 +171,9 @@ Rf: doublebox(R_2,R_3) at ((S1.x+T.x)/2,T.y-boxht*3/2)
arrow from T to (T,Rf) then to Rf.e
arrow from Rf.w to (S1,Rf) then to S1.s
"$n_2$" at S1.s+(0,-boxht/2) ljust
-] with .nw at Observer.sw + (0,-0.5)
+] with .nw at Observer.sw + (0,-0.3)
"(c) A multiblock example" below ljust at Multiblock.sw+(0,-5pt__)
+')
# . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . #
@@ -128,15 +205,15 @@ G: box "plant" "$G$"
"$-$" at Here + (-0.15,-0.1)
arrow <- down from R.s
"$W$ control input" at Here - (0,0.1)
-
UL:R.nw +(-boxht/2,boxht/2)
UR:(D.e,UL) + (0.1,0)
line dashed from UL to UR then to (UR,G.s+(0,-boxht*3/2))
line dashed to (Gh.w,Here) "Controller" above
line dashed to (Here,Gh.s+(0,-boxht/2))
line dashed to (UL,Here) then to UL
-] with .nw at Multiblock.sw + (0,-0.5)
- "(d) Nonlinear feedforward (for performance) and small-signal feedback (for stability)" \
- below ljust at Nonlinear.sw+(0,-5pt__)
+] with .nw at last [].sw + (0,-0.2)
+ "(d) Nonlinear feedforward (for performance) and small-signal feedback
+ (for stability)" below ljust at Nonlinear.sw+(0,-5pt__)
+#print PID.n.y - Nonlinear.s.y
.PE