# TuningGoal.Margins class

Package: TuningGoal

Stability margin requirement for control system tuning

## Description

Use TuningGoal.Margins to specify a tuning goal for the gain and phase margins of a SISO or MIMO feedback loop. You can use this tuning goal for validating a tuned control system with viewGoal. You can also use the tuning goal for control system tuning with tuning commands such as systune or looptune.

After you create a tuning goal, you can configure it further by setting Properties of the object.

After using the tuning goal to tune a control system, you can visualize the tuning goal and the tuned value using the viewGoal command. For information about interpreting the margins goal, see Stability Margins in Control System Tuning.

## Construction

Req = TuningGoal.Margins(location,gainmargin,phasemargin) creates a tuning goal that specifies the minimum gain and phase margins at the specified location in the control system.

### Input Arguments

 location Location in the control system at which the minimum gain and phase margins apply, specified as a character vector or cell array of character vectors that identify one or more locations in the control system to tune. What locations are available depends on what kind of system you are tuning:If you are tuning a Simulink® model of a control system, you can use any linear analysis point marked in the model, or any linear analysis point in an slTuner (Simulink Control Design) interface associated with the Simulink model. Use addPoint (Simulink Control Design) to add analysis points to the slTuner interface. For example, if the slTuner interface contains an analysis point u, you can use 'u' to refer to that point when creating tuning goals. Use getPoints (Simulink Control Design) to get the list of analysis points available in an slTuner interface to your model.If you are tuning a generalized state-space (genss) model of a control system, you can use any AnalysisPoint location in the control system model. For example, the following code creates a PI loop with an analysis point at the plant input 'u'. AP = AnalysisPoint('u'); G = tf(1,[1 2]); C = tunablePID('C','pi'); T = feedback(G*AP*C,1); When creating tuning goals, you can use 'u' to refer to the analysis point at the plant input. Use getPoints to get the list of analysis points available in a genss model. The margin requirements apply to the point-to-point, open-loop transfer function at the specified loop-opening location. That transfer function is the open-loop response obtained by injecting signals at the specified location, and measuring the return signals at the same point. If location is a cell array, then the margin requirement applies to the MIMO open-loop transfer function. gainmargin Required minimum gain margin for the feedback loop, specified as a scalar value in dB. TuningGoal.Margins uses disk-based gain and phase margins, which provide a stronger guarantee of stability than the classical gain and phase margins. (For details about disk margins, see Stability Analysis Using Disk Margins (Robust Control Toolbox).) The gain margin indicates how much the gain of the open-loop response can increase or decrease without loss of stability. For instance, For a SISO system, setting gainmargin = 3 specifies a requirement that the closed-loop system remain stable for changes in the open-loop gain of up to ±3 dB.For a MIMO system, setting gainmargin = 3 specifies a requirement that the closed-system remain stable for gain changes up to ±3 dB in each feedback channel. The gain can change in all channels simultaneously, and by a different amount in each channel. phasemargin Required minimum phase margin for the feedback loop, specified as a scalar value in degrees. TuningGoal.Margins uses disk-based gain and phase margins, which provide a stronger guarantee of stability than the classical gain and phase margins. (For details about disk margins, see Stability Analysis Using Disk Margins (Robust Control Toolbox).) The phase margin indicates how much the phase of the open-loop response can increase or decrease without loss of stability. For instance, For a SISO system, setting phasemargin = 45 specifies a requirement that the closed-loop system remain stable for changes of up to ±45° in the phase of the open-loop response.For a MIMO system, setting phasemargin = 45 specifies a requirement that the closed-system remain stable for phase changes up to ±45° in each feedback channel. The phase can change in all channels simultaneously, and by a different amount in each channel.

## Examples

collapse all

Create a margin requirement for the inner loop of the following control system. The requirement imposes a minimum gain margin of 5 dB and a minimum phase margin of 40 degrees.

Create a model of the system. To do so, specify and connect the numeric plant models G1 and G2, and the tunable controllers C1 and C2. Also specify and connect the AnalysisPoint blocks AP1 and AP2 that mark points of interest for analysis and tuning.

G1 = tf(10,[1 10]);
G2 = tf([1 2],[1 0.2 10]);
C1 = tunablePID('C','pi');
C2 = tunableGain('G',1);
AP1 = AnalysisPoint('AP1');
AP2 = AnalysisPoint('AP2');
T = feedback(G1*feedback(G2*C2,AP2)*C1,AP1);

Create a tuning requirement object.

Req = TuningGoal.Margins('AP2',5,40);

This requirement imposes the specified stability margins on the feedback loop identified by the AnalysisPoint channel 'AP2', which is the inner loop.

Specify that these margins are evaluated with the outer loop of the control system open.

Req.Openings = {'AP1'};

Adding 'AP1' to the Openings property of the tuning requirements object ensures that systune evaluates the requirement with the loop open at that location.

Use systune to tune the free parameters of T to meet the tuning requirement specified by Req. You can then use viewGoal to validate the tuned control system against the requirement.

Create a requirement that sets minimum gain and phase margins for the loop defined by three loop-opening locations in a control system to tune. Because this loop is defined by three loop-opening locations, it is a MIMO loop.

The requirement sets a minimum gain margin of 10 dB and a minimum phase margin of 40 degrees, within the band between 0.1 and 10 rad/s.

Req = TuningGoal.Margins({'r','theta','phi'},10,40);

The names 'r', 'theta', and 'phi' must specify valid loop-opening locations in the control system that you are tuning.

Limit the requirement to the frequency band between 0.1 and 10 rad/s.

Req.Focus = [0.1 10];

## Tips

• This tuning goal imposes an implicit stability constraint on the closed-loop sensitivity function measured at Location, evaluated with loops opened at the points identified in Openings. The dynamics affected by this implicit constraint are the stabilized dynamics for this tuning goal. The MinDecay and MaxRadius options of systuneOptions control the bounds on these implicitly constrained dynamics. If the optimization fails to meet the default bounds, or if the default bounds conflict with other requirements, use systuneOptions to change these defaults.

## Algorithms

When you tune a control system using a TuningGoal, the software converts the tuning goal into a normalized scalar value f(x), where x is the vector of free (tunable) parameters in the control system. The software then adjusts the parameter values to minimize f(x) or to drive f(x) below 1 if the tuning goal is a hard constraint.

For TuningGoal.Margins, f(x) is given by:

$f\left(x\right)={‖2\alpha S-\alpha I‖}_{\infty }.$

S = D–1[I – L(s,x)]–1D is the scaled sensitivity function.

L(s,x) is the open-loop response being shaped.

D is an automatically-computed loop scaling factor. For more information about D, see Stability Margins in Control System Tuning.

α is a scalar parameter computed from the specified gain and phase margin. For more information about α, see Stability Analysis Using Disk Margins (Robust Control Toolbox).

## Compatibility Considerations

expand all

Behavior changed in R2016a