Main Content

Build Tunable Closed-Loop Model for Tuning with hinfstruct

In Formulating Design Requirements as H-Infinity Constraints you expressed your design requirements as a constraint on the H norm of a closed-loop transfer function H(s).

The next step is to create a Generalized LTI model of H(s) that includes all of the fixed and tunable elements of the control system. The model also includes any weighting functions that represent your design requirements. There are two ways to obtain this tunable model of your control system:

Constructing the Closed-Loop System Using Control System Toolbox Commands

To construct the tunable generalized linear model of your closed-loop control system in MATLAB®:

  1. Use commands such as tf, zpk, and ss to create numeric linear models that represent the fixed elements of your control system and any weighting functions that represent your design requirements.

  2. Use tunable models (either Control Design Blocks or Generalized LTI models) to model the tunable elements of your control system. For more information about tunable models, see Models with Tunable Coefficients.

  3. Use model-interconnection commands such as series, parallel, and connect to construct your closed-loop system from the numeric and tunable models.

Example: Modeling a Control System With a Tunable PI Controller and Tunable Filter

This example shows how to construct a tunable generalized linear model of the following control system for tuning with hinfstruct.

Block diagram of control system with weighting functions for loop shaping. The weighting function LS takes the error signal as input and produces the weighted error ew. The weighting function 1/LS takes input nw and injects the noise n into the feedback path.

This block diagram represents a head-disk assembly (HDA) in a hard disk drive. The architecture includes the plant G in a feedback loop with a PI controller C and a low-pass filter, F = a/(s+a). The tunable parameters are the PI gains of C and the filter parameter a.

The block diagram also includes the weighting functions LS and 1/LS, which express the loop-shaping requirements. Let T(s) denote the closed-loop transfer function from inputs (r,nw) to outputs (y,ew). Then, the H constraint:

T(s)<1

approximately enforces the target open-loop response shape LS. For this example, the target loop shape is

LS=1+0.001sωc0.001+sωc.

This value of LS corresponds to the following open-loop response shape.

Frequency response of target loop shape LS, with 60 dB gain below about 1 rad/s, rolling off to -60 dB above about 10e6 rad/s

To tune the HDA control system with hinfstruct, construct a tunable model of the closed-loop system T(s), including the weighting functions, as follows.

  1. Load the plant G from a saved file.

    load hinfstruct_demo G

    G is a 9th-order SISO state-space (ss) model.

  2. Create a tunable model of the PI controller.

    You can use the predefined Control Design Block tunablePID to represent a tunable PI controller.

    C = tunablePID('C','pi');
  3. Create a tunable model of the low-pass filter.

    Because there is no predefined Control Design Block for the filter F = a/(s+a), use realp to represent the tunable filter parameter a. Then create a tunable genss model representing the filter.

    a = realp('a',1);    
    F = tf(a,[1 a]);
  4. Specify the target loop shape LC.

    wc = 1000;  
    s = tf('s');
    LS = (1+0.001*s/wc)/(0.001+s/wc);
  5. Label the inputs and outputs of all the components of the control system.

    Labeling the I/Os allows you to connect the elements to build the closed-loop system T(s).

    Wn = 1/LS;
    Wn.InputName = 'nw';
    Wn.OutputName = 'n';
    We = LS;
    We.InputName = 'e';
    We.OutputName = 'ew';
    C.InputName = 'e';
    C.OutputName = 'u';
    F.InputName = 'yn';
    F.OutputName = 'yf';
  6. Specify the summing junctions in terms of the I/O labels of the other components of the control system.

    Sum1 = sumblk('e = r - yf');
    Sum2 = sumblk('yn = y + n');
  7. Use connect to combine all the elements into a complete model of the closed-loop system T(s).

    T0 = connect(G,Wn,We,C,F,Sum1,Sum2,{'r','nw'},{'y','ew'});

T0 is a genss object, which is a Generalized LTI model representing the closed-loop control system with weighting functions. The Blocks property of T0 contains the tunable blocks C and a.

T0.Blocks
ans = struct with fields:
    C: [1x1 tunablePID]
    a: [1x1 realp]

For more information about generalized models of control systems that include both numeric and tunable components, see Models with Tunable Coefficients.

You can now use hinfstruct to tune the parameters of this control system. See Tune the Controller Parameters.

In this example, the control system model T0 is a continuous-time model (T0.Ts = 0). You can also use hinfstruct with a discrete-time model, provided that you specify a definite sample time (T0.Ts ≠ –1).

Constructing the Closed-Loop System Using Simulink Control Design Commands

If you have a Simulink model of your control system and Simulink Control Design software, use slTuner (Simulink Control Design) to create an interface to the Simulink model of your control system. When you create the interface, you specify which blocks to tune in your model. The slTuner interface allows you to extract a closed-loop model for tuning with hinfstruct. (Simulink-based functionality is not available in MATLAB Online™.)

Example: Creating a Weighted Tunable Model of Control System Starting From a Simulink Model

This example shows how to construct a tunable generalized linear model of the control system in the Simulink model rct_diskdrive.

To create a generalized linear model of this control system (including loop-shaping weighting functions):

  1. Open the model.

    open('rct_diskdrive');
    

  2. Create an slTuner interface to the model. The interface allows you to specify the tunable blocks and extract linearized open-loop and closed-loop responses. (For more information about the interface, see the slTuner (Simulink Control Design) reference page.)

    ST0 = slTuner('rct_diskdrive',{'C','F'});
    

    This command specifies that C and F are the tunable blocks in the model. The slTuner interface automatically parametrizes these blocks. The default parametrization of the transfer function block F is a transfer function with two free parameters. Because F is a low-pass filter, you must constrain its coefficients. To do so, specify a custom parameterization of F.

    a = realp('a',1);    % filter coefficient
    setBlockParam(ST0,'F',tf(a,[1 a]));
    
  3. Extract a tunable model of the closed-loop transfer function you want to tune.

    T0 = getIOTransfer(ST0,{'r','n'},{'y','e'});
    

    This command returns a genss model of the linearized closed-loop transfer function from the reference and noise inputs r,n to the measurement and error outputs y,e. The error output is needed for the loop-shaping weighting function.

  4. Define the loop-shaping weighting functions and append them to T0.

    wc = 1000;
    s = tf('s');
    LS = (1+0.001*s/wc)/(0.001+s/wc);
    
    T0 = blkdiag(1,LS) * T0 * blkdiag(1,1/LS);
    

The generalized linear model T0 is a tunable model of the closed-loop transfer function T(s), discussed in Example: Modeling a Control System With a Tunable PI Controller and Tunable Filter. T(s) is a weighted closed-loop model of the control system of rct_diskdrive. Tuning T0 to enforce the H constraint

T(s)<1

approximately enforces the target loop shape LS.

You can now use hinfstruct to tune the parameters of this control system. See Tune the Controller Parameters.