Why does my Discrete Events Subsystem update at an incorrect rate when I have a Mux or Bus input in SimEvents 3.0 (R2009b)?

1 view (last 30 days)
I have a model with a discrete events subsystem that is designed to update upon a "Sample Time Hit" . The model updates correctly if I pass it a single signal, but updates at a different rate when I pass it a muxed or bus signal. I have attached a model that illustrates this behavior. Is this an expected behavior?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 11 Nov 2009
This is expected behavior for a discrete event subsystem with mux or bus inputs in SimEvents 3.0 (R2009b).
In SimEvents, it is probable that the inputs to your discrete events subsystem are coming from another SimEvents block and are event-based signals. You can mux (or bus) these signals together. Event-based signals don't have a sample time and they update asynchronously during the simulation.
It is completely acceptable to mux two event-based signals to create a virtual signal of width any width. A mux signal still retains the individual properties of its components. Hence the components of the mux can still fire asynchronously and are still event-based.
However, when this behavior changes when virtual mux signal feeds into a discrete-event subsystem , which is very similar to an Atomic Subsystem. The contents of a discrete-event subsystem always execute as a unit, and hence you can think of this subsystem as atomic in the "SimEvents sense". Feeding a virtual mux signal to the Inport block of such an atomic subsystem converts that signal to a non-virtual signal. For further information see the link below.
web([docroot '/toolbox/simulink/ug/bq4jy05-1.html'])
In effect, the discrete event subsystem creates a new signal by copying over the constituent signals. Thus, inside the subsystem, we have a new non-virtual signal of width 2. This new signal cannot possibly be an event-based signal because its components can no longer update asynchronously. Both elements must now update together, and hence it becomes a time-based signal. Every time-based signal has a sample-time. The Simulink engine assigns this new time-based signal with the default sample time of 0.2. In the attached model it updates 5 times every second or 5 times the rate of the truly discrete signals. By feeding a virtual mux'ed signal into a discrete-event subsystem, the components of the signal have lost their event-based nature.
A similar argument applies for Bus Signals. You may use a Bus Selector block to select one of the two bus elements, the result would continue to be an event-based signal. However, by feeding this virtual bus to a discrete-event subsystem, this converts it to a non-virtual bus, which is a time-based signal because its components can no longer update asynchronously. Hence it is assigned the default sample time of 0.2.
If you wish to have a discrete events subsystem execute at a rate different than the time-based signals inside of it, you can do so with a triggered subsystem as noted by the "workaround" in the attached model.

More Answers (0)

Categories

Find more on Interface with Simulink in Help Center and File Exchange

Products


Release

R2009b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!