indirect addressing

2009-01-27
2011-12-06
  • fractalmind - 2009-01-27

    hi , i work with codesys and wago plc 750-841 ...... is possible indirect

    addressing in codesys ?

    thanks

    (excused for my very bad English)

     
  • ndzied1 - 2009-01-27

    I am assuming that you are referring to the Allen Bradley term Indirect Addressing.

    In CoDeSys this type of manipulaiton is not necessary as you can define arrays. It is actually much clearer to do this type of programming in CoDeSys.

    Here is a sample array declaration. Look in the help for more information.

    arr1 : ARRAY [1..5] OF INT;

     
  • dansaxton - 2011-12-05

    So how can you create a DO loop that will increment the address in the array each time?

     
  • RolandWagner

    RolandWagner - 2011-12-06

    Hi,

    Zitat:
    So how can you create a DO loop that will increment the address in the array each time?

    There are several possibilities. The best is to use a FOR loop:

    Β  Β arr1 : ARRAY [1..5] OF INT;
    Β  Β i: INT;
    Β  Β read: INT;
    FOR i:=1 TO 5 BY 1 DO
    Β  Β read := arr1[i];
    END_FOR
    

    Alternatively you can use REPEAT ... UNTIL or the WHILE loops.
    You will find examples to both in the online help of CoDeSys.

    Zitat:
    is possible indirect addressing in codesys

    Yes, even if this is an extension to the IEC 61131-3 you can use indirect addressing.

    Example:

    Β  Β var1, var2, var3: INT;
    Β  Β pAdress : POINTER TO INT;
    pAdress:=ADR(Var1);
    pAdress^:=5;
    

    You can find more information on pointers in the online help. But please be careful! Writing on addresses you are not supposed to can really harm your application, the controller or the machine. Thus I can only recommend to use pointers in case you really know how to use them.

     

Log in to post a comment.