Main Content

Design Rigid Interface Specifications for Conserving Connections

You can design rigid interface specifications for conserving connections and lock down connection names and types by using Simulink.ConnectionBus and Simulink.ConnectionElement objects. Then, when you apply a rigid specification to a Simscape Bus or Connection Port block, the block ports become typed by the interface and do not accept connections to a different domain type. This functionality helps you ensure the correct connection types within your model architecture. For example, if you design a 6-pin rigid interface and apply it to two Simscape Bus blocks in your model, these blocks can be connected to each other, but not to a block with a 9-pin interface.

Before you can apply a rigid interface specification to a Simscape Bus or Connection Port block, you need to have a Simulink.ConnectionBus object in your base workspace or a data dictionary. You can construct or modify these objects:

Create Connection Bus Objects Using the Bus Editor

Before you can apply a rigid interface specification to a Simscape Bus or Connection Port block, you need to have a Simulink.ConnectionBus object in your base workspace or a data dictionary.

In this example, define a rigid interface with one mechanical translational and one electrical port by creating a ConnectionBus object named MechElec.

  1. Open the Bus Editor. At the MATLAB command prompt, enter buseditor.

    Tip

    You can also open the Bus Editor directly from a Simscape Bus or Connection Port block dialog box. Under Type Assistant, set Mode to Connection Bus object and click the Edit button.

  2. In the Bus Editor, click the Add Connection Bus button .

    A ConnectionBus object with a default name appears in the left pane and its default properties appear in the Simulink.ConnectionBus dialog pane.

  3. Specify the name for the ConnectionBus object using the Name property. In this example, name the ConnectionBus object MechElec.

    Optionally, add a description for the ConnectionBus object using the Description property.

    Bus Editor with Connection Bus properties defined

    Tip

    Click Apply after editing properties or choose to automatically apply changes when you click a different object.

  4. Click the Add/Insert ConnectionElement button .

    A connection element with a default name and default properties is created in the MechElec ConnectionBus object. The connection element appears in the left pane nested under the MechElec ConnectionBus object.

    Bus Editor with default Connection Element properties

  5. In the Simulink.ConnectionElement dialog pane, set Name to mech.

  6. Under Type Assistant, with Mode set to Connection, from the <domain name> drop-down list, select foundation.mechanical.translational.translational, which corresponds to the Foundation mechanical translational domain.

    Tip

    For a list of Foundation domain types, see Domain-Specific Line Styles.

    Optionally, add a description for the ConnectionElement object using the Description property.

    Bus Editor with Connection Element properties defined

  7. Similarly, create a ConnectionElement object named elec that corresponds to the electrical port.

    You now have a ConnectionBus object with one translational mechanical and one electrical connection port.

    Bus Editor with Connection Bus object defined

  8. Save the ConnectionBus object to a MAT-file called MechElec.

    If you do not save a ConnectionBus object, then when you reopen a model that uses that ConnectionBus object, you need to recreate the object. You save and load ConnectionBus objects similar to Simulink.Bus objects. For more information, see Determine How to Manage Simulink.Bus Objects.

Apply a Rigid Interface Specification to a Simscape Bus Block

In this example, you apply the rigid interface specification, which you created in Create Connection Bus Objects Using the Bus Editor, to a Simscape Bus block. Before starting the exercise, make sure that you have the MechElec object in your base workspace or a data dictionary.

  1. Create a new model or open an existing model containing blocks with both electrical and mechanical translational ports.

  2. Open the Simscape > Utilities block library and add a Simscape Bus block to the model diagram.

    Default Simscape Bus block appearance in model diagrams

  3. Double-click the Simscape Bus block.

    Simscape Bus block dialog with default parameters

  4. From the drop-down list under Connection type, select Bus: MechElec and click Apply. Note that the block now has two children ports, mech and elec, according to the interface definition.

    Simscape Bus block dialog with interface specification applied

    These ports appear under Hierarchy Strings in the block dialog, and the block icon changes as well to indicate that the block is a rigid bus.

    Rigid Simscape Bus block appearance in model diagrams

  5. Add a second Simscape Bus block and apply the same interface definition to it. You can do this either by repeating the previous steps or by copying the first block.

  6. Flip the second block to face the first one and connect the bus ports of the two blocks. You can connect these bus ports because the Simscape Bus blocks use the same interface definition, and therefore have identical children ports. The connection line style (double line) indicates a rigid bus connection.

    Connection line between two rigid Simscape Bus blocks

  7. You can now connect electrical and mechanical translational ports on other blocks in the model to the children ports of the Simscape Bus blocks, for example:

    Two rigid Simscape Bus blocks with other blocks connected to them

See Also

Blocks

Objects

Tools

Related Topics