Sign in to follow this  
Followers 0
Blackriv3r

Problem with Array of Array

12 posts in this topic

Hello i'm new in Omron plc programming and not very good in english! I have write this code in ST language but have 1 error in compiling it. This is the code: PLC CJ2M Data Types Prova [struct] Members of Prova Dog Bool [10] array of ten boolean bit Presente Bool Symbols Prova [3] Array of 3 elements. I create a new program Max:=3; (uint) Max2:= 10; (uint) FOR i :=1 TO Max BY 1 DO; Prova.Presente := TRUE; FOR j:= 1 TO Max2 BY 1 DO; Prova.Dog[j]= Prova.Presente AND j<10; END_FOR; END_FOR; I get this error Matrix Index not valid. Need some help, maybe indirect addressing?

Share this post


Link to post
Share on other sites
You may need to declare the pointers (i,j) as integers. From memory, you cannot use un-declared variables in ST in Omron

Share this post


Link to post
Share on other sites
Hmm, yep is looking like it, or perhaps even structures...?? Looks like you cannot indirectly access a sub-element of an array within a structure. A constant index does work into the sub-element though, but I suspect that will defeat the purpose. Without suggesting how to re-work your structures, not sure what you can do. I wonder if this can be clarified by Omron? My suspicion is that it is because it is a structure... Looks like it cannot even be done in ladder I have a way of doing this in ladder using IR/DR if you want an example?

Share this post


Link to post
Share on other sites
I have a way of doing this in ladder using IR/DR if you want an example? Yeah can you post it? Thank you I wonder if this can be clarified by Omron? They post in this forum?

Share this post


Link to post
Share on other sites
There are members who work for Omron, they are more application specific, not the actual code writers, but can provide information sometimes that the rest of us cannot get...

Share this post


Link to post
Share on other sites
Yes in this example the 2 condictions are "Prova.Presente := TRUE" and "Prova.Dog[j]= Prova.Presente AND j<10"; In real program the condiction Prova.Presente := TRUE and j<10 doesn't exists. Both are variable (int) from HMI. The cycle "for" must check if i have Prova [1] and then check if i have the Dogs in Prova [1]. Then check if i have Prova [2] and then Dogs. Example If i don't have Prova [2] the Dogs in Prova[2] are all False! Edited by Blackriv3r

Share this post


Link to post
Share on other sites
Example attached. I have used D1001-D1003 as 'Prova', with bits D100x.00/09 as Dogs & D100x.15 as Presente. If you need Presente to not be part of the same word let me know & I can change it. This way was nice & easy.. Arraytest.cxp

Share this post


Link to post
Share on other sites
Thank you so much!!!!!!! Edited by Blackriv3r

Share this post


Link to post
Share on other sites
No problem, once you get the hang or IR/DR can do almost anything...

Share this post


Link to post
Share on other sites
great work "lost control"..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0