|On this page…|
If you want a root level Inport of a model to produce a bus signal, in the Inport block parameters dialog box, set Data type to Bus: <object name> and replace <object name> with the name of the bus object name that defines the bus that the Inport produces. See Bus Objects for more information.
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, in the Outport block parameters dialog box, set Data type to Bus: <object name> and replace <object name> with the name of the bus object name that defines the bus that the Inport produces. If the bus signal is virtual, it will be converted to nonvirtual, as described in Automatic Bus Conversion. See Bus Objects more information.
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, the following model, which includes an atomic subsystem, does not simulate.
Starting the simulation generates the following error messages:
Opening the subsystem reveals that in this model, the Inport block 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 (bus1) connected to the subsystem's inputs has components of differing data types. As a result, you cannot simulate this model.
To break the direct connection to the subsystem's output, insert a Signal Conversion block. Set the Signal Conversion block Output parameter to Signal copy. Inserting the Signal Conversion block enables the Simulink software to simulate the model.
Referenced models, Stateflow® charts, and MATLAB Function 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.
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:
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:
The Configuration Parameters > Solver pane specifies a rate:
Periodic sample time constraint is Specified
Sample time properties contains the specified rate.
The Inport that accepts the bus in the referenced model specifies a rate in its Block Properties > Signal Attributes > Sample time field.