This example shows how to optimize controller parameters to meet step response design requirements using the Design Optimization tool. You specify the design requirements in a Check Step Response Characteristics block.
The model sldo_model1 includes the following blocks:
Controller block, which is a PID controller. This block controls the output of the Plant subsystem.
Unit Step block applies a step input and produces the model output that should meet step response requirements.
You can also use other types of inputs, such as ramp, to optimize the response to meet step response requirements generated by such inputs.
The plant output must meet the following step response requirements:
Rise time less than 2.5 seconds
Settling time less than 30 seconds
Overshoot less than 5%
Open Simulink® model.
sys = 'sldo_model1'; open_system(sys);
To learn more about the model, see Model Structure.
Add a Check Step Response Characteristics block to the model.
In the Simulink model window, select View > Library Browser.
In the Libraries pane, expand the Simulink Design Optimization node and select Signal Constraints.
Drag and drop the Check Step Response Characteristics block into the model window.
Connect the block to the output.
You must connect the block to the signal on which you want to specify design requirements.
Double-click the Check Step Response Characteristics block to open the Sink Block Parameters: Check Step Response Characteristics dialog box.
Specify step response requirements:
In Rise time (seconds), enter 2.5
In Settling time (seconds), enter 30
In % Overshoot, enter 5
Instead of specifying time-domain requirements in the Check blocks, you can specify them in the Design Optimization tool without adding blocks. For an example, see Specify Reference Signal.
Before you begin this task, specify the design requirements as described in Specify Step Response Requirements.
When you optimize the model response, the software modifies the design variable (parameter) values to meet the design requirements.
In the Simulink model window, select Analysis > Response Optimization.
Alternatively, click Response Optimization in the Block Parameters dialog box.
A Design Optimization tool for the model opens.
The amplitude versus time plot graphically shows the step response requirements specified in the Check Step Response Characteristics block.
Select New in the Design Variables Set drop-down list.
A window opens where you specify design variables.
Click Kd, Ki and Kp to select them.
Click to add the selected parameters to a design variables set.
The software displays the following parameter settings:
Variable — Parameter name
Value — Current parameter value
Minimum and Maximum — Parameter bounds
Scale — Scaling factor for the parameter
The check-box indicates that the parameter is included in the design variable set. The default design variable set name is DesignVars.
To limit the parameters to positive values, enter the minimum value of each parameter as 0 in the corresponding Minimum field and press Enter.
Click OK. A new variable DesignVars appears in Design Optimization Workspace of the Design Optimization tool. You can click the variable to view its contents in the Variable Preview area.
Before you begin this task, you must have already specified the design requirements and design variables as described in Specify Step Response Requirements, and Specify Design Variables, respectively.
(Optional) View the current response of the model. Click .
The plot shows that the model output does not meet the specified step response requirements.
An Optimization Progress window opens.
Tip To view the model response and optimization progress windows simultaneously, tile them using the plot layout area .
At each optimization iteration, the software simulates the model, and the default optimization solver Gradient descent (fmincon) modifies the design variables to reduce the distance between the simulated response and the design requirement line segments. For more information, see Selecting Optimization Methods and How the Optimization Algorithm Formulates Minimization Problems.
After the optimization completes, the optimization progress window resembles the next figure.
The message Optimization converged indicates that the optimization solver found a solution that meets the design requirements within the tolerances and parameter bounds. For more information about the outputs displayed in the optimization, see Iterative Display in the Optimization Toolbox™ documentation.
Verify that the model output meets the step response requirements.
The plot displays the last five iterations. The final response using the optimized parameter values appears as the thick line.
The optimized response lies in the white region bounded by the design requirement line segments and thus meets the requirements.
View the optimized parameter values. Click DesignVars in Design Optimization Workspace and view the updated values in the Variable Preview area.
The optimized values of the design variables are automatically updated in the Simulink model.
After you optimize the model response to meet design requirements, you can save the Design Optimization tool session which includes the optimized parameter values.
Click the Design Optimization tab of the Design Optimization tool.
In the Save drop-down list, select Save to model workspace.
A window opens where you specify the session name.
Specify a session name in the Session field.