Call a Function Block

Romuald
2010-04-08
2010-04-09
  • Romuald - 2010-04-08

    Hi,

    I call a Program (PRG1) from System Events (event start for example).

    PRG1 have to send a email. But the function to do this is a function block and need multiple cycles.

    How to do this when PRG1 is called once and have only one cycle.

    I also notes that I can't put parmeters to call a program from System Events.

    It is possible from a Tasks Config but not from System Events.

    Thanks,

    Romuald.

     
  • Nitrozin - 2010-04-09

    Hi,

    • call a FB from your event wich sets a global bit

    • call PRG1 in main cycle as long as bit is true.

    • reset the bit in PRG1 when all stuff is send.

    Nitro

     
  • Romuald - 2010-04-09

    Thanks for you reply.

    Nitrozin hat geschrieben:
    Hi,
    - call a FB from your event wich sets a global bit
    Nitro

    So we can call a FB from an event ? When I press the F2 key, only PRGs are proposed.

    I don't understand how we can call a FB. We do not need to create an instance ? It does not seem to be possible in System Events.

    And as I said, apparently we can not use parameters for POU in System Events.

     
  • Romuald - 2010-04-09

    I should mention that I use the version 2.3.9.13

    What I did that seems to work:

    System Event 'start' --> START_PRG
    
    PROGRAM START_PRG
    VAR
    Β  Inst: FB;
    Β  error: INT;
    END_VAR
    go := TRUE;
    WHILE go DO
    Β  Inst(var1 := '', .., send := go, error => error);
    END_WHILE
    

    In fact I simulates cycles with a WHILE boucle. Is the good way to do in CoDeSys development ?

    I don't think so. My WAGO stops responding

     
  • Romuald - 2010-04-09

    Nitrozin hat geschrieben:
    Hi,
    - call a FB from your event wich sets a global bit
    - call PRG1 in main cycle as long as bit is true.
    - reset the bit in PRG1 when all stuff is send.
    Nitro

    Perhaps you want to say this:

    VAR_GLOBAL
    Β  Gstart: BOOL;
    END_VAR
    

    System Event 'start' --> START_PRG
    Cyclic Tasks which calls --> PRG_WITH_FB

    PROGRAM START_PRG
    Gstart := TRUE;
    
    PROGRAM PRG_WITH_FB
    VAR
    Β  Inst: FB;
    Β  error: INT;
    END_VAR
    IF Gstart THEN
    Β  (* send = IN_OUT variable. Set to FALSE when finished *)
    Β  Inst(var1 := '', .., send := Gstart, error => error);
    Β  IF NOT send THEN
    Β  Β  Gstart := FALSE;
    Β  END_IF
    END_IF
    
     

Log in to post a comment.