Main Content

Interface Adapter

A source port and its destination port may be defined by different data interfaces. Such a connection can represent an intermediate point in design, where components from different sources come together. To connect components with different data interfaces, use an Adapter block and the Interface Adapter dialog. For interfaces terminology, see Define Port Interfaces Between Components.

An adapter helps connect two components with incompatible port interfaces by mapping between the two interfaces. Use the Adapter block to implement an adapter. Open the Interface Adapter by double-clicking an Adapter block on the connection between the ports.

Use the Interface Adapter in System Composer™ to map interface elements between two ports. You can also use the Interface Adapter to apply an interface conversion that breaks algebraic loops with unit delays, inserts a rate transition for different sample time rates, or merges two or more message or signal lines. When output interfaces are undefined, you can use input interfaces in bus creation mode of the Interface Adapter to author owned output interfaces.

systemcomposer.openModel("exMobileRobotInterfaces");

Map Incompatible Interfaces

When two connected components with Simulink® behaviors have incompatible interfaces, use an Adapter block and the Interface Adapter to define the port connections.

  1. Add an Adapter block on the connection between the two components.

  2. Double-click the block to open the Interface Adapter dialog box.

  3. In the Select input box, select a data element. In the Select output box, select a data element.

  4. Click the Map and Overwrite button.

2021-10-31_14-43-56.png

You can use an Adapter block to map similar interfaces for an N:1 connection, which is an Adapter with more than one input port and a single output port. A data element from each input connection maps to the output connection data elements.

Change the number of input ports on an Adapter block in the same way you add and remove component ports. For more information, see Compose Architectures Visually.

2021-10-31_14-50-58.png

Use Unit Delay to Break Algebraic Loop

When connecting two components with port connections in both directions, an algebraic loop can occur. To break the algebraic loop, use an Adapter block to insert a unit delay between the components.

  1. Add an Adapter block on the connection between the two components.

  2. Double-click the block to open the Interface Adapter dialog box.

  3. From the Apply interface conversion list, select UnitDelay.

Use Rate Transition Between Simulink Behaviors

When connecting two reference components, the Simulink models the components reference can have different sample time rates. For compatibility, use an Adapter block to insert a rate transition between the components.

  1. Add an Adapter block on the connection between the two components.

  2. Double-click the block to open the Interface Adapter dialog box.

  3. From the Apply interface conversion list, select RateTransition.

Use Adapter Block as Merge Block

Use an Adapter block as a Merge block to merge multiple message lines for system architecture models or merge multiple signal and message lines for software architecture models.

  1. Add an Adapter block on the connection between the two components.

  2. Double-click the block to open the Interface Adapter dialog box.

  3. From the Apply interface conversion list, select Merge.

Use Bus Creation Mode to Author Owned Interfaces

When input ports for an Adapter block are typed by interfaces from incoming connections and no interfaces are defined on the output ports of the Adapter, you can use these interface elements to author owned interfaces for outgoing connections. Instead of pre-defining interface structures, you can create the bus structure.

systemcomposer.openModel("SewingMachine");

1. Double-click the Adapter block to open the Interface Adapter dialog in bus creation mode.

2. Click the button-add-element.png button to add the input data element Torque to the output port interface for the port named Signal.

bus-creation-mode-interface-adapter.png

3. Click the button-remove-element.png button to remove the output data element Displacement from the output port interface for the port named Signal.

bus-creation-mode-interface-adapter-remove.png

4. Click OK to apply the changes.

2022-04-12_9-05-21.png

The owned interface on the output port of the Adapter block propagates to the connected input port Signal on the Controller component. The owned interface contains one element, Torque.

To convert an owned interface into a shared interface, right-click the port with the owned interface and select Convert to shared interface.

See Also

Blocks

Related Topics