Knob
Change parameter or variable value using knob with customizable appearance
- Library:
Simulink / Dashboard / Customizable Blocks
Description
Use theKnobblock to tune the value of a variable or block parameter to during simulation. When you use theKnob块的可定制的模块库,你可以customize the appearance of the block so that it looks like a control in a real system. You can modify the range and tick values on theKnobblock to fit the desired range for the value you want to tune. Use theKnobblock with other dashboard blocks to create an interactive dashboard to control your model.
CustomizeKnobBlocks
When you add aKnob阻止你的莫del, the block is preconfigured with a default design. You can use the block with the default design or customize the appearance of the block using design mode. You can enter design mode in one of three ways after selecting the block:
On theKnobtab, underDesign, clickEdit.
In theProperty Inspector, on theDesigntab, clickEdit Design.
Pause on the ellipsis that appears above the block and click theEdit Custom Blockbutton.
In design mode, you have access to block parameters and settings that allow you to design the appearance of the block. You can use the toolbar above the block to change the background image or needle image and to set the opacity and color for the scale, tick labels, and value bar. To design the appearance of the scale, select the aspect of the scale you want to edit in the middle section of the toolbar. Use the controls on the right of the toolbar to set the color and opacity. You can also click and drag to reposition the needle or the scale.
For fine control of the block design, use theDesigntab in theProperty Inspector. You can use theProperty Inspectorto enter exact values for design settings. TheDesigntab also includes design parameters that are not available through the toolbar or interactive editing, such as the ability to add a foreground image to the block.
When you finish editing the design, clickExitin the upper-right of the canvas to exit design mode.
Connect Dashboard Blocks
Dashboard blocks do not use ports to connect to model elements. To connect dashboard blocks to variables and block parameters, use connect mode. Connect mode facilitates the process of connecting dashboard blocks in your model, especially when you want to connect multiple blocks at once. To connect a single dashboard block, you can also use theConnectiontable in the block dialog box.
Tip
You can modify dashboard block connections in your model during normal and accelerator mode simulations.
Note
Dashboard blocks cannot connect to variables until you update the model diagram. To connect dashboard blocks to variables or modify variable values between opening your model and running a simulation, update the model diagram usingCtrl+D.
To enter connect mode, in the canvas, select the dashboard block to connect. On the Simulink®Toolstrip, a tab named after the type of the selected block appears. On the block tab, clickConnect. In connect mode, when you select one or more blocks, a list of parameters and variables available for connection appears. Select a variable or parameter from the list to connect to the selected dashboard block.
When the value of the selected variable or block parameter is nonscalar, use the text box at the bottom of theConnectiontable to specify the element you want to connect to the dashboard block. To connect to an element of a vector, matrix, or array, specify the element index, for example,3
or(1,3)
. To connect to an element in a bus or structure, specify the element in the context of the bus or structure hierarchy by using dots to indicate different levels in the hierarchy, and omit the top level. For example, specifya.b
to connect to scalar elementb
of the structure or busa
nested inside the selected composite variable or parameter.
To connect another dashboard block, pause on another dashboard block and click theConnectbutton above it. Then, make a selection of signals and blocks in your model and choose a model element to connect.
When you finish connecting the dashboard blocks in your model, on the block tab, clickDone Connecting.
Tip
You can hide the message shown on unconnected blocks using theset_param
function with theShowInitialText
block parameter. The message also disappears when you connect the block.
Parameter Logging
Tunable parameters connected to dashboard blocks are logged to the Simulation Data Inspector, where you can view the parameter values along with logged signal data. You can access logged parameter data in the MATLAB®workspace by exporting the parameter data from the Simulation Data Inspector by using the UI or theSimulink.sdi.exportRun
function. For more information about exporting data using the Simulation Data Inspector UI, seeExport Data to the Workspace or a File. The parameter data is stored in aSimulink.SimulationData.Parameter
object, accessible as an element in the exportedSimulink.SimulationData.Dataset
.
Limitations
Except for theDashboard Scopeblock and theDisplayblock, dashboard blocks can only connect to real scalar signals.
The toolstrip does not support blocks that are inside a panel.
You cannot use theConnectiontable in the block dialog to connect a dashboard block to a block that is commented out. When you connect a dashboard block to a commented block using connect mode, the dashboard block does not display the connected value until the you uncomment the block.
Dashboard blocks cannot connect to model elements inside referenced models.
When you simulate a model hierarchy, dashboard blocks inside referenced models do not update.
Dashboard blocks do not support rapid accelerator simulation.
When you connect a dashboard block to a variable or parameter during simulation, the data for that variable or parameter is not logged to the Simulation Data Inspector. To log variable and parameter data to the Simulation Data Inspector, connect the dashboard block to the variable or parameter prior to simulation.
When you simulate a model in external mode with theDefault parameter behaviorset toInlined, dashboard blocks can appear to change parameter and variable values. However, the change does not propagate to the simulation. For example,Gainblocks display changes made to theGainparameter using the dashboard blocks, but theGainvalue used in the simulation does not change.
Parameters
Model Examples
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|