Why is it not advisable to specify an inherited sample time for a source block?

2 views (last 30 days)
The Simulink documentation states the following:
Specifying sample-time inheritance for a source block can cause Simulink to assign an inappropriate sample time to the block if the source drives more than one block. For this reason, you should avoid specifying sample-time inheritance for source blocks.
Is there an example that illustrates potential pitfalls of specifying an inherited sample time for a source block?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The attached example illustrates one of the potential dangers of specifying an inherited sample time for a source block.
Note that the attached model example was built with Simulink 6.3 (R14SP3).
The example has a "Sine Wave 1" source block connected to two different blocks. The sample time of the "Sine Wave 1" block is set as -1 (inherited). The "Discrete Time Integrator" block has a sample time of 1. This causes the "Sine" block to also have a sample time of 1. The "Sine Wave 1" block is also connected to the "Compare to Constant" block that enables a subsystem if the input signal exceeds 0.1.
The expectation is that when the sine wave exceeds a value of 0.1, the subsystem should be enabled. Since the sine wave has a frequency of 1 rad/sec, one would expect that the "Enabled Subsystem 1" block to be enabled when sin(t) = 0.1. However, because the "Sine Wave 1" block has inherited a sample time of 1 sec from the "Discrete Time Integrator" block, its output updates only at 1 sec intervals. This implies that the output of the "Sine Wave 1" block exceeds 0.1 only at 1 sec (at 0 sec output is 0 and at 1 sec output jumps to sin(1) ). If you open "Scope" you will observe that the output jumps to 1 at only 1 sec. To make things worse, changing the sample time of the "Discrete Time Integrator" block changes the time at which the "Enabled Subsystem 1" is enabled. In a complex model, such situations could affect simulation results in unintended ways that might not be easily detectable.
In the same model there is another sine block called "Sine Wave 2" that only connects to a "Compare to Constant" block which enables a subsystem if the input signal exceeds 0.1 . In this case the sample time of the "Sine" block has been specified as 0 (continuous). In this case you will observe that the subsystem is enabled at 0.1 sec. If you look at "Scope1", you will see that the output of the subsystem jumps to 1 at 0.1 sec.
In the above example, had the sample time of the "Sine Wave1" block been specified as 0 (instead of inherited), we would get consistent results at the outputs of both the "Discrete Time Integrator" block and the "Enabled Subsystem" blocks irrespective of what the sample time of the "Discrete Time Integrator" block is.

More Answers (0)

Categories

Find more on Schedule Model Components in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!