Real-Time Workshop User's Guide | ![]() ![]() |
Slower to Faster Transitions in Real Time
In models where a slower block drives a faster block, the generated code assigns the faster block a higher priority than the slower block. This means the faster block is executed before the slower block, which requires special care to avoid incorrect results.
Figure 7-9: Time Overlaps in Slower to Faster Transitions
This timing diagram illustrates two problems:
To eliminate these problems, you must insert a Unit Delay block between the slower and faster blocks. The sample rate for a Unit Delay block must be set to that of the block that is driving it (i.e., the slower block).
The picture below shows the timing sequence that results with the added Unit Delay block.
Three key points about this diagram:
The output portion of a Unit Delay block is executed at the sample rate of the slower block, but with the priority of the faster block. Since a Unit Delay block drives the faster block and has effectively the same priority, it is executed before the faster block. This solves the first problem.
The second problem is alleviated because the Unit Delay block executes at a slower rate and its output does not change during the computation of the faster block it is driving.
Note Inserting a Unit Delay block changes the model. The output of the slower block is now delayed by one time step compared to the output without a Unit Delay block. |
![]() | Slower to Faster Transitions in Simulink | Optimizing the Model for Code Generation | ![]() |