Real-Time Workshop User's Guide    

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 Figure 7-8, 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 second (faster) block until the 2 second (slower) block finishes executing. The way to accomplish this is by inserting a Zero-Order Hold block between the 1 second and 2 second blocks. The sample time of the Zero Order Hold block must be set to 2 seconds (i.e., the sample time of the slower block).

The Zero Order Hold block executes at the sample rate of the slower block, but with the priority of the faster block.

This ensures that the Zero Order Hold block executes before the 1 second block (its priority is higher) and that its output value is held constant while the 2 second block executes (it executes at the slower sample rate).


 Faster to Slower Transitions in Simulink Slower to Faster Transitions in Simulink