Main Content

Create Interfaces

You can create interfaces between components in System Composer™ to structure transmitted data. Use composite data interfaces with data elements or value types to manage data defined on ports. Assign a data interface or value type to a data element so the data element inherits attributes and reuses data. Use the model below as a starting point before adding interfaces using the Interface Editor.

For interfaces terminology, see Define Port Interfaces Between Components.

To manage interfaces shared between models in data dictionaries, see Manage Interfaces with Data Dictionaries.

Mobile Robot Architecture Model

This example shows a mobile robot platform architecture.

Open the Interface Editor

To open the Interface Editor, navigate to Modeling > Design > Interface Editor. The Interface Editor will open at the bottom of the canvas.

Example mobile robot architecture model with the Interface Editor indicated in red.

Note

The System Composer Interface Editor is a web-based widget and might appear blank when you first launch it. If this occurs, save the model and relaunch MATLAB® with the command line option -cefdisablegpu.

Create Composite Data Interfaces

To add a new data interface definition, click the add data interface icon. Name the data interface sensordata.

Interface editor showing one defined interface named 'sensor data'.

To add a data element to the data interface, click the add data element icon. Data interface and data element names must be valid MATLAB variable names.

Interface elements named 'coordinates' and 'motor speed' shown below an interface named 'sensor data'.

You can delete data interfaces and data elements in the Interface Editor using the delete button.

You can view and edit the properties of an element in the Property Inspector. Right-click the data element and select Inspect Properties. For data interfaces, use the Property Inspector to apply stereotypes.

Properties for the interface element named 'motor speed' in the property inspector showing. Properties include Type as double, Dimensions as 1, Units as blank, Complexity as real, Minimum, which is empty, Maximum, which is empty, and Description, which is blank.

For a comparative view, you can edit data element properties from the relevant Interface Editor columns.

Units being edited for the property under the motor speed interface element.

Create Value Types as Interfaces

To add a value type in the Interface Editor, select the down arrow next to the add data interface icon and select Value Type. Name the value type motorSpeedType. Value type names must be valid MATLAB variable names.

Add value type option in Interface Editor.

Right-click the motorSpeed data element and select Set 'Type' > motorSpeedType. The data element motorSpeed is assigned to the value type motorSpeedType.

Type motor speed by the value type motor speed type in the Interface Editor.

Any data changes on the motorSpeedType value type is propagated to the motorSpeed data element. You can reuse value types any number of times. Data changes on a value type will propagate to each data element that uses the value type.

Nest Interfaces to Reuse Data

A nested interface contains another data interface. Create a nested data interface by assigning a data interface as the type of a data element. For information about the corresponding buses, see Nest Bus Objects Using the Bus Editor.

For example, let coordinates be a data interface that consists of x, y, and z coordinates. The GPSdata data interface includes location and a timestamp. If the location data element is in the same format as the coordinates interface, you can set its type to coordinates. Right-click location and select Set 'Type' > coordinates. The available interface options include all value types and all data interfaces in the model, except the parent of the data element.

Interface editor with three interfaces named 'sensor data', 'coordinates' and 'GPS data'. Below each are interface elements with properties defined. The 'location' interface element under the interface named 'GPS data' has been right-clicked. The user is selecting the option 'Set type' to choose the interface named 'coordinates'.

The nested data interface displays the inherited data elements.

The coordinates interface is nested into the location interface element under GPS data. All coordinates interface elements show below location.

Note

To change the number of columns that display in the Interface Editor, click the show hide columns icon. Select or clear the desired columns to show or hide them.

The Interface Editor view with the drop down next to the show hide columns icon is selected. The columns Type, Dimensions, and Units are selected.

See Also

Functions

Blocks

Related Topics