In this tutorial, you learn how to use the Simulink^{®} Control Design™ GUI to design a controller for a single-loop feedback system that is operating at the operating conditions specified in the Simulink model. You accomplish the following tasks:
Configure the model and GUI for compensator design.
Design a PID compensator using the robust-response-time tuning algorithm and Bode graphical design.
Simulate the closed-loop nonlinear model.
watertank_comp_design Simulink Model. The watertank_comp_design
model,
shown in the following figure, contains the Water-Tank System plant
and a simple proportional-integral-derivative (PID) controller, called
Controller, in a single-loop feedback system.
To view the Water-Tank System and the Controller, double-click
the corresponding subsystem in the watertank_comp_design
model.
For descriptions of these subsystems, see the following topics:
Water-Tank Subsystem. The Water-Tank subsystem of the watertank_comp_design
model
appears in the following figure.
This model represents the water-tank system depicted in the following figure.
Water enters the tank from the top at a rate proportional to the voltage, V, applied to the pump. The water leaves through an opening in the tank base at a rate that is proportional to the square root of the water height, H, in the tank. The presence of the square root in the water flow rate results in a nonlinear plant.
The following table describes the variables, parameters, differential equations, states, inputs, and outputs of the water-tank system.
Variables | H is the height of water in the tank. Vol is the volume of water in the tank. V is the voltage applied to the pump. |
Parameters | A is the cross-sectional area of the tank. b is a constant related to the flow rate into the tank. a is a constant related to the flow rate out of the tank. |
Differential equation | $$\frac{d}{dt}Vol=A\frac{dH}{dt}=bV-a\sqrt{H}$$ |
States | H |
Inputs | V |
Outputs | H |
Controller Subsystem. The Controller subsystem appears in the following figure.
This model contains a PID Controller block that controls the height of the water in the Water-Tank System.
The PID controller you design in this tutorial must control the Water-Tank System response such that the:
Overshoot is less than 5%.
Rise time is less than 5 seconds.
The process for designing a compensator for the Water-Tank System in this tutorial includes the following tasks:
Configuring the model and GUI for the design.
Designing a PID compensator using the robust response time tuning algorithm.
Tuning the compensator using the Bode design technique.
Simulating the closed-loop Simulink model with the compensator design to analyze the system dynamics.
Simulink Control Design tools work only with linear plant models. Because the Water-Tank System is nonlinear, Simulink Control Design automatically linearizes the model about the model operating point, by default. The linearization provides a valid approximation of the nonlinear model in a region around the operating point. For more information about linearization and how the operating point impacts linearization results, see Linearizing Nonlinear Models.
In this portion of the tutorial, you design a compensator using the automated PID robust-response-time tuning algorithm. This tuning method tunes the PID gains to maximize bandwidth and optimize phase margin.
Open the watertank_comp_design
model
by typing the model name in the MATLAB^{®} Command Window:
watertank_comp_design
The command opens the watertank_comp_design
model
in Simulink, as shown in the following figure.
In the watertank_comp_design
model
window, select Analysis > Control Design > Control System
Designer.
This action opens the Control and Estimation Tools Manager with the Simulink Compensator Design Task node selected.
Select the PID Controller block as the block to tune.
In the Tunable Blocks tab, click Select Blocks.
This action opens the Select Blocks to Tune window.
In the watertank_comp_design tree, select the Controller subsystem.
Select the Tune? check box for PID Controller.
Click OK.
Define the closed-loop systems for which you want to analyze the response.
The input and output points of the closed-loop path are already
defined in the watertank_comp_design
model. If
you needed to add or define them, you would use the following steps:
In the watertank_comp_design
model,
right-click the output of the Desired Water Level block, and select Linear Analysis Points > Input
Point.
This action displays the symbol on the signal line. This symbol indicates the input of the closed-loop path.
Right-click the output signal from the Water-Tank System, and select Linear Analysis Points > Output Point.
This action displays the symbol on the signal line. This symbol indicates the output of the closed-loop path.
In the Control and Estimation Tools Manager, click Tune Blocks to open the Design Configuration Wizard. Click Next.
Step 1 of the Design Configuration Wizard prompts you to select the design plots you will use to tune the controller. Accept the default settings and click Next.
In Step 2 of the Design Configuration Wizard, specify the type of plot for analyzing the response.
In the Analysis Plots area, select Step
for
the Plot Type corresponding to Plot
1.
In the Plots section of the Contents in Plots pane, select 1 for Closed Loop from Desired Water Level to Water-Tank System.
Click Finish.
The software performs the following actions:
Linearizes the Simulink model about the operating point specified in the model.
Creates a SISO Design Task node under the Simulink Compensator Design Task node.
Opens the following plot windows:
Linear System Analyzer for SISO Design Task window, which shows the closed-loop Step Response plot of the linearized model
SISO Design for SISO Design Task window, which is empty
You do not use in this window in this section of the tutorial. Keep this window open for the next section of the tutorial.
The Control and Estimation Tools manager resembles the following figure.
The Step Response plot shows an overshoot that does not meet the overshoot design requirement of less than 5%.
In the Automated Tuning tab of
the SISO Design Task node in the Control and
Estimation Tools Manager, select PID Tuning
as
the Design method.
In the Specifications area, select the following options:
Controller type: PI
Tuning method: Robust
response time
Click Update Compensator.
This action computes the PI values for the compensator using the robust response time tuning algorithm and updates the Step Response plot.
Tip You can view the PI values in the Parameter tab of the Compensator Editor tab in the SISO Design Task node. |
Evaluate whether the compensator design meets the design requirements by analyzing the overshoot and the rise time, as follows:
Right-click the Step Response plot and select the following options:
Characteristics > Peak Response
Characteristics > Rise Time
These actions add a plot marker to the plot for each characteristic, shown as blue dots.
Left-click each blue dot to open the corresponding data marker.
The data markers show the following response characteristics:
The overshoot is 11.6%.
The rise time is 82.2 seconds.
This system response with the PID compensator exceeds the maximum allowed overshoot of 5%. The rise time is much slower than the required rise time of 5 seconds.
You decrease the rise time by increasing the gain of the compensator, as described in PID Control Design Using Bode Graphical Tuning.
Tip
You can also decrease the rise time by adjusting the loop bandwidth.
First, select |
In this example, you decrease the rise time of the Water-Tank System response by increasing the compensator gain using Bode graphical tuning.
Bode graphical tuning lets you design a compensator by manipulating Bode diagrams of the open-loop response. This process is also called loop shaping.
You must have already designed an initial compensator using PID tuning, as described in PID Control Design Using Robust-Response-Time Tuning Algorithm.
If you have not performed this step, click here to complete it.
To design a compensator using Bode graphical tuning:
In the Control and Estimation Tools Manager, select the Graphical Tuning tab of the SISO Design Task node.
In the Plot Type cell that corresponds to Plot 1, select Open-Loop Bode.
This action creates an Open-Loop Bode plot in the SISO Design for SISO Design Task window. This plot shows a Bode plot of the linearized model with the compensator designed using automated PID tuning.
In the SISO Design window, drag the Bode Magnitude line upward to increase the gain. As you adjust the gain, view the affects on the closed-loop response in the Step Response plot.
By increasing the gain, you increase the bandwidth and speed up the response. One possible compensator design that meets the tutorial requirements has the following parameters:
P = 5.0368
I = 0.11434
D = 0
Tip You can view the parameter values corresponding to the gain adjustment you made in the Bode Magnitude plot in the Compensator Editor tab of the SISO Design Task. You can also adjust the parameter values in this tab. |
Evaluate whether the compensator design meets the design requirements by analyzing the overshoot and the rise time, as follows:
Right-click the Step Response plot and select the following options, if you have not done so already:
Characteristics > Peak Response
Characteristics > Rise Time
These actions add a plot marker to the plot for each characteristic, shown as blue dots.
Left-click each blue dot to open the corresponding data marker.
The data markers show the following response characteristics:
The overshoot is 0.437%.
The rise time is 1.72 seconds.
This compensator design satisfies the design requirements of less than 5% overshoot and less than 5 second rise time.
In this example, you simulate the nonlinear closed-loop Simulink model that includes a PID controller to determine how well the design meets the requirements.
You must have already designed the compensator, as described in PID Control Design Using Bode Graphical Tuning.
If you have not performed this step, click here to complete it.
In the Control and Estimation Tools Manager SISO Design Task node, click Update Simulink Block Parameters.
This action writes the compensator parameters into the PID Controller block of the Controller subsystem in the Simulink model.
Tip You can view the PID Controller block parameters in the Function Block Parameters Dialog box. To open this dialog box, double-click the PID Controller block. |
In the Simulink model, double-click the Scope block to open the Scope block window.
Simulate the model.
This action updates the Scope window with the response of the nonlinear model with the compensator design. This simulation shows that the rise time is less than 5 seconds and there is minimal overshoot. Thus, this compensator design meets the requirements of less than 5% overshoot and less than 5 second rise time.