DSP Blockset | ![]() ![]() |
Example: Nonzero Tasking Latency. Most multirate blocks experience tasking latency only in the Simulink multitasking mode. As an example, consider the following model.
To engage the Simulink multitasking mode, adjust the following settings in the Solver panel of the Simulation Parameters dialog box:
Use the default settings for the Mux and To Workspace blocks. Adjust the other blocks' parameter settings as follows:
4
0
-1
0.25
to match the sample period of the Upsample block's output.
Notice that the current value of the Simulink timer (from the Digital Clock block) is prepended to each output frame. The frame-based signal is converted to a sample-based signal by the Frame Status Conversion block so that the output in the command window will be easily readable.
In the example, the Signal From Workspace block generates a new frame containing four samples once every second (Tfo = *4). The first few output frames are shown below:
The Upsample block upsamples the input by a factor of 4, inserting three zeros between each input sample. The change in rates is confirmed by the Probe blocks in the model, which show a decrease in the frame period from Tfi = 1 to Tfo = 0.25.
Question: When does the first input sample appear in the output?
The "Latency and Initial Conditions" section of the reference page for the Upsample block indicates that when Simulink is in multitasking mode, the first sample of the block's frame-based input appears in the output as sample MiL+D+1, where Mi is the input frame size, L is the Upsample factor, and D is the Sample offset. This formula therefore predicts that the first input in this example should appear as output sample 17 (i.e., 4*4+0+1).
To verify this, look at the output from the simulation, saved in the workspace array yout
. To convert the array to a easier-to-read matrix format, type
The first few samples of the result, ans
, are shown below:
The first column of yout
is the Simulink time provided by the Digital Clock block. The four values to the right of each time are the values in the output frame at that time. You can see that the first sample in each of the first four output frames inherits the value of the block's Initial conditions parameter. As a result of the tasking latency, the first input value appears only as the first sample of the 5th output frame (at t=1), which is sample 17.
![]() | Predicting Tasking Latency | Example: Zero Tasking Latency | ![]() |