SYSTEMTIME_TO_DT

SYSTEMTIME_TO_DT 1:

The "SYSTEMTIME_TO_DT" function allows the Windows system time structure to be converted to the DATE_AND_TIME format (DT) usual in a PLC. The system time has a resolution of 1ms, while the resolution of DATE_AND_TIME is 1s. The milliseconds from the system time are used in the course of the conversion to determine the direction of rounding for the returned DATE_AND_TIME value. Set the wMilliseconds member of the Windows system time structure to zero to deactivate the rounding.

FUNCTION SYSTEMTIME_TO_DT : DT

VAR_INPUT
    TIMESTR     : TIMESTRUCT;
END_VAR

TIMESTR: The structure with the Windows system time requiring conversion.

 

Example of a call in FBD:

PROGRAM SystemTimeTest
VAR
    SystemTimeStruct  :TIMESTRUCT;
    DTFromSystemTime  :DT;
END_VAR

 

SYSTEMTIME_TO_DT 2:

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT v2.7.0

PC or CX (x86)

Standard.Lib; PLCSystem.Lib; TcPLCAds.Lib; PLCHelper.Lib; TcPlcUtilities.Lib

TwinCAT v2.8.0 and above

PC or CX (x86)

TcUtilities.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically )

TwinCAT v2.10.0 Build >= 1301

CX (ARM)