First, I used Codesys V3.5.14 with Eaton XV303 PLC.
I want to extract the current time of the PLC to used it in my programme.
Currently I already extract the date and time with the function : gettimedate().
But this function return the current date and time and for my programme I want only current time.
Can you help?
Maybe it's possible to extract the time from the function gettimedate() or extract directly the current time from my PLC.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmm... Not a standard CODESYS function that one. If it returns a DATE_AND_TIME just use the TO_TOD() to convert it to a TIME_OF_DAY.
If not, then the function_block getDateAndTime() from the CAA DTUtil Can get you a DATE_AND_TIME, and when .xDone is true, call the TO_TOD().
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everyone,
First, I used Codesys V3.5.14 with Eaton XV303 PLC.
I want to extract the current time of the PLC to used it in my programme.
Currently I already extract the date and time with the function : gettimedate().
But this function return the current date and time and for my programme I want only current time.
Can you help?
Maybe it's possible to extract the time from the function gettimedate() or extract directly the current time from my PLC.
Hmm... Not a standard CODESYS function that one. If it returns a DATE_AND_TIME just use the TO_TOD() to convert it to a TIME_OF_DAY.
If not, then the function_block getDateAndTime() from the CAA DTUtil Can get you a DATE_AND_TIME, and when .xDone is true, call the TO_TOD().
May try this
SysTimeRtcHighResGet(pTimestamp:=GetTimeResult)
SysTimeRTc.SysTimeRtcConvertHighResToDate(pTimestamp:=GetTimeResult, pDate:=Ctrl_DateTime);
Then you can use e.g
Ctrl_DateTime.wHour
Ctrl_DateTime.wMinute
Ctrl_DateTime.wSecond
Ctrl_DateTime.wMilliseconds
BR
Chris
Hi All,
Thanks for your answers.
I have used the TOD function in my program.
BR
Yann