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

Time Measurement between two events with V2.3 using Wago750-890

jared
2020-12-22
2020-12-26
  • jared - 2020-12-22

    Hello,
    Excuse me I don't speak english very well. I am discovering Codesys and I am trying to measure the time between two events. My main program is in LD but I can create function blocks with ST.
    I already saw some programs using the function SYS_TIME but Codesys doesn't recognize this function when I use it.
    Do you have any idea that could help me ?
    Thank you

     
  • ojz0r - 2020-12-23

    If you know the scan time you can simply implement a counter in ST and count the cycles between the events.
    Say you have a scan time of 100ms then do:
    IF event1 THEN
    Count := Count + 0.1; // Increment by 0.1s
    END_IF;
    IF event2 THEN
    Time := Count; // Set time value to Count
    Count := 0; // Rsset counter value for next run
    END_IF;

    This is just a simple example to give you inspiration.

     
  • dFx

    dFx - 2020-12-26

    Hum, regular way to do this is using systime library. You need to add it to your project in the library manager.
    Then use SysTimeGetMs to get actual CPU time in milliseconds ( ! This time is UTC time, not localized).
    Then, just substract values to get the delta time.

     

Log in to post a comment.