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

Interval from timer elapsed time

aarondw10
2022-10-17
2022-10-17
  • aarondw10 - 2022-10-17

    Hi,

    for a project I want to make a certain boolean X true, but only if the elapsed time of a TOF is between 2 specific values. (TOF goes up to 20 seconds).
    For example:

    IF T#4S <= timer.ET <= T#7S THEN
    X := TRUE;
    END_IF

    Now I keep getting the error that he can't do that. He can only compare the value of timer.ET to 1 specific time but not if the ET is between an interval of 2 times. Is their a different way to do it that doesn't make the code much larger?

    Thanks!

     
  • tvm - 2022-10-17

    Try this:

    IF (timer.ET >= T#4S) AND (timer.ET <= T#7S) THEN
        X:= TRUE;
    END_IF
    
     
    πŸ‘
    1

Log in to post a comment.