|
1 | 1 | .. _iosys-module: |
2 | 2 |
|
| 3 | +.. currentmodule:: control |
| 4 | + |
3 | 5 | ************************** |
4 | 6 | Interconnected I/O Systems |
5 | 7 | ************************** |
6 | 8 |
|
| 9 | +Input/output systems can be interconnected in a variety of ways, |
| 10 | +including operator overloading, block diagram algebra functions, and |
| 11 | +using the :func:`interconnect` function to build a hiearchical system |
| 12 | +description. This chapter provides more detailed information on |
| 13 | +operator overloading and block diagram algebra, as well as a |
| 14 | +description of the :class:`InterconnectedSystem` class, which can be |
| 15 | +created using the :func:`interconnect` function. |
| 16 | + |
7 | 17 | Operator overloading |
8 | 18 | ==================== |
9 | 19 |
|
| 20 | +The following operators are defined to operate between I/O systems: |
| 21 | + |
| 22 | +.. list-table:: |
| 23 | + :header-rows: 1 |
| 24 | + |
| 25 | + * - Operation |
| 26 | + - Desription |
| 27 | + - Equivalent command |
| 28 | + * - `sys1 + sys2` |
| 29 | + - Add the outputs of two systems receiving the same input |
| 30 | + - `parallel(sys1, sys2)` |
| 31 | + * - `sys1 * sys2` |
| 32 | + - Connect output(s) of sys2 to input(s) of sys1 |
| 33 | + - `series(sys2, sys1)` |
| 34 | + * - `-sys` |
| 35 | + - Multiply the output(s) of the system by -1 |
| 36 | + - `negate(sys)` |
| 37 | + * - `tf1 / tf2` |
| 38 | + - Divide one SISO transfer function by another |
| 39 | + - N/A |
| 40 | + * - `tf**n` |
| 41 | + - Multiply a transfer function by itself `n` times |
| 42 | + - N/A |
| 43 | + |
| 44 | +If either of the systems is a number or an array of appropriate |
| 45 | +dimension, then the appropriate scalar or matrix operation is |
| 46 | +performed. |
| 47 | + |
| 48 | +Systems of different types can be combined using these operations, |
| 49 | +with the following rules: |
| 50 | + |
| 51 | +* If the two systems can be converted into the type of the other, the |
| 52 | + leftmost system determines the type of the output. |
| 53 | + |
| 54 | +* If one system can be converted into the other, then the more general |
| 55 | + system determines the type of the output. In particular: |
| 56 | + |
| 57 | + - State space and transfer function systems can be converted to |
| 58 | + nonlinear systems. |
| 59 | + |
| 60 | + - Linear systems can be converted to frequency response data (FRD) |
| 61 | + systems, using the frequencies of the FRD system. |
| 62 | + |
| 63 | + - FRD systems can only be combined with FRD systems, constants, |
| 64 | + and arrays. |
| 65 | + |
10 | 66 |
|
11 | 67 | Block diagram algebra |
12 | 68 | ===================== |
13 | 69 |
|
| 70 | +Block diagram algebra is implemented using the following functions: |
| 71 | + |
| 72 | +.. autosummary:: |
| 73 | + |
| 74 | + series |
| 75 | + parallel |
| 76 | + feedback |
| 77 | + negate |
| 78 | + append |
| 79 | + |
| 80 | +The :func:`feedback` function implements a standard feedback |
| 81 | +interconnection between two systems, as illustrated in the following |
| 82 | +diagram: |
| 83 | + |
| 84 | +.. image:: figures/bdalg-feedback.png |
| 85 | + :width: 240 |
| 86 | + |
| 87 | +By default a gain of -1 is applied at the output of the second system, |
| 88 | +so the dynamics illustrate above can be created using the command |
| 89 | + |
| 90 | +.. code:: |
| 91 | +
|
| 92 | + Gyu = ct.feedback(G1, G2) |
| 93 | +
|
| 94 | +An optional `gain` parameter can be used to change the sign of the gain. |
| 95 | + |
| 96 | +For LTI systems, the :func:`feedback` operation is also implemented |
| 97 | +via the :func:`LTI.feedback` method, so if `G1` is an LTI system then |
| 98 | +the following command will also work:: |
| 99 | + |
| 100 | + Gyu = G1.feedback(G2) |
| 101 | + |
| 102 | +All block diagram algebra functions allow the names of the system and |
| 103 | +signals to be specified using the usual `name`, `inputs`, and |
| 104 | +`outputs` keywords, as described in the :class:`InputOutputSystem` |
| 105 | +class. For state space systems, the names of the states can also be |
| 106 | +given, but caution should be used since the order of states in the |
| 107 | +combined system is not gauranteed. |
| 108 | + |
14 | 109 |
|
15 | 110 | Signal-based interconnection |
16 | 111 | ============================ |
17 | 112 |
|
18 | 113 | More complex input/output systems can be constructed by using the |
19 | | -:func:`~control.interconnect` function, which allows a collection of |
| 114 | +:func:`interconnect` function, which allows a collection of |
20 | 115 | input/output subsystems to be combined with internal connections |
21 | 116 | between the subsystems and a set of overall system inputs and outputs |
22 | | -that link to the subsystems:: |
| 117 | +that link to the subsystems. For example, the closed loop dynamics of |
| 118 | +a feedback control system using the standard names and labels for |
| 119 | +inputs and outputs could be constructed using the command |
| 120 | + |
| 121 | +.. code:: |
23 | 122 |
|
24 | | - steering = ct.interconnect( |
| 123 | + clsys = ct.interconnect( |
25 | 124 | [plant, controller], name='system', |
26 | 125 | connections=[['controller.e', '-plant.y']], |
27 | 126 | inplist=['controller.e'], inputs='r', |
28 | 127 | outlist=['plant.y'], outputs='y') |
29 | 128 |
|
30 | | -Interconnected systems can also be created using block diagram manipulations |
31 | | -such as the :func:`~control.series`, :func:`~control.parallel`, and |
32 | | -:func:`~control.feedback` functions. The :class:`~control.InputOutputSystem` |
33 | | -class also supports various algebraic operations such as `*` (series |
34 | | -interconnection) and `+` (parallel interconnection). |
| 129 | +The remainder of this section provides a detailed description of the |
| 130 | +operation of the :func:`interconnect` function. |
35 | 131 |
|
36 | | -Example |
37 | | -======= |
38 | 132 |
|
39 | | -To illustrate the use of the input/output systems module, we create a |
| 133 | +Illustrative example |
| 134 | +-------------------- |
| 135 | + |
| 136 | +To illustrate the use of the :func:`interconnect` function, we create a |
40 | 137 | model for a predator/prey system, following the notation and parameter |
41 | 138 | values in `Feedback Systems <http://fbsbook.org>`_. |
42 | 139 |
|
@@ -123,7 +220,7 @@ lynxes as the desired output (following `Feedback Systems |
123 | 220 | To construct the control law, we build a simple input/output system that |
124 | 221 | applies a corrective input based on deviations from the equilibrium point. |
125 | 222 | This system has no dynamics, since it is a static (affine) map, and can |
126 | | -constructed using :func:`~control.nlsys` with no update function: |
| 223 | +constructed using :func:`nlsys` with no update function: |
127 | 224 |
|
128 | 225 | .. code-block:: python |
129 | 226 |
|
@@ -169,21 +266,21 @@ Finally, we simulate the closed loop system: |
169 | 266 | plt.legend(['input']) |
170 | 267 | plt.show(block=False) |
171 | 268 |
|
172 | | -Additional features |
173 | | -=================== |
| 269 | +This example shows the standard operations that would be used to build |
| 270 | +up an interconnected nonlinear system. The I/O systems module has a |
| 271 | +number of other features that can be used to simplify the creation and |
| 272 | +use of interconnected input/output systems. |
174 | 273 |
|
175 | | -The I/O systems module has a number of other features that can be used to |
176 | | -simplify the creation and use of interconnected input/output systems. |
177 | 274 |
|
178 | | -Vector elements processing |
| 275 | +Vector element processing |
179 | 276 | -------------------------- |
180 | 277 |
|
181 | 278 | Several I/O system commands perform processing of vector elements |
182 | 279 | (such as initial states or input vectors) and broadcast these to the |
183 | 280 | proper shape. |
184 | 281 |
|
185 | 282 | For static elements, such as the initial state in a simulation or the |
186 | | -nominal state and input for a linearization), the following processing |
| 283 | +nominal state and input for a linearization, the following processing |
187 | 284 | is done: |
188 | 285 |
|
189 | 286 | * Scalars are automatically converted to a vector of the appropriate |
@@ -254,6 +351,7 @@ use the list processing feature combined with time series broadcasting:: |
254 | 351 | In this command, the second and third arguments will be broadcast to match |
255 | 352 | the number of time points. |
256 | 353 |
|
| 354 | + |
257 | 355 | Summing junction |
258 | 356 | ---------------- |
259 | 357 |
|
@@ -290,6 +388,7 @@ the command |
290 | 388 | will produce an input/output block that implements `e[0] = r[0] - y[0]` and |
291 | 389 | `e[1] = r[1] - y[1]`. |
292 | 390 |
|
| 391 | + |
293 | 392 | Automatic connections using signal names |
294 | 393 | ---------------------------------------- |
295 | 394 |
|
@@ -317,6 +416,7 @@ of the interconnected system) is not found, but inputs and outputs of |
317 | 416 | individual systems that are not connected to other systems are left |
318 | 417 | unconnected (so be careful!). |
319 | 418 |
|
| 419 | + |
320 | 420 | Advanced specification of signal names |
321 | 421 | -------------------------------------- |
322 | 422 |
|
@@ -430,6 +530,7 @@ complicated to debug error message when things go wrong. Setting |
430 | 530 | information about how the arguments are processed that may be helpful |
431 | 531 | in understanding what is going wrong. |
432 | 532 |
|
| 533 | + |
433 | 534 | Automated creation of state feedback systems |
434 | 535 | -------------------------------------------- |
435 | 536 |
|
|
0 commit comments