This example shows how to enable custom masked subsystems in Control System Designer. Once configured, you can tune a custom masked subsystem in the same way as any supported blocks in Simulink Control Design. For more information, see "What Blocks Are Tunable?".
For this example, tune the
Lead-Lag Controller block in the
This block implements a compensator with a single zero, a single pole, and a gain. To open the Block Parameters dialog box, add the Lead-Lag Controller block to your model, and double-click the block.
The block uses the specified Gain,
K, Zero Frequency,
wz, and Pole Frequency,
wp, to implement the compensator transfer function:
To configure a masked subsystem for tuning with Control System Designer, you specify a configuration function. In this example, use the configuration function in scdleadexample.m, which specifies that:
There is only one pole allowed (MaxPoles constraint)
There is only one zero allowed (MaxZeros constraint)
The gain is tunable (isStaticGainTunable constraint)
Register the configuration in the subsystem using the
SCDConfigFcn block callback function. Right-click the Lead-Lag Controller block and select Properties. In the Block Properties dialog box, on the Callbacks tab, set
Alternatively, you can set
SCDConfigFcn using the command
After setting the SCDConfigFcn the block is now ready to be used in a Simulink Compensator Design Task.
The scdspeedctrlleadlag model uses the Lead-Lag Controller block to tune the feedback loop in "Single Loop Feedback/Prefilter Design". In this model, the SCDConfigFcn property is already set. .
Step 1 To open the Control System Designer, in the Simulink model window, select Analysis > Control Design > Control System Designer.
Step 2 In the Edit Architecture dialog box, on the Blocks tab, click Add Blocks. In the Select Blocks to Tune dialog box, click Feedback Controller, and select
Step 3 On the Signals tab, the analysis points defined in the Simulink model are automatically added as Locations.
scdspeedctrlleadlag/Speed Reference output port 1
scdspeedctrlleadlag/Plant Model output port 1
Step 4 On the Linearization Options tab, in the Operating Point drop-down list, select Model Initial Condition.
Step 5 Create new plots to view the step responses while tuning the controllers.
In the Control System Designer, click New Plot, and select New Step. In the Select Response to Plot drop-down menu, select New Input-Output Transfer Response. Configure the response as follows:
To view the response, click Plot.
The Control System Designer contains four methods to tune a control system:
Manually tune the parameters of the
Lead-Lag Controller using the compensator editor. For more information, see "Tuning Simulink Blocks in the Compensator Editor".
Graphically tune the compensator poles, zeros, and gains using open/closed-loop Bode, root locus, or Nichols editor plots. Click Tuning Methods, and select an editor under Graphical Tuning.
Optimize compensator parameters using both time-domain and frequency-domain design requirements (requires Simulink Design Optimization™ software). Click Tuning Methods, and select Optimization based tuning. For more information, see "Enforcing Time and Frequency Requirements on a Single-Loop Controller Design".
Compute initial compensator parameters using automated tuning based on parameters such as closed-loop time constants. Click Tuning Methods, and select either PID tuning, IMC tuning, Loop shaping (requires Robust Control Toolbox™ software), or LQG synthesis.
The design requirements for the reference step response in the example "Single Loop Feedback/Prefilter Design" can be met with the following Lead-Lag Controller block parameters:
Gain = 0.0075426
Zero Frequency (rad/s) = 2
Pole Frequency (rad/s) = 103.59
The responses of the closed-loop system are shown below:
To write the compensator parameters back to the Simulink model, click Update Blocks. You can then test your design on the nonlinear model.