mdlref_bus.mdl Open this Model

Model Reference and Bus Signal Demonstration

Introduction

This demonstration explains how to propagate bus signals into referenced models. (For a quick introduction to Model Reference, run the Basic Model Reference Demo and for a quick introduction to bus signals, run the Bus Signal Demo.)

Demo Requirements

If you plan to alter the demonstration models:

  1. Preserve the demo in its original state by copying the following files in your MATLAB installation directory without changing their names to a different directory:

  2. Change your current working directory to the directory to which you copied the files.

  3. Continue with the demonstration.

If you haven't already opened it, open the demo model mdlref_bus.

Description of Bus Signal Setup for the Demonstration

This model contains a Model block, CounterA, that references mdlref_counter_bus, a model of a simple counter. A bus signal called COUNTERBUS feeds the input signal and the saturation limits of the counter into the model. The COUNTERBUS contains two more bus signals, the LIMITBUS and the SIGNALBUS. LIMITBUS contains the upper and lower limit values of the counter and SIGNALBUS contains the signal used in counting. The following shows the structure of COUNTERBUS:

The demo also includes a MAT-file named mdlref_counter_bus.mat that creates type objects that define the elements of COUNTERBUS, SIGNALBUS, and LIMITBUS. The mdlref_bus model's preload function loads this MAT-file when the model is loaded, causing the bus type objects to be created in the MATLAB workspace.

Note: You can view these objects by selecting the MATLAB workspace in the Model Explorer. You can also view the bus structures in the Bus Types Editor.

The model uses these bus type objects to specify the outputs of the following Bus Creator Blocks:

The Inport of the referenced model mdlref_counter_bus specifies the COUNTERBUS bus type object in its Bus object for validating input bus field and enables the Specify Properties via bus object option in the Signal Specification page of the parameter dialog, thereby configuring the port to accept buses of the COUNTERBUS type.

Now you can simulate mdlref_bus to see the output.

Code Generation For Standalone Applications(Requires Real-Time Workshop)

Create the executable and inspect the code for mdlref_bus.

Exit

Close mdlref_counter_bus and mdlref_bus.