Real-Time Workshop    

Data Logging In Singletasking
and Multitasking Model Execution

The Real-Time Workshop data-logging features, described in Workspace I/O Options and Data Logging, enable you to save system states, outputs, and time to a MAT-file at the completion of the model execution. The LogTXY function, which performs data logging, operates differently in singletasking and multitasking environments.

If you examine how LogTXY is called in the singletasking and multitasking environments, you will notice that for singletasking LogTXY is called after ModelOutputs. During this ModelOutputs call, all blocks that have a hit at time t are executed, whereas in multitasking, LogTXY is called after ModelOutputs(tid=0) that executes only the blocks that have a hit at time t and that have a task identifier of 0. This results in differences in the logged values between singletasking and multitasking logging. Specifically, consider a model with two sample times, the faster sample time having a period of 1.0 second and the slower sample time having a period of 10.0 seconds. At time t = k*10, k=0,1,2... both the fast (tid=0) and slow (tid=1) blocks have a hit. When executing in multitasking mode, when LogTXY is called, the slow blocks will have a hit, but the previous value will be logged, whereas in singletasking the current value will be logged.

Another difference occurs when logging data in an enabled subsystem. Consider an enabled subsystem that has a slow signal driving the enable port and fast blocks within the enabled subsystem. In this case, the evaluation of the enable signal occurs in a slow task and the fast blocks will see a delay of one sample period, thus the logged values will show these differences.

To summarize differences in logged data between singletasking and multitasking, differences will be seen when:

For the first two cases, even though the logged values are different between singletasking and multitasking, the model results are not different. The only real difference is where (at what point in time) the logging is done. The third (enabled subsystem) case results in a delay that can be seen in a real-time environment.


  Program Execution Rapid Prototyping and Embedded Model Execution Differences