User`s guide
Sample Rate Transitions
7-13
Simulink does not execute in real-time, which means that it is not bound by
real-time constraints. Simulink waits for, or moves ahead to, whatever tasks
are necessary to complete simulation flow. The actual time interval between
sample time steps can vary.
Faster to Slower Transitions in Real-Time
In models where a faster block drives a slower block, you must compensate for
the fact that execution of the slower block may span more than one execution
period of the faster block. This means that the outputs of the faster block may
change before the slower block has finished computing its outputs. The
following diagram illustrates a situation where this problem arises. The
hashed area indicates times when tasks are preempted by higher priority
before completion:
Figure 7-8: Time Overlaps in Faster to Slower Transitions (T=Sample Time)
In this figure, the faster block executes a second time before the slower block
has completed execution. This can cause unpredictable results because the
input data to the slow task is changing.
To avoid this situation, you must hold the outputs of the 1 sec (faster) block
until the 2 sec (slower) block finishes executing. The way to accomplish this is
by inserting a Zero-Order Hold (ZOH) block between the 1 sec and 2 sec blocks.
T=2s
T=1s
Time
1Sec
Task
2Sec
1
The faster task (T=1s) completes.
Faster Slower
BlockBlock
T=1sec T=2sec
T=1s T=1s T=1s
T=2s
Task
1
2 3
1
32
2
3
Higher priority preemption occurs.
The slower task (T=2s) resumes and its inputs
have changed. This leads to unpredictable results.