UNION to I/O Mapping

2020-12-09
2020-12-09
  • andras-mozes - 2020-12-09

    Hello,

    I would like to ask for your help, again. πŸ˜„

    I created the following Union:

    TYPE CognexReader :
    UNION
        ResultData : ARRAY[0..4] OF WORD;
        ResultString : STRING(10);
    END_UNION
    END_TYPE
    

    I instantiated it.

    PROGRAM PLC_PRG
    VAR
        Result : CognexReader;
    END_VAR
    

    It works fine but currently I have to map each I/O to the element of the array.
    I am wondering if there is a better approach b/c currently I have some 120 WORD to link to the union.

    I cannot link the whole ARRAY as the result data starts from index 5.

    Thanks for your help in advance.

    I really appreciate.

    Best Regards!

     
  • Morberis

    Morberis - 2020-12-09

    What about linking the whole array to another array starting at index 5?

    Or can you put Application.PLC_PRG.Result.ResultData[5..120] if you only want to use index's 5-120?

     
    πŸ‘
    1
  • andras-mozes - 2020-12-09

    Hm maybe I didn't get... πŸ€”

    I use Union in order to have the STRING representation of ARRAY[0..4] OF WORD.

    So somehow I need to map the PLC Output's 5..120 indexes to UNION CognexReader.

     

Log in to post a comment.