Create an slTuner
interface to the Simulink model, and specify the blocks to be tuned. Configure the interface for tuning with looptune
by adding analysis points that define the separation between the plant and the controller. Also add the analysis points needed for imposing tuning requirements.
This system is now ready for tuning with looptune
, using tuning goals that you specify. For example, specify a target bandwidth range. Create a tuning requirement that imposes reference tracking in both channels of the system, and a disturbance rejection requirement.
Final: Peak gain = 1.04, Iterations = 66
looptune
successfully tunes the system to these requirements. However, you might want to switch to systune
to take advantage of additional flexibility in configuring your problem. For example, instead of tuning both channels to a loop bandwidth inside wc
, you might want to specify different crossover frequencies for each loop. Or, you might want to enforce the tuning requirements, req1
and req2
, as hard constraints, and add other requirements as soft requirements.
Convert the looptune
input arguments to a set of input arguments for systune
.
This command returns a set of arguments you can feed to systune
for equivalent results to tuning with looptune
. In other words, the following command is equivalent to the looptune
command.
Final: Peak gain = 1.04, Iterations = 66
Examine the tuning requirements returned by looptuneSetup
. When tuning this control system with looptune
, all requirements are treated as soft requirements. Therefore, HardReqs
is empty. SoftReqs
is an array of TuningGoal
requirements. These requirements together enforce the bandwidth and margins of the looptune
command, plus the additional requirements that you specified.
SoftReqs =
5x1 heterogeneous SystemLevel (LoopShape, Tracking, Gain, ...) array with properties:
Models
Openings
Name
For example, examine the first entry in SoftReqs
.
ans =
LoopShape with properties:
LoopGain: [1x1 zpk]
CrossTol: 0.3495
Focus: [0 Inf]
Stabilize: 1
LoopScaling: 'on'
Location: {'y'}
Models: NaN
Openings: {0x1 cell}
Name: 'Open loop GC'
looptuneSetup
expresses the target crossover frequency range wc
as a TuningGoal.LoopShape
requirement. This requirement constrains the open-loop gain profile to the loop shape stored in the LoopGain
property, with a crossover frequency and crossover tolerance (CrossTol
) determined by wc
. Examine this loop shape.
The target crossover is expressed as an integrator gain profile with a crossover between 0.1 and 0.5 rad/s, as specified by wc
. If you want to specify a different loop shape, you can alter this TuningGoal.LoopShape
requirement before providing it to systune
.
looptune
also tunes to default stability margins that you can change using looptuneOptions
. For systune
, stability margins are specified using TuningGoal.Margins
requirements. Here, looptuneSetup
has expressed the default stability margins as soft TuningGoal.Margins
requirements. For example, examine the fourth entry in SoftReqs
.
ans =
Margins with properties:
GainMargin: 7.6000
PhaseMargin: 45
ScalingOrder: 0
Focus: [0 Inf]
Location: {2x1 cell}
Models: NaN
Openings: {0x1 cell}
Name: 'Margins at plant inputs'
The last entry in SoftReqs
is a similar TuningGoal.Margins
requirement constraining the margins at the plant outputs. looptune
enforces these margins as soft requirements. If you want to convert them to hard constraints, pass them to systune
in the input vector HardReqs
instead of the input vector SoftReqs
.