F_CXSubTimeStamp

F_CXSubTimeStamp 1:

For subtraction TwinCAT3.1 also offers 64-bit data types (LINT/ULINT, LWORD) that can be executed directly (A-B) or there are TC2-compatible functions for 64-bit operations that should be used as an alternative to F_CXSubTimeStamp.

F_CXSubTimeStamp 2:

The function F_CXSubTimeStamp executes a 64-bit subtraction time stamp A - time stamp B and converts the result to µs. The required 64-bit time stamps with 100 ns resolution can be read from the system with the function block GETCPUCOUNTER.

If the difference between time stamp A and time stamp B is negative or greater than 4294967295 us, the maximum value 4294967295 us is returned. This corresponds to 71 minutes, 34 seconds, 967 milliseconds and 295 microseconds. In such cases the function UInt64Sub64() from TcUtilities.lib can be used to execute a complete 64-bit subtraction with 64-bit result in [100 ns].

FUNCTION F_CXSubTimeStamp: UDINT

VAR_INPUT
    nTimeStampLoDW_A : UDINT; (* 2*32 bit time stamp A: low DWORD *)
    nTimeStampHiDW_A : UDINT; (* 2*32 bit time stamp A: high DWORD *)
    nTimeStampLoDW_B : UDINT; (* 2*32 bit time stamp B: low DWORD *)
    nTimeStampHiDW_B : UDINT; (* 2*32 bit time stamp B: high DWORD *)
END_END_VAR

nTimeStampLoDW_A: lower 32bit of time stamp A.

nTimeStampHiDW_A: upper 32bit of time stamp A.

nTimeStampLoDW_B: lower 32bit of time stamp B.

nTimeStampHiDW_B: upper 32bit of time stamp B.

Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT v3.1

CX (WES7/Win7/Win10: TC RT x86/x64, WEC6/7 :TC TR x86, WEC7: TC CE7 ARMV7)

Tc2_SystemCX