Skip to content

Commit 44b90cb

Browse files
committed
Some progress
1 parent 46ee455 commit 44b90cb

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

mwes/mwe_06.jl

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ function calc_force(v_wind, v_ro)
5151
(v_wind - v_ro)^2 * 4000.0 / 16.0
5252
end
5353

54+
# create the upper force controller
55+
# Tf​ can typically be chosen as Ti/NT for a PI controller and Td/N for a PID controller, and N is commonly in the range 2 to 20.
56+
# Td = wcs.df_high / wcs.pf_high Kd/Kp
57+
function upper_force_controller(wcs)
58+
# wcs: WCSettings object
59+
Td = wcs.df_high / wcs.pf_high
60+
N = wcs.nf_high
61+
Tf = Td / N
62+
C = pid(wcs.pf_high, wcs.if_high, wcs.df_high; form=:parallel, filter_order=1, state_space=true, Tf)
63+
return C
64+
end
65+
5466
function system_dynamics(x, u)
5567
# x: state vector, e.g., [v_act]
5668
# u: input vector, e.g., [v_set, v_wind]
@@ -73,10 +85,18 @@ function linearize(winch, v_set, v_wind)
7385
siso_sys = ss(A, B[:, 1], C, D[:, 1])
7486
end
7587

88+
function open_loop_system(winch, v_set, v_wind)
89+
# Create the open loop system with the upper force controller
90+
C = upper_force_controller(winch.wcs)
91+
sys = linearize(winch, v_set, v_wind)
92+
# sys_open = feedback(C * sys, 1.0; sign=-1)
93+
return C * sys
94+
end
95+
7696
for v_wind in range(1, 9, length=9)
7797
local v_set, sys
7898
v_set = 0.57*v_wind
7999
@info "Linearizing for v_wind: $v_wind m/s, v_ro: $(round(v_set, digits=2)) m/s"
80-
sys = linearize(winch, v_set, v_wind)
100+
sys = open_loop_system(winch, v_set, v_wind)
81101
bode_plot(sys; from=0.76, to=2.85, title="Linearized System, v_wind=1..9 m/s")
82102
end

0 commit comments

Comments
 (0)