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 for IW ,QW or MW addresses

himanshu
2016-11-11
2016-11-14
  • himanshu - 2016-11-11

    Hello Everyone,
    I want to use Input or Memory address as array and then want to read in Program.
    For e.g, %MW512, % MW514, % MW516..
    I want to read as following
    %MW(variable_Name) and Variable name to be increased by 2 in each cycle and read values of memory and write to some different temporary array.

    Is this possible?

     
  • Anonymous - 2016-11-14

    Originally created by: scott_cunningham

    You can do this:

    PROGRAM PLC_PRG
    VAR
    Β  Β Word1 AT %MW0 : WORD;
    Β  Β Word2 AT %MW1 : WORD;
    Β  Β Words AT %MW0 : ARRAY[0..1] OF WORD;
    Β  Β Pass : BOOL;
    END_VAR
    Word1 := 12345;
    Word2 := 32109;
    Pass := (Words[0] = Word1) AND (Words[1] = Word2);
    

    Pass goes true.

    But be careful about direct memory access - when I changed removed the forced memory location on Word1 and Word2 - then Pass was false (i.e. who knows where the compiler put the variables!). Also, I believe the memory locations may be hardware dependent, too.

     

    Related

    Talk.ru: 1


Log in to post a comment.