Skip to content

Commit 2a8aa33

Browse files
committed
make feedback2dof work for any system type
1 parent 5982cc3 commit 2a8aa33

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

docs/src/man/creating_systems.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Continuous-time transfer function model
3434
```
3535

3636
The transfer functions created using this method will be of type `TransferFunction{SisoRational}`.
37-
For more general expressions, it is often more convenient to define `s = tf("s")`:
37+
For more general expressions, it is sometimes more convenient to define `s = tf("s")` (only use this approach for low-order systems).:
3838
#### Example:
3939
```julia
4040
julia> s = tf("s")
@@ -295,10 +295,10 @@ The returned closed-loop system will have a state vector comprised of the state
295295
---
296296
Closed-loop system from reference to output
297297
```
298-
r ┌─────┐ ┌─────┐
299-
───►│ │ u │ │ y
300-
│ C ├────►│ P ├─┬─►
301-
-┌►│ │ │ │ │
298+
┌─────┐ ┌─────┐
299+
r │ │ u │ │ y
300+
──+►│ C ├────►│ P ├─┬─►
301+
-│ │ │ │ │
302302
│ └─────┘ └─────┘ │
303303
│ │
304304
└─────────────────────┘
@@ -396,6 +396,32 @@ Here, we have reversed the order of `P` and `C` to get the correct sign of the c
396396

397397
---
398398

399+
Two degree of freedom control system with feedforward ``F`` and feedback controller ``C``
400+
401+
```
402+
+-------+
403+
| |
404+
+-----> F +----+
405+
| | | |
406+
| +-------+ |
407+
| +-------+ | +-------+
408+
r | - | | | | | y
409+
+--+-----> C +----+----> P +---+-->
410+
| | | | | |
411+
| +-------+ +-------+ |
412+
| |
413+
+--------------------------------+
414+
```
415+
416+
```math
417+
Y = (F+C)\dfrac{P}{I + PC}R
418+
```
419+
420+
Code: `feedback(P,C)*(F+C)` or `feedback2dof(P, C, F)`
421+
- [`feedback2dof`](@ref)
422+
423+
---
424+
399425
Linear fractional transformation
400426

401427
```
@@ -445,9 +471,9 @@ I & P
445471
w_1 \\ w_2
446472
\end{bmatrix}
447473
```
448-
Code: This function requires the package [RobustAndOptimalControl.jl](https://juliacontrol.github.io/RobustAndOptimalControl.jl/dev/).
474+
Code:
449475
```julia
450-
RobustAndOptimalControl.extended_gangoffour(P, C, pos=true)
476+
extended_gangoffour(P, C, pos=true)
451477
# For SISO P
452478
S = G[1, 1]
453479
PS = G[1, 2]

lib/ControlSystemsBase/src/connections.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ end
442442
feedback2dof(B,A,R,S,T) = tf(conv(B,T),zpconv(A,R,B,S))
443443

444444
"""
445-
feedback2dof(P::TransferFunction, C::TransferFunction, F::TransferFunction)
445+
feedback2dof(P, C, F)
446446
447447
Return the transfer function
448448
`P(F+C)/(1+PC)`
@@ -463,7 +463,7 @@ r | - | | | | | y
463463
```
464464
"""
465465
function feedback2dof(P::TransferFunction{TE}, C::TransferFunction{TE}, F::TransferFunction{TE}) where TE
466-
!issiso(P) && error("Feedback not implemented for MIMO systems")
466+
!issiso(P) || return tf(feedback2dof(ss(P), ss(C), ss(F)))
467467
timeevol = common_timeevol(P, C, F)
468468

469469
Pn,Pd = numpoly(P)[], denpoly(P)[]
@@ -473,6 +473,10 @@ function feedback2dof(P::TransferFunction{TE}, C::TransferFunction{TE}, F::Trans
473473
tf(Cd*Pn*Fn + Pn*Cn*Fd, den, timeevol)
474474
end
475475

476+
function feedback2dof(P,C,F)
477+
feedback(P,C)*(F+C)
478+
end
479+
476480
"""
477481
lft(G, Δ, type=:l)
478482

lib/ControlSystemsBase/test/test_connections.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ F = tf(1.0, [1,1])
294294
@test feedback2dof(P0, C, 0*F) == feedback(P0*C)
295295
@test_nowarn feedback2dof(P0, C, F)
296296

297+
C = pid(1, 0, 1, form=:parallel)
298+
hinfnorm(minreal(feedback2dof(ss(P0), ss(C*F), ss(F)) - feedback2dof(P0, C*F, F)))[1] < 1e-8
297299

298300

299301
G1 = tf([1, 0],[1, 2, 2])

0 commit comments

Comments
 (0)