Read Timer¶
The Read Timer block can be used to do time measurements within code generated from a Simulink model.
See also
The Start Timer block.
The name of the timer is set by the Timer name parameter (i.e. Timer0). A timer can be started using the Start Timer block. The timer name must correspond to the one of the Start Timer block.
The input of the Read Timer block should be connected indirectly to the corresponding Start Timer block. The data type of both input and output is inherited.
The Read Timer acts as a pass-through block when used during simulation and thus does not implement any functional behavior.
When code is generated, the BlockName_ElapsedTime
signal can be used to get the elapsed time between the starting and the reading of the timer value in seconds.
It is possible to have multiple Read Timer blocks in combination with one Start Timer block, as shown in the example in Timers example.
Data Type Support¶
The Read Timer block supports any data type available in Simulink.
Code generation¶
The following signals are generated in PMP:
Signal Name |
Access |
Data Type |
Description |
---|---|---|---|
<BlockName>_ElapsedTime |
R |
Double |
Elapsed time block: <BlockName>; timer: <TimerName> |
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.