Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Digital Clock

aved
2024-02-26
2024-02-27
  • aved - 2024-02-26

    i need help creating a digital clock in CODESYS that should be displyed on a Raspberry Pi LCD Display trough the Visualization built in CODESYS. I have an idea how to display the time by making a 7 Segment Dysplay in the Visu. But I don't know how to get the actual time into the program. Can anyone help?

     
  • evanclegg - 2024-02-27

    To display the current time, you’ll need to retrieve it from the system clock. In CODESYS, you can use the built-in function SysTime to get the current system time.
    Here’s an example of how you can use it:

    VAR
    dtCurrentTime: DATE_AND_TIME;
    sTime: STRING(8);
    END_VAR

    dtCurrentTime := SysTime();
    sTime := TIME_TO_STRING(dtCurrentTime.t);

    The sTime variable now contains the current time in the format β€œHH:MM:SSuno online".

     

    Last edit: evanclegg 2024-02-28

Log in to post a comment.