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

2 Dimmensional Array

kevinl
2021-11-09
2021-11-10
  • kevinl - 2021-11-09

    Hi Guys
    i am trying to define a Constant array in Var Constant....

    i initialise it like this:

    intEntranceControl : ARRAY [0..5, 0..1] OF DINT     := [-1000,  20, 1400,   70100,  71427,  72532   ,
                                                                80,     100,1200,   1200,   100,    80      ] ;
    

    but then i get weird values, some missing, some twice and the order seems completely wrong... can you please point me in the right direction?
    Thank you

     
  • i-campbell

    i-campbell - 2021-11-09

    Seems specific to your setup.
    on CODESYS Control Win V3 x64 3.5.17.20 I get the expected results (see attached).
    What are you running it on?
    Also a possibilty, is nd having an array out of bounds problem, writing to memory it shouldn't.

     
  • kevinl - 2021-11-10

    hmm, kinda weird... unfortunately not the first time i got weird behaviour on codesys for raspberry pi....

    i'll do a test with a empty project to make sure i have no other issues that can interference...

     
  • kevinl - 2021-11-10

    hmm, the problem seems to sit a little deeper, i just tested on Raspberry pi 4.2.0.0, in SP16.60 and SP17 in a empty project... works fine on both.

    there must be a issue with my current project.
    this is how i initialize all constants. do you see a error here?

    VAR CONSTANT
        dintPositionTolerance : DINT := 10;
        dintControlTolerance : DINT:=800;
        intSpeedLimit : INT :=1100; 
        intSpeedLimitEntrance : INT := 320;
        intFix : UDINT :=   10023072;
        intBottomStationPos : UDINT :=  1255875;  //position of the Bottomstation for reset Position manual pos in cm  +10000 /0,008 
        intTopStationPos    : UDINT := 10185625;  //position of the Topstation for reset Position manual     pos in cm +10000 /0,008   
    
        intEntranceControl : ARRAY [0..5, 0..1] OF DINT     := [-1000,  20, 1400,   70100,  71427,  72532   ,
                                                                80,     100,1200,   1200,   100,    80      ] ;
    END_VAR
    

    btw. if i init like this:

        intEntranceControlP : ARRAY [0..5] OF DINT  :=  [-1000, 20, 1400,   70100,  71427,  72532   ];                                      
        intEntranceControlS : ARRAY [0..5] OF DINT  :=  [80,    100,1200,   1200,   100,    80      ] ;
    

    that works...

     
  • i-campbell

    i-campbell - 2021-11-10

    Can you post a project which reproduces it?
    Your latest declaration works fine on my Pi. (screnshot)

     

Log in to post a comment.