Timer (Initiate Timer)
The Timer instruction is used to initiate a timer in the datalogger program.
Syntax
variable = Timer ( TimerNo, TUnits, TOption )

This example uses Timer to measure the time required to execute the measurement instructions. The Timer is reset at the top of each scan. The time in microseconds is stored in the variable Elapse. Note that the newer InstructionTimes function is an alternative method to measure processing times.
Public RefTemp, TCTemp, Elapsed
DataTable (Test,True,-1)
DataInterval (0,1,Min,10)
Sample (1,TCTemp,FP2)
Sample (1,Elapsed,IEEE4)
EndTable
BeginProg
Scan (1,Sec,3,0)
Timer
(1,uSec,2)
TCDiff (TCTemp,1,mv200C,U1,TypeT,RefTemp,True,0,15000,1.0,0)
Elapsed = Timer (1,uSec,4)
calltable (Test)
NextScan
EndProg
Remarks
A typical use of the Timer is to set a variable equal to the Timer instruction (i.e., Variable=Timer(1, sec, 2). The Timer value is then stored in the defined variable. Multiple Timers can be defined in the program; each must have a unique TimerNo argument.
Parameters
TimerNo (Timer Number)
A number assigned to the timer (for example, 0, 1, 2, …). Memory is allocated for timers based on the value entered + 1 (for example, using a TimerNo of 100 will allocate memory for 101 timers even if there is only one Timer in the program). Use a low number to conserve memory.
If this value is a variable, memory for 17 (0 - 16) timers is allocated. If more than 17 timers are needed, and TimerNo also needs to be a variable, use a "dummy" Timer instruction, which does not execute at run-time, with a TimerNo of the maximum number of timers needed in the program.
Type: Integer or Variable
TUnits (Time Units)
The TUnits argument is the time unit in which to report the Timer. A numeric or alphabetical code can be entered.
Code | Alphanumeric Code | Description |
---|---|---|
0 | usec | microseconds |
1 | msec | milliseconds |
2 | sec | seconds |
3 | min | minutes |
4 | hr | hours |
Note, when using microseconds:
- The datalogger does not go into quiescent mode. This increases the power consumption of the datalogger. If a microsecond timer is needed within the program, stop the timer after its use to allow the datalogger to go into quiescent mode when it is not actively running its program.
- The datalogger uses a 32-bit counter, so the maximum amount of elapsed time that can be tracked when using microseconds is 2147 seconds or approximately 35 minutes. Furthermore, the results are stored as a float that has 24-bits of resolution, so precision will be lost after 8 seconds.
Type: Constant
TimeOpt (Timer Action)
The action on the Timer. The timer instruction returns the value of the timer after the action is performed. A numeric code is entered. Right-click the parameter to display a list.
Code | Description |
---|---|
0 | Start |
1 | Stop |
2 | Reset and start |
3 | Stop and reset |
4 | Read only |
Type: Constant