diff --git a/lib/ControlSystemsBase/src/connections.jl b/lib/ControlSystemsBase/src/connections.jl index 8b4f68c33..9d3511352 100644 --- a/lib/ControlSystemsBase/src/connections.jl +++ b/lib/ControlSystemsBase/src/connections.jl @@ -331,6 +331,14 @@ function feedback(sys1::AbstractStateSpace, sys2::AbstractStateSpace; if !(isa(Y2, Colon) || allunique(Y2)); @warn "Connecting single output to multiple inputs Y2=$Y2"; end if !(isa(U1, Colon) || allunique(U1)); @warn "Connecting multiple outputs to a single input U1=$U1"; end if !(isa(U2, Colon) || allunique(U2)); @warn "Connecting a single output to multiple inputs U2=$U2"; end + U1 isa Number && (U1 = [U1]) + Y1 isa Number && (Y1 = [Y1]) + U2 isa Number && (U2 = [U2]) + Y2 isa Number && (Y2 = [Y2]) + W1 isa Number && (W1 = [W1]) + Z1 isa Number && (Z1 = [Z1]) + W2 isa Number && (W2 = [W2]) + Z2 isa Number && (Z2 = [Z2]) if (U1 isa Colon ? size(sys1, 2) : length(U1)) != (Y2 isa Colon ? size(sys2, 1) : length(Y2)) error("Lengths of U1 ($U1) and Y2 ($Y2) must be equal") @@ -394,13 +402,13 @@ function feedback(sys1::AbstractStateSpace, sys2::AbstractStateSpace; R1 = try inv(α*I - s2_D22*s1_D22) # slightly faster than α*inv(I - α*s2_D22*s1_D22) catch - error("Ill-posed feedback interconnection, I - α*s2_D22*s1_D22 or I - α*s2_D22*s1_D22 not invertible") + error("Ill-posed feedback interconnection, I - α*s2_D22*s1_D22 not invertible") end R2 = try inv(I - α*s1_D22*s2_D22) catch - error("Ill-posed feedback interconnection, I - α*s2_D22*s1_D22 or I - α*s2_D22*s1_D22 not invertible") + error("Ill-posed feedback interconnection, I - α*s1_D22*s2_D22 not invertible") end s2_B2R2 = s2_B2*R2 @@ -463,7 +471,7 @@ r | - | | | | | y ``` """ function feedback2dof(P::TransferFunction{TE}, C::TransferFunction{TE}, F::TransferFunction{TE}) where TE - !issiso(P) || return tf(feedback2dof(ss(P), ss(C), ss(F))) + issiso(P) || return tf(feedback2dof(ss(P), ss(C), ss(F))) timeevol = common_timeevol(P, C, F) Pn,Pd = numpoly(P)[], denpoly(P)[] diff --git a/lib/ControlSystemsBase/src/pid_design.jl b/lib/ControlSystemsBase/src/pid_design.jl index e47bdb002..822899024 100644 --- a/lib/ControlSystemsBase/src/pid_design.jl +++ b/lib/ControlSystemsBase/src/pid_design.jl @@ -131,8 +131,9 @@ The `form` can be chosen as one of the following (determines how the arguments ` This controller has negative feedback built in, and the closed-loop system from `r` to `y` is thus formed as ``` Cr, Cy = C[1, 1], C[1, 2] -feedback(P, Cy, pos_feedback=true)*Cr # Alternative 1 -feedback(P, -Cy)*Cr # Alternative 2 +feedback(P, Cy, pos_feedback=true)*Cr # Alternative 1 +feedback(P, -Cy)*Cr # Alternative 2 +feedback(P, C, U2=2, W2=1, W1=[], pos_feedback=true) # Alternative 3, less pretty but more efficient, returns smaller realization ``` """ function pid_2dof(args...; state_space = true, Ts = nothing, disc = :tustin, kwargs...) diff --git a/lib/ControlSystemsBase/src/sensitivity_functions.jl b/lib/ControlSystemsBase/src/sensitivity_functions.jl index e84d7b0c5..2789301e4 100644 --- a/lib/ControlSystemsBase/src/sensitivity_functions.jl +++ b/lib/ControlSystemsBase/src/sensitivity_functions.jl @@ -156,7 +156,7 @@ T = G[P.ny+1:end, P.ny+1:end] # Input complimentary sensitivity function The gang of four can be plotted like so ```julia Gcl = extended_gangoffour(G, C) # Form closed-loop system -bodeplot(Gcl, lab=["S" "CS" "PS" "T"], plotphase=false) |> display # Plot gang of four +bodeplot(Gcl, lab=["S" "PS" "CS" "T"], plotphase=false) |> display # Plot gang of four ``` Note, the last input of Gcl is the negative of the `PS` and `T` transfer functions from `gangoffour2`. To get a transfer matrix with the same sign as [`G_PS`](@ref) and [`input_comp_sensitivity`](@ref), call `extended_gangoffour(P, C, pos=false)`. See `glover_mcfarlane` from RobustAndOptimalControl.jl for an extended example. See also `ncfmargin` and `feedback_control` from RobustAndOptimalControl.jl.