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

array

remy16
2021-04-08
2021-04-08
  • remy16

    remy16 - 2021-04-08

    Hello
    I would like to create an array in an ST language subroutine, which I am not familiar with.
    A priori you have to use the ARRAY function.
    This would be a 2 column table of 24 rows.
    The 1st column would record times, the second an INT or WORD value.
    The collection would be triggered from a top (BOOL) from a subroutine.
    Thank you for your help...!

     
  • JAPIB

    JAPIB - 2021-04-08

    Hello,
    An array only consists of data of the same type.
    To mix data types you need to create an array of struture. In this structure you can mix data types.
    For example :

    Define a structure in the tab Data type:
    MyStruct
    TYPE MyStruct :
    STRUCT
    Record_Time:TIME;
    Trigger:BOOL;
    END_STRUCT
    END_TYPE

    Define an array, for example in Glabal data :
    VAR_GLOBAL
    MyTab:ARRAY[1..24] OF MyStruct;
    END_VAR
    Nota : You can define your array from 0 to 23 or from 1 to 24 (or from what number you want !)

    And you can use it, for example in the PLC_PRG :
    PLC_PRg :
    MyTab[1].Record_Time:=T#10s;
    MyTab[1].Trigger:=TRUE;

    Hope to have been useful to you.
    BR

     

    Related

    Talk.ru: 1


Log in to post a comment.