Array

Paul
2007-04-10
2015-11-08
  • Paul - 2007-04-10

    Hi, I need to make array of output.

    Like: OUTd AT %QX1.3 : ARRAY[0..9] OF BOOL;

    This entry is not allowed.

    Start at address 1.3 …

    Thanks

     
  • Igor Petrov - 2007-04-13

    IMHO it is impossible to declare bit array in IEC (I know the solution with CoDeSys 3.1 but not with 2.3). You can only use bytes array.

    If you extreme need it then write special functions like and . See here the idea implementation example for inputs.

     
  • ndzied1 - 2007-04-15

    For sure you can declare an array of bool without an address.

    You cannot, however, delcare an array of bool with a bit address.

    But, you can declare an array of bool with a byte address.

    In your example, you could declare the array

    OUTd AT %QB1 : ARRAY[0..7] OF BOOL;

    So long as the actual address %QB1 exists, this should work fine.

    Maybe if you mention what you are actually trying to accomplish someone might have a way to do it already.

     
  • robkristiaan - 2007-06-27

    abOutp:array[0..7];

    assign the outputs in abOutp

    then do this:

    byOutput.0:=abOutp[0];

    byOutput.1:=abOutp[1];

    byOutput.2:=abOutp[2];

    byOutput.3:=abOutp[3];

    byOutput.4:=abOutp[4];

    byOutput.5:=abOutp[5];

    byOutput.6:=abOutp[6];

    byOutput.7:=abOutp[7];

    %QB1:= byOutput;

     

    Related

    Talk.ru: 1
    Talk.ru: 2
    Talk.ru: 3
    Talk.ru: 5
    Talk.ru: 7

  • ljean - 2007-06-29

    An alternative can be to use the VAR_CONFIG mechanism. Then you can create an array of blocks and assign each output to the physical output in the VAR_CONFIG variable list:

    It would consist in something like:

    1) Create a FB:

    FUNCTION_BLOCK MyBlock

    VAR_INPUT

    END_VAR

    VAR_OUTPUT

    END_VAR

    VAR

    MyBit AT %Q*: BOOL;
    

    END_VAR

    2) In you program you can declare:

    PROGRAM PLC_PRG

    MyArray : ARRAY [0..7] OF MyBlock;
    

    END_VAR

    3) In the var config you must do:

    VAR_CONFIG

    PLC_PRG.MyArray[0].MyBit AT %QX0.0 : BOOL;
    
    PLC_PRG.MyArray[1].MyBit AT %QX0.1 : BOOL;
    

    .....

    PLC_PRG.MyArray[7].MyBit AT %QX0.7 : BOOL;
    

    END_VAR

    I didn't test this code but I did something similar in the past and I think it should work!

     
  • drChiavo - 2015-11-08

    ljean hat geschrieben:
    An alternative can be to use the VAR_CONFIG mechanism. Then you can create an array of blocks and assign each output to the physical output in the VAR_CONFIG variable list:
    It would consist in something like:
    1) Create a FB:
    FUNCTION_BLOCK MyBlock
    VAR_INPUT
    END_VAR
    VAR_OUTPUT
    END_VAR
    VAR
    MyBit AT %Q*: BOOL;
    END_VAR
    2) In you program you can declare:
    PROGRAM PLC_PRG
    MyArray : ARRAY [0..7] OF MyBlock;
    END_VAR
    3) In the var config you must do:
    VAR_CONFIG
    PLC_PRG.MyArray[0].MyBit AT %QX0.0 : BOOL;
    PLC_PRG.MyArray[1].MyBit AT %QX0.1 : BOOL;
    .....
    PLC_PRG.MyArray[7].MyBit AT %QX0.7 : BOOL;
    END_VAR
    I didn't test this code but I did something similar in the past and I think it should work!

    And how can I use, for example this bit (PLC_PRG.MyArray[0].MyBit AT %QX0.0 : BOOL;) afterwards in function block or function?
    Thanks

     

    Related

    Talk.ru: 1
    Talk.ru: 7


Log in to post a comment.