mdlref_bus.mdl | Open this Model |
Model Reference and Bus Signal Demonstration
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.)
During this demonstration, Simulink and Real-Time Workshop generate code in a Simulink project directory created in the current working directory. If you do not want to (or if you cannot) generate files in this directory, you should change the working directory to a suitable directory.
Real-Time Workshop is required to generate Model Reference RTW target to be deployed in standalone applications.
If you plan to alter the demonstration models:
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:
Change your current working directory to the directory to which you copied the files.
Continue with the demonstration.
If you haven't already opened it, open the demo model mdlref_bus.
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.
mdlref_bus
.