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

Ethernet/IP Symbolic Access to I/O Channels pass the EIP Device FB instance to another FB IN_OUT

matthew
2023-07-30
2023-08-01
  • matthew - 2023-07-30

    Hi there,

    I'm having trouble working out how to pass the EIP devices FB instances into my function block since each EIP device has a different name and IEC Object type.

    I have just tested this and can access all the parameters of the device for example.

    _3G3AX_MX2_EIP_A4055_v1_4_FB.RunFwd 
    _3G3AX_MX2_EIP_A4055_v1_4_FB.RunRev
    

    Now I can create an instance:

    Drive : _3G3AX_MX2_EIP_A4055_v1_4_FB;
    

    I can now use that drive instance:

    Drive.RunFwd
    Drive.RunRev
    

    The Problem I have is codesys creates an FB per device with different name/instance...

     _3G3AX_MX2_EIP_A4055_v1_4_1_FB
     _3G3AX_MX2_EIP_A4055_v1_4_2_FB
     _3G3AX_MX2_EIP_A4055_v1_4_3_FB
    

    I need a way to pass that whole instance into my function block, maybe using in-out variable, reference/pointer or something. But I can't do this easily because I need to declare the instance inside the function block and each instance has a different name.

    Is there a way to use the input/output of the function block to pass the instance?

    If I can just pass _3G3AX_MX2_EIP_A4055_v1_4_FB into my function block without having to declare it inside of my function block. I can then use my one VSD FB and just assign each EIP device to my function block and won't have to map hundreds of variables and It's easy to add and change stuff etc in the future

     
  • matthew - 2023-08-01

    I take it this is not possible in CodeSys currently since everything has to be declared as static, I have been researching and reading into OOP and some of the limitations with CodeSys, I see there is the _NEW for dynamic memory, but does not look like a robust solution. Am I best just going back to the traditional method of mapping data?

     

Log in to post a comment.