How to deal with clock_ms() counting longer than 24days?

The customer wants to use the clock_ms () function block to calculate the scanning TIME of the program. However, the TIME type will overflow after 24 days. How to handle the situation after 24 days of overflow? The introduction of the time type states that it will flip. Then, will clock_ms also flip?


Hi,

yes, clock_ms() will also have an overflow when the maximum number of the data type is reached.

Of course you could handle the overflow by your own, but when running more then 24 days without restart, but maybe it would be better to use AsIoTimestamp().
This timestamp is of type DINT with microseconds resolution, so substracting actual value from last value will always be the difference in microseconds.

Best regards.

Thanks, We’ll try it!