| SimEvents | ![]() |
www.kxcad.net Home > CAE Software Index > MATLAB Index >
| On this page… |
|---|
For discrete event subsystems that respond to entity departures rather than signal-based events, see Creating Entity-Departure Subsystems.
Building on the conceptual information in Role of Discrete Event Subsystems in SimEvents Models, this section provides some practical information to help you incorporate Discrete Event Subsystem blocks into your SimEvents models.
To create discrete event subsystems that respond to signal-based events, follow the procedure below using blocks in the SimEvents Ports and Subsystems library.
Note You cannot create a signal-based discrete event subsystem by selecting blocks and using Edit > Create Subsystem or by converting a time-based subsystem into a discrete event subsystem. If your model already contains the blocks you want to put into a discrete event subsystem, then you can copy them into the subsystem window of a Discrete Event Subsystem block while following the procedure below. |
Drag the Discrete Event Subsystem block from the SimEvents Ports and Subsystems library into your model. Initially, it shows one signal input port Din and one signal output port Dout. Note that these are signal ports, not entity ports, because the subsystem is designed to process signals rather than entities. Furthermore, the signal input ports carry only real scalar signals of data type double.

In the model window, double-click the Discrete Event Subsystem block to open the subsystem it represents. Initially, the subsystem contains an inport block connected to an outport block. Note that these are Discrete Event Inport and Discrete Event Outport blocks, which are not the same as the Inport and Outport blocks in the Simulink Ports & Subsystems library. The subsystem also contains a Subsystem Configuration block, which you should not delete.

A discrete event subsystem must have at least one input that determines when the subsystem executes. To change the number of inputs or outputs to the subsystem, change the number of inport and outport blocks in the subsystem window:
If your subsystem requires an additional input or output, then copy and paste an inport block or outport block in the subsystem window. (Copying and pasting is different from duplicating the inport block, which is not supported.) The figure below shows a pasted inport block.

As a result, the subsystem block at the upper level of your model shows the additional port as appropriate. The figure below shows an additional input port on the subsystem block.

If your subsystem needs no outputs, then select and delete the outport block in the subsystem window. The figure below shows the absence of outport blocks.

As a result, the subsystem block at the upper level of your model omits the output port. The figure below shows the absence of output ports on the subsystem block.

Drag other blocks into the subsystem window as appropriate to build the subsystem. This step is similar to the process of building the top level of your model, except that only certain types of blocks are suitable for use inside the subsystem. See Blocks Inside Discrete Event Subsystems for details.
Configure each of the Discrete Event Inport blocks to indicate when the subsystem should be executed. Each inport block independently determines criteria for executing the subsystem:
To execute the subsystem when the signal corresponding to that inport block exhibits a qualifying signal-based event, select Execute subsystem upon signal-based events and use additional parameters in the dialog box to describe the signal-based event.
To have the subsystem use the most recent value of the signal corresponding to that inport block without responding to signal-based events in that signal, clear the Execute subsystem upon signal-based events option.

Blocks in a Discrete Event Subsystem are called in response to signal-based events. Using the dialog box of the Discrete Event Inport blocks inside the subsystem, you configure the subsystem so that it is executed in response to
An updated value in an input signal, even if the updated value is the same as the previous value
A change in the value of an input signal
A rising edge or falling edge in an input signal known as a trigger signal
Note To call a subsystem upon an entity departure or upon a function call, see Creating Entity-Departure Subsystems or Using Function-Call Subsystems, respectively. |
In a discrete event subsystem containing multiple Discrete Event Inport blocks, the subsystem is executed when at least one of the inport blocks detects a qualifying event. If N qualifying events occur at the same simulation time (whether at the same or different Discrete Event Inport blocks), then the subsystem executes N times and updates its output signals N times.
If you want one of the inport blocks to provide an input signal without affecting the times at which the subsystem is executed, then clear the Execute subsystem upon signal-based event check box on that inport block. However, always select Execute subsystem upon signal-based event for at least one inport block of the subsystem or else the subsystem will never be executed.
Here are some points to keep in mind when deciding which type of signal-based event should call your discrete event subsystem:
Value changes are similar to sample time hits, except that a sample time hit might cause a signal to be updated with the same value. If you expect that calling the subsystem for repeated values of an input signal would produce incorrect numerical results or would be wasteful, then execute the subsystem upon changes in the signal value rather than upon every sample time hit.
The Discrete Event Subsystem block is similar to the ordinary Triggered Subsystem block in the Simulink Ports & Subsystems library. However, the Discrete Event Subsystem block can detect zero-duration values in the input signal, which are signal values that do not persist for a positive duration. (See Working with Multivalued Signals for details on zero-duration values.) Unlike the Triggered Subsystem block, the Discrete Event Subsystem block can detect and respond to a trigger edge formed by a zero-duration value, as well as multiple edges in a single instant of time.
For more information about signal-based events, see Types of Supported Events.
| Blocks Inside Discrete Event Subsystems | Examples Using Discrete Event Subsystem Blocks | ![]() |
© 1984-2007 The MathWorks, Inc. Terms of Use Patents Trademarks Acknowledgments