diff --git a/docs/src/man/creating_systems.md b/docs/src/man/creating_systems.md index 80a22c76f..1b66baa50 100644 --- a/docs/src/man/creating_systems.md +++ b/docs/src/man/creating_systems.md @@ -34,7 +34,7 @@ Continuous-time transfer function model ``` The transfer functions created using this method will be of type `TransferFunction{SisoRational}`. -For more general expressions, it is often more convenient to define `s = tf("s")`: +For more general expressions, it is sometimes more convenient to define `s = tf("s")` (only use this approach for low-order systems).: #### Example: ```julia julia> s = tf("s") @@ -295,10 +295,10 @@ The returned closed-loop system will have a state vector comprised of the state --- Closed-loop system from reference to output ``` -r ┌─────┐ ┌─────┐ -───►│ │ u │ │ y - │ C ├────►│ P ├─┬─► - -┌►│ │ │ │ │ + ┌─────┐ ┌─────┐ +r │ │ u │ │ y +──+►│ C ├────►│ P ├─┬─► + -▲ │ │ │ │ │ │ └─────┘ └─────┘ │ │ │ └─────────────────────┘ @@ -396,6 +396,32 @@ Here, we have reversed the order of `P` and `C` to get the correct sign of the c --- +Two degree of freedom control system with feedforward ``F`` and feedback controller ``C`` + +``` + +-------+ + | | + +-----> F +----+ + | | | | + | +-------+ | + | +-------+ | +-------+ +r | - | | | | | y ++--+-----> C +----+----> P +---+--> + | | | | | | + | +-------+ +-------+ | + | | + +--------------------------------+ +``` + +```math +Y = (F+C)\dfrac{P}{I + PC}R +``` + +Code: `feedback(P,C)*(F+C)` or `feedback2dof(P, C, F)` +- [`feedback2dof`](@ref) + +--- + Linear fractional transformation ``` @@ -445,9 +471,9 @@ I & P w_1 \\ w_2 \end{bmatrix} ``` -Code: This function requires the package [RobustAndOptimalControl.jl](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/). +Code: ```julia -RobustAndOptimalControl.extended_gangoffour(P, C, pos=true) +extended_gangoffour(P, C, pos=true) # For SISO P S = G[1, 1] PS = G[1, 2] diff --git a/lib/ControlSystemsBase/src/connections.jl b/lib/ControlSystemsBase/src/connections.jl index a95ff86fc..8b4f68c33 100644 --- a/lib/ControlSystemsBase/src/connections.jl +++ b/lib/ControlSystemsBase/src/connections.jl @@ -442,7 +442,7 @@ end feedback2dof(B,A,R,S,T) = tf(conv(B,T),zpconv(A,R,B,S)) """ - feedback2dof(P::TransferFunction, C::TransferFunction, F::TransferFunction) + feedback2dof(P, C, F) Return the transfer function `P(F+C)/(1+PC)` @@ -463,7 +463,7 @@ r | - | | | | | y ``` """ function feedback2dof(P::TransferFunction{TE}, C::TransferFunction{TE}, F::TransferFunction{TE}) where TE - !issiso(P) && error("Feedback not implemented for MIMO systems") + !issiso(P) || return tf(feedback2dof(ss(P), ss(C), ss(F))) timeevol = common_timeevol(P, C, F) Pn,Pd = numpoly(P)[], denpoly(P)[] @@ -473,6 +473,10 @@ function feedback2dof(P::TransferFunction{TE}, C::TransferFunction{TE}, F::Trans tf(Cd*Pn*Fn + Pn*Cn*Fd, den, timeevol) end +function feedback2dof(P,C,F) + feedback(P,C)*(F+C) +end + """ lft(G, Δ, type=:l) diff --git a/lib/ControlSystemsBase/test/test_connections.jl b/lib/ControlSystemsBase/test/test_connections.jl index e84b88e9f..c58c9265f 100644 --- a/lib/ControlSystemsBase/test/test_connections.jl +++ b/lib/ControlSystemsBase/test/test_connections.jl @@ -294,6 +294,8 @@ F = tf(1.0, [1,1]) @test feedback2dof(P0, C, 0*F) == feedback(P0*C) @test_nowarn feedback2dof(P0, C, F) +C = pid(1, 0, 1, form=:parallel) +hinfnorm(minreal(feedback2dof(ss(P0), ss(C*F), ss(F)) - feedback2dof(P0, C*F, F)))[1] < 1e-8 G1 = tf([1, 0],[1, 2, 2])