3

I am trying to get the current time from the PLC (Beckhoff-cx5130). I have tried "GETSYSTEMTIME", but I am not getting any output. I also tried "NT_GetTime" "TIMESTRUCT" and "T_FILETIME" but showing some compiling error (Could be a library issue). Any suggestion (Example code) regarding this issue will be highly appreciated. Thanks!

ali nawaz
  • 93
  • 1
  • 7

1 Answers1

5

I forgot to add the TcUtilities.Lib. After adding it, everything worked. For more info see Beckhoff's InfoSys

Example code

PROGRAM MAIN
VAR
    fbSystemTime : GETSYSTEMTIME;
    timeAsFileTime : T_FILETIME;
    timeAsDT : DT;
END_VAR

fbSystemTime(
    timeLoDW=>timeAsFileTime.dwLowDateTime,
    timeHiDW=>timeAsFileTime.dwHighDateTime 
);

timeAsDT := FILETIME_TO_DT(timeAsFileTime); 
Roald
  • 2,459
  • 16
  • 43
ali nawaz
  • 93
  • 1
  • 7