Main Content

Design Optimization to Track Reference Signal (GUI)

This example shows how to optimize controller parameters to track a reference signal using the Response Optimizer. You specify the reference signal without adding any Check blocks to the model.

Model Structure

The model sldo_model1 includes these blocks:

Model with the controller and plant in a feedback loop. There is a unit step input.

  • Controller block, a PID controller, controls the output of the Plant subsystem.

  • Unit Step block applies a step input.

    You can also use other types of inputs, such as ramp, to optimize the response generated by such inputs.

  • Plant subsystem is a second-order system with delay. It contains Transfer Function and Transport Delay blocks.

    Plant subsystem

Design Requirements

The model output must track a reference signal y=1exp(0.1×t), where t is time.

Specify Reference Signal

  1. Open the Simulink® model.

    sys = 'sldo_model1';
    openExample(sys);

    Model with Controller and plant in a feedback loop. There is a unit step input.

    To learn more about the model, see Model Structure.

  2. To open the Response Optimizer, in the Simulink model window, from the Apps tab, in the gallery, under Control Systems, select Response Optimizer.

    Response Optimizer app main screen. Response Optimization toolstrip is on the top. Data and preview areas are on the left.

  3. Select the model signal to track the reference signal.

    1. In the New drop-down list, select Signal to open the Create Signal Set window.

      Drop-down list for the New button on the Response Optimization toolstrip

      Create Signal Set dialog box with name of signal set on top followed by the area to display added signals

    2. To display the signal in the window, click the output of the Plant block in the Simulink model window.

      Simulink model with plant block output signal selected

    3. Select the signal to add it to the signal set.

      Create Signal Set dialog box with the plant output as the added signal

    4. In Signal set, enter PlantOutput as the selected signal name.

    Click OK to create the variable PlantOutput. It appears in the Data area of the Response Optimizer.

  4. Specify the reference signal for the model output to track.

    1. In the New drop-down list, select Signal Tracking to open a Create Requirement window.

    2. In the Name edit box, enter ref_sig.

    3. In the Time vector edit box, enter linspace(0,50,200)

    4. In the Amplitude edit box, enter 1-exp(-0.1*linspace(0,50,200)).

      Create Requirement dialog box with the specified values entered

      Leave the Tracking Method as SSE which means, at each optimization iteration, the solver attempts to reduce the sum of squared errors between the simulated output and reference signal.

    5. Click Update reference signal data.

    6. In the Specify Signal to Track Reference Signal area, select the check-box corresponding to the signal you selected in the previous step, and click OK.

      PlantOutput signal selected under the specify signal to track reference signal area in the Create Requirements dialog box

      A new reference signal ref_sig is created and appears in the Data area. The Response Optimization window updates to plot the reference signal.

      Time plot of reference signal

Specify Design Variables

When you optimize the model response, the software modifies the design variable values to meet the design requirements.

In the Response Optimization tab:

  1. Create a new set of design variables.

    In the Design Variables Set drop-down list select New.

    Drop-down list for Design Variables Set

    The Create Design Variables Set window shows model parameters that you can use as design variables and indicates their locations within the model subsystems.

    Create Design Variables Set dialog box

  2. Add parameters to the design variables set.

    Select Kd, Ki, and Kp, and click the left arrow with C button to add the selected parameters.

    Create Design Variables Set showing the added selected parameters

    The design variables list displays the following parameter settings:

    • Variable — Parameter name

    • Value — Current parameter value

    • Minimum and Maximum — Parameter bounds

    • Scale — Scaling factor for the parameter

  3. Limit the parameters to positive values. To do so, enter 0 for the minimum value of each parameter in the corresponding Minimum field, and press Enter on your keyboard.

    Create Design Variables Set dialog box with minimum value of all parameters as 0

    Click OK. A new design variable DesignVars is created and appears in the Data area of the Response Optimizer.

    DesignVars is selected in the Data area of the app and its preview is displayed in the preview area

Optimize Model Response

  1. To view the current model response, click Plot Model Response.

    Model response plot

    The plot shows that the model response does not track the reference signal.

  2. Click Optimize.

    At each iteration, the optimization solver Gradient descent (fmincon) modifies the controller parameters to minimize the error between the simulated response and the reference signal. To learn more, see How the Optimization Algorithm Formulates Minimization Problems.

    The message Optimization converged in the Optimization Progress Report indicates that the optimization method found a solution that tracks the reference signal within the tolerances and parameter bounds. For more information about the outputs displayed in the Optimization Progress Report, see Iterative Display.

    Optimization Progress report

  3. Verify that the response tracks the reference signal by observing the amplitude versus time plot.

    Model response plot

    The optimized response closely tracks the reference signal.

  4. To view the optimized parameter values, click DesignVars in the Data area of the Response Optimizer. View the updated values in the Variable Preview area.

    The optimized values of the design variables are automatically updated in the Simulink model.

Related Topics