@@ -50,36 +50,36 @@ The actual model can now be composed.
5050@named speed_sensor = SpeedSensor()
5151
5252connections = [connect(fixed.flange, emf.support, friction.flange_b)
53- connect(emf.flange, friction.flange_a, inertia.flange_a)
54- connect(inertia.flange_b, load.flange)
55- connect(inertia.flange_b, speed_sensor.flange)
56- connect(load_step.output, load.tau)
57- connect(ref.output, feedback.input1)
58- connect(speed_sensor.w, :y, feedback.input2)
59- connect(feedback.output, pi_controller.err_input)
60- connect(pi_controller.ctr_output, :u, source.V)
61- connect(source.p, R1.p)
62- connect(R1.n, L1.p)
63- connect(L1.n, emf.p)
64- connect(emf.n, source.n, ground.g)]
53+ connect(emf.flange, friction.flange_a, inertia.flange_a)
54+ connect(inertia.flange_b, load.flange)
55+ connect(inertia.flange_b, speed_sensor.flange)
56+ connect(load_step.output, load.tau)
57+ connect(ref.output, feedback.input1)
58+ connect(speed_sensor.w, :y, feedback.input2)
59+ connect(feedback.output, pi_controller.err_input)
60+ connect(pi_controller.ctr_output, :u, source.V)
61+ connect(source.p, R1.p)
62+ connect(R1.n, L1.p)
63+ connect(L1.n, emf.p)
64+ connect(emf.n, source.n, ground.g)]
6565
6666@named model = ODESystem(connections, t,
67- systems = [
68- ground,
69- ref,
70- pi_controller,
71- feedback,
72- source,
73- R1,
74- L1,
75- emf,
76- fixed,
77- load,
78- load_step,
79- inertia,
80- friction,
81- speed_sensor,
82- ])
67+ systems = [
68+ ground,
69+ ref,
70+ pi_controller,
71+ feedback,
72+ source,
73+ R1,
74+ L1,
75+ emf,
76+ fixed,
77+ load,
78+ load_step,
79+ inertia,
80+ friction,
81+ speed_sensor,
82+ ])
8383nothing # hide
8484```
8585
@@ -93,7 +93,7 @@ prob = ODEProblem(sys, [], (0, 6.0))
9393sol = solve(prob, Rodas4())
9494
9595p1 = Plots.plot(sol.t, sol[inertia.w], ylabel = "Angular Vel. in rad/s",
96- label = "Measurement", title = "DC Motor with Speed Controller")
96+ label = "Measurement", title = "DC Motor with Speed Controller")
9797Plots.plot!(sol.t, sol[ref.output.u], label = "Reference")
9898p2 = Plots.plot(sol.t, sol[load.tau.u], ylabel = "Disturbance in Nm", label = "")
9999Plots.plot(p1, p2, layout = (2, 1))
@@ -124,7 +124,7 @@ So = ss(matrices_S...) |> minreal # The output-sensitivity function as a StateSp
124124matrices_T, simplified_sys = Blocks.get_comp_sensitivity(model, :y)
125125To = ss(matrices_T...)# The output complementary sensitivity function as a StateSpace system
126126bodeplot([So, To], label = ["S" "T"], plot_title = "Sensitivity functions",
127- plotphase = false)
127+ plotphase = false)
128128```
129129
130130Similarly, we may compute the loop-transfer function and plot its Nyquist curve
@@ -134,5 +134,5 @@ matrices_L, simplified_sys = Blocks.get_looptransfer(model, :y)
134134L = -ss(matrices_L...) # The loop-transfer function as a StateSpace system. The negative sign is to negate the built-in negative feedback
135135Ms, ωMs = hinfnorm(So) # Compute the peak of the sensitivity function to draw a circle in the Nyquist plot
136136nyquistplot(L, label = "\$L(s)\$", ylims = (-2.5, 0.5), xlims = (-1.2, 0.1),
137- Ms_circles = Ms)
137+ Ms_circles = Ms)
138138```
0 commit comments