Main Content

Describe Component Behavior Using金宝app

System design and architecture definitions can involve a behavior definition for some components, such as the algorithm for a data processing component. Define components in System Composer™ architecture models as behaviors using Simulink®subsystem components that are part of the parent model, or referenced behaviors by linking components to Simulink models or subsystems.

You can simulate the Simulink component implementations in System Composer. Use theSimulation Data Inspectorto view and compare simulation results between model designs.

Create Simulink Behavior with Robot Arm Model

This example shows how to use a robot arm model to create Simulink® behavior from theMotioncomponent.

1. Open theRobot.slxmodel.

model = systemcomposer.openModel('Robot');

TheRobotmodel has an interfacesensordataapplied on the portsSensorData

2. Look up theMotioncomponent.

motionComp = lookup(model,'Path','Robot/Motion');

3. Create a Simulink behavior.

motionComp.createSimulinkBehavior('MotionSimulink');

Create Referenced金宝appBehavior Model

When a component does not require decomposition from an architecture standpoint, you can design and define the behavior of the component in Simulink. When you link to a Simulink behavior, theComponentblock becomes aReference Componentblock.

Areference componentis a component whose definition is a separate architecture model, Simulink behavior model, or Simulink subsystem behavior. A reference component represents a logical hierarchy of other compositions.

You can reuse compositions in the model using reference components. There are three types of reference components:

  • Model referencesare Simulink models.

  • Subsystem referencesare Simulink subsystems.

  • Architecture referencesare System Composer architecture models.

In this section, you will create a model reference and a subsystem reference. For more information on architecture references, seeCreate Reference Architecture

Referenced or linked models are useful for collaborative design with version control using Simulink projects. For more information, seeOrganize System Composer Files in Projects

Create Reusable金宝appBehavior Using Model Reference Component

Use Simulink model references to describe the implementation of System Composer components.

  1. Right-click theMotioncomponent and selectCreate Simulink Behavior。Alternatively, navigate toModeling>Create Simulink Behavior

  2. From theTypelist, selectModel Reference。Provide the model nameMotionSimulink。The default name is the name of the component.

    创建模型的行为金宝app与不结盟运动新模式对话框e 'Motion Simulink' with options browse, from Simulink template, new data dictionary name, OK, cancel, and help.

  3. A new Simulink model file with the provided name is created in the current folder. The root-level ports of the Simulink model reflect the ports of the component. The component in the architecture model is linked to the Simulink model. The金宝appicon on the component indicates that the component has a Simulink behavior.

    The motion component with referenced Simulink model between chevrons with arrow pointing to what is inside. There is a Simulink base model inside with in-ports and out-ports designated.

  4. To view the interfaces on theSensorDataport converted into Simulink bus elements, double-click the port in Simulink.

    Sensor data bus element properties.

  5. To remove model behavior, right-click the linkedMotioncomponent and selectInline Model

For more information on removing referenced behaviors, seeRemove Reference Architecture

Create Reusable金宝appSubsystem Behavior Using Subsystem Reference Component

Use subsystem references to author Simulink or Simscape™ behaviors with physical ports, connections, and blocks. For more information, seeDescribe Component Behavior Using Simscape

  1. Right-click theMotioncomponent and selectCreate Simulink Behavior。Alternatively, navigate toModeling>Create Simulink Behavior

  2. From theTypelist, selectSubsystem Reference。Provide the model nameMotionSubsystem。The default name is the name of the component.

    Create Simulink Behavior dialog with new subsystem name 'Motion Subsystem'.

  3. A new Simulink subsystem file with the provided name is created in the current folder. The root-level ports of the Simulink subsystem reflect the ports of the component. The component in the architecture model is linked to the Simulink subsystem. TheSubsystemicon on the component indicates that the component has a Simulink subsystem behavior.

    Motion component as a subsystem reference component.

You can access and edit referenced Simulink models and subsystems by double-clicking theReference Componentin the architecture model. When you save the architecture model, all unsaved referenced Simulink behaviors are also saved, and all linked components are updated.

Create金宝appSubsystem Behavior Using Subsystem Component

Asubsystem componentis a Simulink subsystem that is part of the parent System Composer architecture model.

Add Simulink subsystem behavior to a component to author a subsystem component in System Composer. You cannot synchronize and reuse subsystem components asReference Componentblocks because the component is part of the parent model.

  1. Right-click theSensorcomponent and selectCreate Simulink Behavior。Alternatively, navigate toModeling>Create Simulink Behavior

  2. From theTypelist, selectSubsystem

    Create Simulink subsystem behavior dialog.

  3. TheSensorcomponent is now a Simulink subsystem of the same name that is part of the parent System Composer architecture model.

    The root-level ports of the Simulink model reflect the ports of the component. The金宝appicon on the component indicates that the component has a Simulink subsystem behavior.

    Sensor component is now a Simulink subsystem component.

  4. You can continue to provide specific dynamics and algorithms in the Simulink subsystem behavior model. Adding root-level ports in the subsystem behavior creates additional ports on the subsystem component.

  5. You can use subsystem components to author Simscape component behaviors with physical ports, connections, and blocks. For example, this amplifier physical system uses electrical domain blocks inside a subsystem component in a System Composer architecture model.

    Amplifier physical subsystem with electrical domain blocks.

Convert Simulink Subsystem Component to Subsystem Reference Component

You can convert existing Simulink subsystem components that are part of the parent System Composer model to subsystem reference components. The subsystem reference components are saved separately as a reusable artifact.

  1. Right-click the subsystem component block and selectBlock Parameters (Subsystem)

  2. Click theSubsystem Referencetab.

    Block parameters for a subsystem component.

  3. ClickConvertto open theConvert to Subsystem Referencedialog.

  4. Choose a name for the new subsystem file. Optionally, selectTransfer test harnessesto transfer test harnesses. ClickConvertto complete the conversion.

    Convert to subsystem reference dialog.

To convert a subsystem component to a subsystem reference programmatically, use thecreateSimulinkBehaviorfunction.

Link to Existing Simulink Behavior Model

You can link to an existing Simulink behavior model or subsystem from a System Composer component, provided that the component is not already linked to a reference architecture. Right-click the component and selectLink to Model。Type in or browse for the name of a Simulink model or subsystem.

Link to model dialog with existing model name 'Motion Simulink'. Press Enter for OK.

Any subcomponents and ports in the components are deleted when the component links to a Simulink model or subsystem. A prompt displays to continue and lose subcomponents and ports.

Note

Linking a System Composer component to a Simulink model with root-level enable or trigger ports is not supported.

You can link protected Simulink models (。slxp) to create component behaviors. You can also convert an already linked Simulink behavior model to a protected model. The change is reflected when you refresh the model.

Access Model Arguments as Parameters on Reference Components

System Composer exposes instance-specific parameter values for reusable referenced models.

Aparameter definitionis the definition of a property that has instance semantics. A parameter definition specifies attributes such as name, data type, default value, and units.

Parameter definitions can be specified as model arguments on a Simulink model or a System Composer architecture model.

Aparameteris an instance-specific value of a parameter definition. A parameter captures instance-specific values and units.

Parameters are available for each component linking to a model reference or architecture reference that specifies model arguments. You can specify independent values for a parameter on each component.

Instance-specific parameter values are visible on the component level. View and edit these values using the Property Inspector.

Left wheel parameters with the PSI parameter set to 34.

Each parameter value can be specified independently for each component that references the model.

Right wheel parameters with the PSI parameter set to 32.

For more information, seeUse Parameters to Store Instance Values with Components

Create金宝appBehavior from Template for Component

To create user-defined templates for Simulink models, seeCreate Template from Model

After creating and saving a user-defined template, you can link the template to a Simulink behavior. Right-click the component and selectCreate Simulink Behavior, or, navigate toModeling>Create Simulink Behavior

Create Simulink Behavior for a component. Create the new model from a Simulink template and a new data dictionary.

On theCreate Simulink behaviordialog, choose the template and enter a new data dictionary name if local interfaces are defined. ClickOK。雅高集团组件展品模型行为金宝appding to the template with shared interfaces, if present. Blocks and lines in the template are excluded, and only configuration settings are preserved. Configuration settings include annotations and styling.

Note that you can use architecture templates by right-clicking a component and selectingSave As Architecture Model, or navigating toModeling>Save As Architecture Model

Save component as an architecture model. Create the new model from a Simulink template and a new data dictionary.

See Also

Functions

Blocks

Related Topics