quarc_computation_time_demo.mdl
Open this model

MATLAB Command Line

Click to copy the following command line to the clipboard. Then paste it in the MATLAB Command Window:

quarc_computation_time_demo

QUARC Computation Time Demo

This example demonstrates how to use the Computation Time block from the QUARC Targets library to compute the time it takes for a Function-Call Subsystem to execute in one cycle. For details of this block, please refer to the Computation Time block reference page in the QUARC documentation.

Computation Time Demo Simulink Diagram

The model computes a matrix multiplication of two 10x10 random matrices in a loop. The number, N, of iterations of the loop is controlled by the Slider Gain. Start with a low number of iterations and work up slowly, as the model could freeze your PC as the number of computations increases. Be sure to keep the computation time less than the sample time of the model, which is set to 10 ms. A safety feature is added to the model for the QUARC Hardware-In-Loop Watchdog Demo to stop executing the Function-Call subsystem in case the model starts to miss sampling instants due to long computation time of this subsystem. In this demonstration however, we have not included this safety feature.

Configuring the Demonstration

To set up the demonstration, double-click on the Slider Gain to open the Slider Gain dialog, as shown below:

Computation Time Demo Slider Gain

Set the initial gain to 10 in the middle field so that the computation time will not be too large.

Warning This example will take too long to execute and eventually freeze the target if the slider gain is set to be very large. Caution must be taken when setting this variable. Note that the maximum slider gain of 200 may be too large for slower targets.

Demonstration

Building, deploying and starting the model

Refer to One Step Process in QUARC Basic Procedures to build, deploy and start the model.

Running the model

Double-click on the "Tc(ms)" Scope block to display the computation time of the Function-Call Subsystem.

Slowly adjust the slider gain up or down and watch the change in computation time. For embedded targets, it is highly recommended that the arrow buttons be used to adjust the slider rather than clicking in the track to the left or right of the slider thumb. The "Tc(ms)" Scope will trace a signal similar to the following figure:

Scope

Stopping the model

Refer to One Step Process in QUARC Basic Procedures to stop the model.

Running the example on a different target

To run the example on a different target, refer to the instructions on the Running QUARC Examples on Remote Targets page.