current time

yann
2020-03-26
2020-03-31
  • yann - 2020-03-26

    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.

     
  • i-campbell

    i-campbell - 2020-03-26

    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().

     
  • Chris.O - 2020-03-26

    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

     
  • yann - 2020-03-31

    Hi All,

    Thanks for your answers.
    I have used the TOD function in my program.

    BR
    Yann

     

Log in to post a comment.