R Trigger for UINT

2022-06-15
2022-06-20
  • edwin200000 - 2022-06-15

    Hello,

    Is there a R Trigger for UINT? I have an joystick, when I rotate clockwise the range is 0 to 65535.
    The standard R Trigger is 0 to 1 cause BOOL. I want when the joystick rotates clockwise (value goes up) a BOOL. And when I don't rotate the bool is false. This also counterclockwise.
    So a R-trigger for UINT.

    Or does someone know a other solution?

    Thankyou

     
  • hermsen

    hermsen - 2022-06-19

    Hi Edwin,

    a FB like R_Trig for integer datatypes does not excist in the standard CODESYS libraries. However, maybe a solution excists in OSCAT basic. Plus I have a small trick which could help.

    FB_INT_TRIG
    VAR_INPUT
    iVAL : INT;
    END_VAR
    VAR_OUTPUT
    Q : BOOL;
    VAR
    iPrev : INT;
    END_VAR

    // BODY code
    Q := (iVal <> iPrev);
    iPrev := iVal;

     
    πŸ‘
    1
  • edwin200000 - 2022-06-20

    Goodmorning Hermsen,

    Thankyou so much it worked!!!! And I got another signal out of the joystick to say if it rotates clockwise or counterclockwise so I could use that. And have add a TOF timer to make the signal more stable. But was not possible without your help so thankyou!

    Kind regards,

    Edwin

     

Log in to post a comment.