Documentation Center

  • Trial Software
  • Product Updates

setBlockValue

Set value of tuned block parameterization in slTuner interface

Syntax

  • setBlockValue(st,blk_val_struc) example

Description

example

setBlockValue(st,blk,val) sets the value of the parameterization of the tuned block, blk, in the slTuner interface, st.

The slTuner interface automatically associates a parametric model with each Simulink® model listed in the TunedBlocks property of st. This parameterization expresses each tunable block as a Control Design Block or a tunable genss model. The parameterization specifies which parameters are tuned by commands such as looptune. Use getBlockValue to access the current value of this parameterization.

You can use setBlockValue to initialize the tunable parameters of blocks parameterized by Control Design Blocks before tuning st with a tuning command such as systune or looptune.

example

setBlockValue(st,m) updates the current values of the tunable parameters in st to match the corresponding values of tunable parameters in the Generalized LTI Model model, m. Only parameters common to st and m are updated. Use this syntax to update st after obtaining m by tuning with commands such as systune, looptune, or hinfstruct.

example

setBlockValue(st,blk_val_struc) updates the value of multiple blocks using the structure, blk_val_struc. Only blocks common to st and blk_val_struc are updated. Use this syntax to update st after obtaining blk_val_struc by tuning with commands such as systune, looptune, or hinfstruct. blk_val_struc corresponds to the Blocks property value of the generalized state-space model returned by such commands.

Examples

expand all

Set Value of Tuned Block Parameterization

Create an slTuner interface for the scdcascade model, and set the value of the parametrization of one of the tuned blocks.

Create an slTuner interface.

open_system('scdcascade');
st = slTuner('scdcascade',{'C1','C2'});

Both C1 and C2 are PI controllers. Examine the default parameterization of C1.

getBlockParam(st,'C1')
  Parametric continuous-time PID controller "C1" with formula:

             1 
  Kp + Ki * ---
             s 

  and tunable parameters Kp, Ki.

Type "pid(ans)" to see the current value and "get(ans)" to see all properties.

The default parameterization is a PI controller with two tunable parameters, Kp and Ki.

Set the value of the parameterization of C1.

C = pid(4.2);

setBlockValue(st,'C1',C);

Examine the value of the parameterization of C1.

getBlockValue(st,'C1')
  Kp = 4.2
 
Name: C1
P-only controller.

Examine the parameterization of C1.

getBlockParam(st,'C1')
  Parametric continuous-time PID controller "C1" with formula:

             1 
  Kp + Ki * ---
             s 

  and tunable parameters Kp, Ki.

Type "pid(ans)" to see the current value and "get(ans)" to see all properties.

Observe that although the current block value is a P-only controller, the block parameterization continues to be a PI-controller.

Set Value of Tuned Block Parameterization Using Generalized State-Space Model

This example shows how to convert an slTuner interface for the Simulink model rct_diskdrive to a genss model. Perform this conversion to tune the model blocks using hinfstruct (requires Robust Control Toolbox™). After validating the tuning results, you can update the slTuner interface with the tuned parameters returned by hinfstruct. Then, you can use the slTuner interface to write the tuned parameter values to the Simulink model.

This example requires Robust Control Toolbox.

Create an slTuner interface for rct_diskdrive. Add C and F as tuned blocks of the interface.

open_system('rct_diskdrive');
st = slTuner('rct_diskdrive',{'C','F'});

The default parameterization of the transfer function block, F, is a transfer function with two free parameters. Because F is a low-pass filter, you must constrain its coefficients. To do so, specify a custom parameterization of F.

a = realp('a',1);    % filter coefficient
setBlockParam(st,'F',tf(a,[1 a]));

Suppose you want to tune the closed-loop transfer function using hinfstruct, which operates only on genss models. Convert st to a genss model.

t0 = genss(st);
t0 = getIOTransfer(t0,{'r','n'},{'y','e'});

t0 contains the linearized closed-loop transfer function from the reference noise inputs, r and n, to the measurement and error outputs, y and e. The error output is needed for the loop-shaping weighting function.

Define the loop-shaping weighting functions and append them to t0.

wc = 1000;
s = tf('s');
ls = (1+0.001*s/wc)/(0.001+s/wc);

t0 = blkdiag(1,ls)*t0*blkdiag(1,1/ls);

t0 is a weighted closed-loop model of the control system of rct_diskdrive.

You can now use hinfstruct to tune the parameters of t0.

t = hinfstruct(t0);

After validating the tuning result, suppose you want to update the Simulink model with the tuned values.

setBlockValue(st,t);
writeBlockValue(st);

You can also use the command setBlockValue(st,t.Blocks) to update the block parameterization values in st.

Input Arguments

expand all

st — Interface for tuning control systems modeled in SimulinkslTuner interface

Interface for tuning control systems modeled in Simulink, specified as an slTuner interface.

blk — Blockstring

Block in the list of tuned blocks for st, specified as a string.

You can specify the full block path or any portion of the block path that uniquely identifies the block among the other tuned blocks of st.

For example, blk = 'scdcascade/C1' or blk = 'C1'.

val — Block parameterization valuecontrol design block | numeric LTI model

Block parameterization value, specified as a control design block or numeric LTI model.

val can be any model that is compatible with the parameterization of blk. For example, suppose blk is parameterized as an ltiblock.pid. You can specify val as one of the following models: ltiblock.pid, numeric pid, numeric tf model representing a PID controller.

setBlockValue updates the value of the parameters of blk based on the parameters of val. setBlockValue does not change the structure of the parameters of blk.

To change the parameterization of blk, use setBlockParam. For example, you can change the block parameterization from ltiblock.pid to a three-pole ltiblock.tf model.

Example:

m — Tuned modelgeneralized LTI model

Tuned model that has some parameters in common with st, specified as a Generalized LTI Model.

blk_val_struc — Parameterization value of multiple blocksstructure

Parameterization value of multiple blocks, specified as a structure.

See Also

| | | |

Was this topic helpful?