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

How to call action in ST with action qualifiers?

2018-12-10
2019-02-03
  • Serhioromano

    Serhioromano - 2018-12-10

    In SFC I can call action with qualifiers like P0, R, S, N, LD, ... It means that there is a way to apply qualifier to action, but in ST if I can action like

    myAction(S);
    

    I get error during compilation.

    How can I call an action with qualifiers in ST?

     
  • Anonymous - 2019-01-24

    Originally created by: scott_cunningham

    ST doesn't work that way. The IEC qualifiers are really replacement for ST code to make SFC easier to manage (LD has some similar items).

    For example, and IEC action (action code or boolean var) without a qualifier looks like this in ST:

    MyAction();
    

    or

    Done := TRUE;
    

    If you use the set qualifier (S), it would be something like this:

    IF DoOnce= TRUE THEN
       MyAction();
       DoOnce := FALSE;
    END_IF
    

    or

    IF DoOnce = TRUE THEN
       Done := TRUE;
       DoOnce := FALSE;
    END_IF
    
     
  • Serhioromano

    Serhioromano - 2019-02-01

    What if I have impulse and I have a trigger. On raise I want to start action and perform it before other signal.

    VAR
        xSignal1: BOOL;
        xSignal2: BOOL;
        xWork: BOOL;
        fbRT1: R_TRIG;
        fbRT2: R_TRIG;
    END_VAR
    fbRT1(CLK := xSignal1);
    fbRT2(CLK := xSignal2);
    IF fbRT1.Q THEN
        xWork := TRUE;
    END_IF; 
    IF fbRT2.Q THEN
        xWork := FALSE;
    END_IF; 
    IF xWork THEN
        actMyAction();
    END_IF; 
    

    This simple task and code is huge. I hoped to shorten it few lines.

    VAR
        xSignal1: BOOL;
        xSignal2: BOOL;
        xSignal1M: BOOL;
        xSignal2M: BOOL;
    END_VAR
    IF fxSignal1 AND NOT xSignal1M THEN
        actMyAction(S);
    END_IF; 
    xSignal1M := xSignal1;
    IF xSignal2 AND NOT xSignal2M THEN
        actMyAction(R);
    END_IF; 
    xSignal2M := xSignal2;
    

    That would really make some things simpler.

     

Log in to post a comment.