Main Content

Simplify Subsystem and Model Interfaces with Bus Element Ports

Buses simplify subsystem and model interfaces by letting you associate multiple signals or messages with one port. They reduce line complexity and clutter in a block diagram, make it easier to change the interface incrementally, and allow access to elements closer to their point of usage.

For an overview of how to use buses to simplify composite interfaces, see Reduced Bus Wiring: Bus Element Ports (2 min, 7 sec).

For example, this model contains subsystems where each subsystem interface has multiple ports.

Each subsystem has multiple input and output ports.

This equivalent model uses buses and has one port per subsystem interface.

Each subsystem has one input port and one output port.

For buses at interfaces, use In Bus Element and Out Bus Element blocks instead of Inport and Bus Selector blocks for inputs and Outport and Bus Creator blocks for outputs. In Bus Element and Out Bus Element blocks support multirate virtual buses and do not require Simulink.Bus objects at model interfaces, unlike Inport and Outport blocks. They also provide cleaner bus interfaces.

For example, this model uses Inport, Bus Selector, Bus Creator, and Outport blocks.

Bus Selector and Bus Creator blocks modify the input bus.

This equivalent model uses In Bus Element and Out Bus Element blocks.

In Bus Element and Out Bus Element blocks make the block diagram easier to parse.

At the interface you want to update, the lines and blocks must not have nondefault specifications that could cause conflicts. For example, the line between a Bus Creator block and an Outport block must not be named or marked for signal logging. Similarly, while you can specify a Simulink.Bus object data type for an output port, you must not specify a nondefault data type for an element of the output port, such as TopBus1.NestedBus1.

The following examples demonstrate how to update interfaces to use In Bus Element and Out Bus Element blocks. The example models are simple, however, buses are most useful when you have many elements to combine.

Combine Multiple Subsystem Ports into One Port

This example shows three ways to simplify a subsystem interface by converting multiple ports and their connected signals into one port and a bus. Model interfaces do not support this automated conversion.

Open the example model, which contains two subsystems with multiple input and output ports.

Drag a selection box around the signal lines between the two subsystems. From the action bar that appears, click Create Bus.

Simulink replaces the Inport and Outport blocks in the source and destination subsystems with In Bus Element and Out Bus Element blocks.

Drag a selection box around the signal lines between the source blocks and first subsystem. From the action bar that appears, click Create Bus.

Simulink adds a Bus Creator block before the first subsystem and replaces the Inport blocks in the first subsystem with In Bus Element blocks.

Drag a selection box around the signal lines between the second subsystem and Scope blocks. From the action bar that appears, click Create Bus.

Simulink replaces the Outport blocks in the second subsystem with Out Bus Element blocks and adds a Bus Selector block after the second subsystem.

The resulting model uses virtual buses at the subsystem interfaces.

Simplify Bus Interfaces in Subsystems and Models

This example shows how to convert a subsystem or model interface that uses Inport, Bus Selector, Bus Creator, and Outport blocks to use In Bus Element and Out Bus Element blocks.

Open the example model, which contains a subsystem that modifies an input bus hierarchy using Bus Selector and Bus Creator blocks. The subsystem uses Inport and Outport blocks for input and output.

Compile the model to update line styles, which you can use to visually identify buses. In the Simulink Toolstrip, on the Modeling tab, click Update Model or Run.

Open the subsystem.

To convert Inport and Bus Selector blocks to In Bus Element blocks:

  1. Click a Bus Selector block that directly connects to an Inport block.

  2. In the action bar that appears when you pause over the ellipsis, click Bus Ports.

You can similarly convert an In Bus Element and Bus Selector block.

To convert Outport and Bus Creator blocks to Out Bus Element blocks:

  1. Click a Bus Creator block that directly connects to an Outport block without branching.

  2. In the action bar that appears when you pause over the ellipsis, click Bus Ports.

You can similarly convert Out Bus Element and Bus Creator blocks.

The resulting model simplifies line routing, makes it easier to incrementally change the interface, and lets you access elements closer to their point of usage.

You can change the name of a bus and its elements by double-clicking the block labels and editing them.

To easily identify elements of the same nested bus or bus port, specify block colors.

  1. Double-click an In Bus Element or Out Bus Element block to open the dialog box for the related port.

  2. Select an element or the top bus.

  3. Specify the background color with the Set color dropdown menu.

See Also

|

Related Topics