Connecting Buses to Inports and Outports

Connecting Buses to Root Level Inports

If you want a root level Inport of a model to produce a bus signal, you must select the Inport's Specify properties via bus object parameter and set the Inport's Bus object for validating input bus parameter to the name of a bus object that defines the bus that the Inport produces. If the bus contains mixed data types, the Inport's data type must be auto. See Using Bus Objects for more information.

Connecting Buses to Root Level Outports

A root level Outport of a model can accept a virtual bus only if all elements of the bus have the same data type. The Outport block automatically unifies the bus to a vector having the same number of elements as the bus, and outputs that vector.

If you want a root level Outport of a model to accept a bus signal that contains mixed types, you must select the Outport's Specify properties via bus object parameter and set the Outport's Bus object for validating input bus parameter to the name of a bus object that defines the type of bus that the Outport produces. If the bus signal is virtual, it will be converted to nonvirtual, as described in Automatic Bus Conversion. See Using Bus Objects more information.

An Outport in a conditionally executed subsystem that is connected to a bus that contains mixed data types cannot be configured to reset and have initial values specified.

Connecting Buses to Nonvirtual Inports

By default, an Inport block is a virtual block and accepts a bus as input. However, an Inport block is nonvirtual if it resides in a conditionally executed or atomic subsystem, or a referenced model, and it or any of its components is directly connected to an output of the subsystem or model. In such a case, the Inport block can accept a bus only if all elements of the bus have the same data type.

If the components are of differing data types, attempting to simulate the model causes the Simulink software to halt the simulation and display an error message. You can avoid this problem, without changing the semantics of your model, by inserting a Signal Conversion block between the Inport block and the Outport block to which it was originally connected.

For example, consider the following model:

In this model, the Inport labeled nonvirtual is nonvirtual because it resides in an atomic subsystem and one of its components (labeled a) is directly connected to one of the subsystem's outputs. Further, the bus connected to the subsystem's inputs has components of differing data types. As a result, this model cannot be simulated.

Inserting a Signal Conversion block with the bus copyoption selected breaks the direct connection to the subsystem's output and thereby enables the Simulink software to simulate the model.

Connecting Buses to Model, Stateflow, and Embedded MATLAB Blocks

Referenced models, Stateflow charts, and Embedded MATLAB blocks require any bus connected to them to be nonvirtual. To provide for this requirement, where possible the Simulink software automatically converts any virtual bus connected to a Model block or Stateflow chart to a nonvirtual bus. See Automatic Bus Conversion for details.

Connecting Multi-Rate Buses to Referenced Models

In a model that uses a fixed-rate solver, referenced models can input only single-rate buses. However, you can input the signals in a multi-rate bus to a referenced model by inserting blocks into the parent and referenced model as follows:

  1. In the parent model: Insert a Rate Transition block to convert the multi-rate bus to a single-rate bus. The Rate Transition block must specify a rate in its Block Parameters > Output port sample time field unless one of the following is true:

  2. In the referenced model: Use a Bus Selector block to pick out signals of interest, and use Rate Transition blocks to convert the signals to the desired rates.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS