"Function block call requires an instance" calling an action

standeven
2015-04-24
2015-04-24
  • standeven - 2015-04-24

    Using Codesys 2.3, I'm getting the following error:

    "A function block call requires a function block instance."

    My call to the function is in a PRG as follows:

    PROGRAM TestProgram
    VAR
    Β  Β  testFunctionBlock:MyFunctionBlock;
    Β  Β  callAction:BOOL;
    END_VAR
    testFunctionBlock(inputVar:=1);
    IF (callAction) THEN
    Β  Β  testFunctionBlock.testAction();
    END_IF;
    

    Any idea why this won't build? The function block is instantiated, so I'm not sure what's going on. I suspect I might be calling the action wrong.

    Thanks for any help!

     
  • standeven - 2015-04-24

    I solved the problem.

    The problem was that I had a variable in the function block with the same name as the action (variable name was zeroCount, action name was ZeroCount). This confused the compiler, so I renamed my action and now it works.

     
  • shooter - 2015-04-24

    and you are also calling this function block twice (that is no good practice, however i do know why as you want the same blockresults.
    You may give the values in front of the call.

    Especcially when using timers this often is a problem, the compiler does not see these problems.

     

Log in to post a comment.