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

Data exchange between 2 FBs

2020-12-28
2020-12-30
  • codesystart - 2020-12-28

    Hello,

    I am a library developer & new to CodeSys.

    I have a very simple question. I have 2 FBs with some input & output parameters. I want to take the output of 1 FB & use it in the 2nd FB. (irrespective of the instance of FB)

    One way is that maybe i can use GVL. But i dont want to do so as i am making a library & not end application(PLC program)

    Is their any other way to get data of a 1st FB instance in a 2nd FB??

    Maybe using some interfaces?? Could someone post an example??

     
  • Morberis

    Morberis - 2020-12-28

    I am not sure. If you do something like FB1_Name.FB_Variable in the second FB you get an error that "Functionblock 'FB1_Name' must be instantiated to be accessed.

    For my own libraries I just make an output variable in the first FB and an input variable on the second but I can see why you would want to do it your way. Though I'm unsure what would happen with multiple instances of FB 1.

    Looking through the help file quickly I'm wondering if Parameter transfer by reference might work for you.

     
  • tvm - 2020-12-30

    What about this?

    FUNCTION_BLOCK BASE
    VAR_STAT
    Shared: INT;
    END_VAR

    FUNCTION_BLOCK FB_1 EXTENDS BASE
    FUNCTION_BLOCK FB_2 EXTENDS BASE

     

    Last edit: tvm 2020-12-30

Log in to post a comment.