Start Timer¶
The Start Timer block can be used to do time measurements within code generated from a Simulink model.
The name of the timer is set by the Timer name parameter (i.e. Timer0). The elapsed time can be read using the Read Timer block with the same value for the Timer name parameter as the Start Timer block (i.e. Timer0).
The time measurement starts when a sample arrives to the input of the block. The input data passes through the block to its output. The output must be connected to the input port of the block for which the time will be measured. The data type of both the input and the output is inherited.
Note
The execution order of blocks is not fixed in Simulink. This means it can be that the execution time of other blocks might also be measured.
The Input and Output ports of a block can be used to validate that the block, which is being measured, is the correct one. However, to exclude other blocks from executing between the start and stop timer, the block order must be manually verified.
The Start Timer acts as a pass-through block when being used during simulation, and thus does not implement any functional behavior.
It is not allowed to have multiple Start Timer blocks with the same timer name. Doing so will result in an error. However, it is allowed to have multiple Read Timer blocks with the same name as the Start Timer block, as shown in the example in Timers example.
Data Type Support¶
The Start Timer block supports any data type available in Simulink.
Code generation¶
The Start timer block will only generate a signal in combination with a Read Timer block.
Examples¶
The timer, named Timer0, is read twice after it is started. The first time it is read, the time it takes to perform a gain operation is measured. The second time that the time is read, the time it takes to do both the gain and abs operations is measured.
Note
The elapsed time is not visible in the model and is only available as a signal in PMP after code generation.