Main Content

Create an Architecture Model

In this example, create an architecture model of a mobile robot that consists of sensors, motion, and a planning algorithm. Define the interfaces and link the requirements.

Visually Represent the System

Capture the construction of a robot arm using System Composer™. The robot arm consists of the components shown in this preliminary sketch.

Diagram with arrow from the left pointing toward trajectory planning called target position, and a cycle of trajectory planning, sensors, and motion within.

Create Architecture Model

  1. In the MATLAB® Command Window, type


    The Simulink® Start Page opens to System Composer.

    Accessing a new System Composer architecture model from the Simulink start page.

  2. Click Architecture Model.

    A composition editor window opens with a new architecture model. You can identify an architecture model by the badge in the lower left corner and the component palette on the left side.

    A new untitled architecture model in System Composer.

  3. Double-click the architecture model header and change untitled to Robot. The name of the model generally reflects the system whose architecture you are building.

    Renamed architecture model called 'Robot'.

  4. Save the model.

Draw Components

  1. Click and drag a Component from the left-side palette.

    Click and drag a component from the left-side palette to add it to the architecture model.

  2. Rename the component to Sensors.

  3. Add Trajectory Planning and Motion components.

    An architecture model called 'Robot' with three components

Create Ports and Connections

You can add a port to a component on any side and the port can have either an input or output direction. To create a port, pause the mouse cursor over a component side. Click and release the mouse button to view direction options. Select either the right arrow or the left arrow to select the direction. Rename the port using a name that is representative of the information that flows through that port.

  1. Create an output port on the bottom side of the Sensors component. Rename it SensorData.

    'Robot' architecture model with a downward facing output port below the 'Sensors' component called 'Sensor Data'.

  2. Click and drag a line from the SensorData output port to the Motion component. When you see an input port created at the component side, release the mouse button. By default, this new port has the same name as the source port.

  3. Hover on the corner of the SensorData line until you see the branch icon.. Right-click and drag a branch line to the Trajectory Planning component.

    'Robot' architecture model with a 'Sensor Data' connection out-port from the 'Sensors' component connected to two in-ports into the 'Trajectory Planning' and 'Motion' components.

  4. Complete connections as shown in the following figure.

    To the 'Robot' architecture model, add a 'Motion Command' connection from the 'Trajectory Planning' component to the 'Motion' component, and an 'Encoder' connection from the 'Motion' component to the 'Sensors' component.

The root level of the architecture model can also have ports that describe the interaction of the system with its environment. In this example, the target position for the robot is provided by a computer external to the robot itself. Represent this relationship with an input port.

  1. Click the left edge of the architecture model and type the port name TargetPosition.

  2. Connect an architecture port to a component by dragging a line from the TargetPosition input port to the Trajectory Planning component. Connections to or from an architecture port appear as tags.

    Final 'Robot' model has an architecture port connected from the 'Trajectory Planning' component to the 'Target Position' input port.

Edit Interfaces

Specify the data flow between components by configuring the data interface with data types, units, dimensions, and other attributes. An interface can be as simple as sending an integer value, but it can also be a set of numbers, an enumeration, a combination of numbers and strings, or a bundle of other predefined interfaces.

Consider the interface between the Sensors and the Motion components. The sensor data consists of:

  • Position data from two motors

  • Obstacle proximity data from two sensors

  • A time stamp to capture the freshness of the data

The data has these specifications.

NameData TypeUnit
position1 for motor 1doubledegrees
position2 for motor 2doubledegrees
distance1 for sensor 1doublemeters
direction1 for sensor 1doubledegrees
distance2 for sensor 2doublemeters
direction2 sensor 2doubledegrees
  1. In the Modeling tab, select Interface Editor.

  2. Click the button to add an interface and name it sensordata.

    The interface is named and defined separately from a component port and then assigned to a port.

  3. Click the SensorData output port on the Sensors component. In the Interface Editor, right-click sensordata and select Assign to Selected Port(s).

    If you click sensordata again, the three SensorData ports are highlighted, indicating the ports are associated with that interface.

    Model with three 'Sensor Data' ports highlighted in purple.

  4. Add an element to the selected interface. Click the add interface element button to add an element and name it timestamp.

  5. Continue adding elements to the interface as specified by clicking the add element button.

  6. Edit the properties of an interface element using the Property Inspector. Right-click an any element and select Inspect Properties. The Property Inspector opens above the Interface Editor.

    Click each interface element and add units as shown in the specification. Click the drop-down next to the button to save the interface to a data dictionary. A data dictionary allows you to collectively manage and share a set of interfaces among interrelated models. For instance, later in the design, if you choose to model the external computer as a separate architecture model, then this model and the Robot model can share the same data dictionary. Here it is saved as RobotDD.

    The RobotDD dictionary with interface named 'sensor data' and interface elements named 'time stamp', 'direction 1', direction 2', distance 1', distance 2', 'position 1', and 'position 2.

Decompose Components

Each component can have its own architecture. Double-click a component to decompose it into its subcomponents.

  1. Double-click the Trajectory Planning component. The title or Model Browser indicates the position of the component in the model hierarchy.

    The inside of the 'Trajectory Planning' component shows three architecture ports called 'Target Position, 'Sensor Data', and 'Motion Command'.

    This component first uses the motor position data that is part of the sensordata interface to compute the ideal position and velocity command. It then processes the obstacle distance information in the same interface to condition this motion command, according to some safety rules.

  2. Add Motion Control and Safety Rules components as part of the Trajectory Planning architecture.

    Drag the TargetPosition port to the Motion Control component. Add a Command output port to Motion Control, and then drag a line to the Safety Rules component. Drag lines from SensorData port to Motion Control and Safety Rules components.

    Port connections for the 'Trajectory Planning' component.

Implement Component Behavior

If you have a component that represents a single functional unit that does not need further architectural decomposition, you can define either its intended or detailed behavior model in Simulink.

  1. Right-click the Motion Control component and select Create Simulink Behavior.

  2. Type the name for a new Simulink model. Select either a blank Simulink template (default) or a template that you created and click OK. For more information about creating your own Simulink templates, see Create Template from Model.

    'Create Simulink behavior' dialog with new model name specified as 'Motion Controller' from a Default Simulnk template and data dictionary RobotDD.

    This creates a new Simulink model in the current directory, converts the component to a reference component (one that refers to another model stored as a separate artifact), and adds a Simulink model badge with the name of the referenced model on the component. The Simulink behavior model is preconfigured with the ports from the component in the architecture model. You can now use Simulink to elaborate the behavior model of the Motion Control.

    Simulink icon in the top right of the 'Motion Control' component specifying a Simulink behavior inside.

  3. Double-click Motion Control. Add a Sum block to subtract SensorData from TargetPosition, and add a Gain block before connecting to the output Command to represent a simple proportional controller.

    A Simulink model inside the 'Motion Control' component.

Link to an Existing Simulink Behavior Model

You can also link to an existing Simulink behavior model from a System Composer component if one is already available from a previous design.

  1. Right-click the component and select Link to Model.

  2. Enter the name of a Simulink model.

    Link to model dialog with existing Simulink model called 'Data Processing'.

Any subcomponents and ports that are present in the component are deleted when the component links to a Simulink model. The component then is created with ports that are the same as those described in the Simulink model.

See Also



Related Topics