Next: , Previous: sysdisp, Up: Control Theory


29.4 Block Diagram Manipulations

See systime.

Unless otherwise noted, all parameters (input,output) are system data structures.

— Function File: bddemo (inputs)

Octave Controls toolbox demo: Block Diagram Manipulations demo.

— Function File: buildssic (clst, ulst, olst, ilst, s1, s2, s3, s4, s5, s6, s7, s8)

Form an arbitrary complex (open or closed loop) system in state-space form from several systems. buildssic can easily (despite its cryptic syntax) integrate transfer functions from a complex block diagram into a single system with one call. This function is especially useful for building open loop interconnections for H-infinity and H-2 designs or for closing loops with these controllers.

Although this function is general purpose, the use of sysgroup sysmult, sysconnect and the like is recommended for standard operations since they can handle mixed discrete and continuous systems and also the names of inputs, outputs, and states.

The parameters consist of 4 lists that describe the connections outputs and inputs and up to 8 systems s1s8. Format of the lists:

clst
connection list, describes the input signal of each system. The maximum number of rows of Clst is equal to the sum of all inputs of s1-s8.

Example: [1 2 -1; 2 1 0] means that: new input 1 is old input 1 + output 2 - output 1, and new input 2 is old input 2 + output 1. The order of rows is arbitrary.

ulst
if not empty the old inputs in vector ulst will be appended to the outputs. You need this if you want to “pull out” the input of a system. Elements are input numbers of s1s8.
olst
output list, specifiy the outputs of the resulting systems. Elements are output numbers of s1s8. The numbers are allowed to be negative and may appear in any order. An empty matrix means all outputs.
ilst
input list, specifiy the inputs of the resulting systems. Elements are input numbers of s1s8. The numbers are allowed to be negative and may appear in any order. An empty matrix means all inputs.

Example: Very simple closed loop system.

          w        e  +-----+   u  +-----+
           --->o--*-->|  K  |--*-->|  G  |--*---> y
               ^  |   +-----+  |   +-----+  |
             - |  |            |            |
               |  |            +----------------> u
               |  |                         |
               |  +-------------------------|---> e
               |                            |
               +----------------------------+
     

The closed loop system GW can be optained by

          GW = buildssic([1 2; 2 -1], 2, [1 2 3], 2, G, K);
     
clst
1st row: connect input 1 (G) with output 2 (K).

2nd row: connect input 2 (K) with negative output 1 (G).

ulst
Append input of 2 (K) to the number of outputs.
olst
Outputs are output of 1 (G), 2 (K) and appended output 3 (from ulst).
ilst
The only input is 2 (K).

Here is a real example:

                                   +----+
              -------------------->| W1 |---> v1
          z   |                    +----+
          ----|-------------+
              |             |
              |    +---+    v      +----+
              *--->| G |--->O--*-->| W2 |---> v2
              |    +---+       |   +----+
              |                |
              |                v
             u                  y
     
          min || GW   ||
                   vz   infty
     

The closed loop system GW from [z, u]' to [v1, v2, y]' can be obtained by (all SISO systems):

          GW = buildssic([1, 4; 2, 4; 3, 1], 3, [2, 3, 5],
                         [3, 4], G, W1, W2, One);
     

where “One” is a unity gain (auxillary) function with order 0. (e.g. One = ugain(1);)

— Function File: sys = jet707 ()

Creates a linearized state-space model of a Boeing 707-321 aircraft at v=80 m/s (M = 0.26, Ga0 = -3 deg, alpha0 = 4 deg, kappa = 50 deg).

System inputs: (1) thrust and (2) elevator angle.

System outputs: (1) airspeed and (2) pitch angle.

Reference: R. Brockhaus: Flugregelung (Flight Control), Springer, 1994.

— Function File: ord2 (nfreq, damp, gain)

Creates a continuous 2nd order system with parameters:

Inputs

nfreq
natural frequency [Hz]. (not in rad/s)
damp
damping coefficient
gain
dc-gain This is steady state value only for damp > 0. gain is assumed to be 1.0 if ommitted.

Output

outsys
system data structure has representation with w = 2 * pi * nfreq:
                   /                                        \
                   | / -2w*damp -w \  / w \                 |
               G = | |             |, |   |, [ 0  gain ], 0 |
                   | \   w       0 /  \ 0 /                 |
                   \                                        /
          
See also jet707 (MIMO example, Boeing 707-321 aircraft model)

— Function File: sysadd (gsys, hsys)

returns sys = gsys + hsys.

                    ________
               ----|  gsys  |---
          u   |    ----------  +|
          -----                (_)----> y
              |     ________   +|
               ----|  hsys  |---
                    --------
     

— Function File: sys = sysappend (syst, b, c, d, outname, inname, yd)

appends new inputs and/or outputs to a system

Inputs

syst
system data structure
b
matrix to be appended to sys "B" matrix (empty if none)
c
matrix to be appended to sys "C" matrix (empty if none)
d
revised sys d matrix (can be passed as [] if the revised d is all zeros)
outname
list of names for new outputs
inname
list of names for new inputs
yd
binary vector; yd(ii)=0 indicates a continuous output; yd(ii)=1 indicates a discrete output.

Outputs

sys
                  sys.b := [syst.b , b]
                  sys.c := [syst.c  ]
                           [ c     ]
                  sys.d := [syst.d | D12 ]
                           [ D21   | D22 ]
          

where D12, D21, and D22 are the appropriate dimensioned blocks of the input parameter d.

  • The leading block D11 of d is ignored.
  • If inname and outname are not given as arguments, the new inputs and outputs are be assigned default names.
  • yd is a binary vector of length rows(c) that indicates continuous/sampled outputs. Default value for yd is:
    • sys is continuous or mixed yd = zeros(1,rows(c))
    • sys is discrete yd = ones(1,rows(c))

— Function File: clsys = sysconnect (sys, out_idx, in_idx, order, tol)

Close the loop from specified outputs to respective specified inputs

Inputs

sys
System data structure.
out_idx
in_idx
Names or indices of signals to connect (see sysidx). The output specified by out_idx(ii) is connected to the input specified by in_idx(ii).
order
logical flag (default = 0)
0
Leave inputs and outputs in their original order.
1
Permute inputs and outputs to the order shown in the diagram below.

tol
Tolerance for singularities in algebraic loops, default: 200eps.

Outputs

clsys
Resulting closed loop system.

Method

sysconnect internally permutes selected inputs, outputs as shown below, closes the loop, and then permutes inputs and outputs back to their original order

                           --------------------
           u_1       ----->|                  |----> y_1
                           |        sys       |
                   old u_2 |                  |
          u_2* ---->(+)--->|                  |----->y_2
          (in_idx)   ^     --------------------    | (out_idx)
                     |                             |
                     -------------------------------
     

The input that has the summing junction added to it has an * added to the end of the input name.

— Function File: [csys, acd, ccd] = syscont (sys)

Extract the purely continuous subsystem of an input system.

Input

sys
system data structure.

Outputs

csys
is the purely continuous input/output connections of sys
acd
ccd
connections from discrete states to continuous states, discrete states to continuous outputs, respectively.

returns csys empty if no continuous/continous path exists

— Function File: [dsys, adc, cdc] = sysdisc (sys)

Input

sys
System data structure.

Outputs

dsys
Purely discrete portion of sys (returned empty if there is no purely discrete path from inputs to outputs).
adc
cdc
Connections from continuous states to discrete states and discrete. outputs, respectively.

— Function File: retsys = sysdup (asys, out_idx, in_idx)

Duplicate specified input/output connections of a system

Inputs

asys
system data structure
out_idx
in_idx
indices or names of desired signals (see sigidx). duplicates are made of y(out_idx(ii)) and u(in_idx(ii)).

Output

retsys
Resulting closed loop system: duplicated i/o names are appended with a "+" suffix.

Method

sysdup creates copies of selected inputs and outputs as shown below. u1, y1 is the set of original inputs/outputs, and u2, y2 is the set of duplicated inputs/outputs in the order specified in in_idx, out_idx, respectively

                    ____________________
          u1  ----->|                  |----> y1
                    |       asys       |
          u2 ------>|                  |----->y2
          (in_idx)  -------------------- (out_idx)
     

— Function File: sys = sysgroup (asys, bsys)

Combines two systems into a single system.

Inputs

asys
bsys
System data structures.

Output

sys
sys = block diag(asys,bsys)
                   __________________
                   |    ________    |
          u1 ----->|--> | asys |--->|----> y1
                   |    --------    |
                   |    ________    |
          u2 ----->|--> | bsys |--->|----> y2
                   |    --------    |
                   ------------------
                        Ksys
     

The function also rearranges the internal state-space realization of sys so that the continuous states come first and the discrete states come last. If there are duplicate names, the second name has a unique suffix appended on to the end of the name.

— Function File: sys = sysmult (Asys, Bsys)

Compute sys = Asys*Bsys (series connection):

          u   ----------     ----------
          --->|  Bsys  |---->|  Asys  |--->
              ----------     ----------
     

A warning occurs if there is direct feed-through from an input or a continuous state of Bsys, through a discrete output of Bsys, to a continuous state or output in Asys (system data structure does not recognize discrete inputs).

— Function File: retsys = sysprune (asys, out_idx, in_idx)

Extract specified inputs/outputs from a system

Inputs

asys
system data structure
out_idx
in_idx
Indices or signal names of the outputs and inputs to be kept in the returned system; remaining connections are “pruned” off. May select as [] (empty matrix) to specify all outputs/inputs.
               retsys = sysprune (Asys, [1:3,4], "u_1");
               retsys = sysprune (Asys, {"tx", "ty", "tz"}, 4);
          

Output

retsys
Resulting system.
                     ____________________
          u1 ------->|                  |----> y1
           (in_idx)  |       Asys       | (out_idx)
          u2 ------->|                  |----| y2
            (deleted)-------------------- (deleted)
     

— Function File: pv = sysreorder (vlen, list)

Inputs

vlen
Vector length.
list
A subset of [1:vlen].

Output

pv
A permutation vector to order elements of [1:vlen] in list to the end of a vector.

Used internally by sysconnect to permute vector elements to their desired locations.

— Function File: retsys = sysscale (sys, outscale, inscale, outname, inname)

scale inputs/outputs of a system.

Inputs

sys
Structured system.
outscale
inscale
Constant matrices of appropriate dimension.
outname
inname
Lists of strings with the names of respectively outputs and inputs.

Output

retsys
resulting open loop system:
                     -----------    -------    -----------
               u --->| inscale |--->| sys |--->| outscale |---> y
                     -----------    -------    -----------
          
If the input names and output names (each a list of strings) are not given and the scaling matrices are not square, then default names will be given to the inputs and/or outputs.

A warning message is printed if outscale attempts to add continuous system outputs to discrete system outputs; otherwise yd is set appropriately in the returned value of sys.

— Function File: sys = syssub (Gsys, Hsys)

Return sys = Gsys - Hsys.

Method

Gsys and Hsys are connected in parallel. The input vector is connected to both systems; the outputs are subtracted. Returned system names are those of Gsys.

                   +--------+
              +--->|  Gsys  |---+
              |    +--------+   |
              |                +|
          u --+                (_)--> y
              |                -|
              |    +--------+   |
              +--->|  Hsys  |---+
                   +--------+
     

— Function File: ugain (n)

Creates a system with unity gain, no states. This trivial system is sometimes needed to create arbitrary complex systems from simple systems with buildssic. Watch out if you are forming sampled systems since ugain does not contain a sampling period.

— Function File: W = wgt1o (vl, vh, fc)

State space description of a first order weighting function.

Weighting function are needed by the H-2/H-infinity design procedure. These function are part of the augmented plant P (see hinfdemo for an application example).

Inputs

vl
Gain at low frequencies.
vh
Gain at high frequencies.
fc
Corner frequency (in Hz, not in rad/sec)

Output

W
Weighting function, given in form of a system data structure.

— Function File: ksys = parallel (asys, bsys)

Forms the parallel connection of two systems.

                       --------------------
                       |      --------    |
              u  ----->|----> | asys |--->|----> y1
                  |    |      --------    |
                  |    |      --------    |
                  |--->|----> | bsys |--->|----> y2
                       |      --------    |
                       --------------------
                            ksys
     

— Function File: [retsys, nc, no] = sysmin (sys, flg)

Returns a minimal (or reduced order) system

Inputs

sys
System data structure
flg
When equal to 0 (default value), returns minimal system, in which state names are lost; when equal to 1, returns system with physical states removed that are either uncontrollable or unobservable (cannot reduce further without discarding physical meaning of states).
Outputs
retsys
Returned system.
nc
Number of controllable states in the returned system.
no
Number of observable states in the returned system.
cflg
is_controllable(retsys).
oflg
is_observable(retsys).