The algorithm is based on incrementing time distances between two invocations of the function block. The function block is capable to calculate the elapsed time after a warm restart beginning from the last invocation. The time distance is measured by using an internal system tick counter (contains the amount of time in milliseconds). The preset timer value (PT) is limited at 2,147,483,647 milliseconds for the *_R function block (max range of DINT data type) and 9,223,372,036,854,775,807 for the *_R_LTIME function block (max. range of the LINT data type).
Problem of lost invocation after warm restart
Because the algorithm is based on a non retentive internal system tick counter, it is important to take notice of the problem, which we call 'lost invocation'. The figure below describes the behavior of the function block before and after a warm start is forced. After the parameter IN raised to TRUE, the next invocation detects the raising edge state of IN. At this point, the calculation begins with ET (elapsed time) := 0. After a warm restart, the next invocation detects the changed state and normalizes the internal start value by subtracting the current system counter with the internal retentive elapsed counter. That is why the time distance to the previous invocation is 0. Related to the 'real' elapsed time there is a delay dependent from the duration between successive invocations of the function block. That means, after a warm start the duration of the function block is at worst one invocation distance slower than a function block where no warm restart occurs.
Hot start behavior
After a hot start is performed , it is important to know that the timer calculates the elapsed time including the duration of the stop state. A hot start is forced, if, for example, the PLC is continued from a breakpoint. During the online debug, it could happen that some timer expire if the PLC halts on breakpoints.