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

TOF RST and ET

alverman
2018-05-01
2018-05-01
  • alverman - 2018-05-01

    hello, I need a TOF that has RST and ET

    OSCAT has a TOF with RST but does not have ET
    Standard TOF has ET but has no RST

    How can I solve ?

    Thanks, Alberto

     
  • Lo5tNet - 2018-05-01

    Just make your own: (Should work but needs to be tested)

    FUNCTION_BLOCK TOF_Advanced
    VAR_INPUT
        IN:BOOL;
        PT:TIME;
        RST:BOOL;
    END_VAR
    VAR_OUTPUT
        ET:TIME;
        Q:BOOL;
    END_VAR
    VAR
        tStartTime : TIME;
        tCurrentTime : TIME;
    END_VAR
    //Read system time
    tCurrentTime := TIME();
    //Set Q based off IN and PT
    IF RST THEN
        Q := FALSE;
        ET := T#0MS; //You can reset ET here also if wanted
    ELSIF IN THEN
        Q := TRUE;
        ET := T#0MS;
        tStartTime := tCurrentTime;
    ELSIF tCurrentTime - tStartTime >= PT AND Q THEN
        ET := tCurrentTime - tStartTime;
        Q := FALSE;
        tCurrentTime := T#0MS;
    ELSIF Q AND NOT IN THEN
        ET := tCurrentTime - tStartTime;
    END_IF
    

    IMG: TOF_Advanced.PNG

     
  • alverman - 2018-05-01

    WooooooW

    Work very fine

    Thanks

     

Log in to post a comment.