CompactLogix - Max size of string array?

First of all; Thank you all for your input on this matter and for taking you time to answer the question in great detail.


The problem was a rookie mistake in this case. The size of the array is 2048, which generates element 0 to 2047. I made the mistake of reseting my index counter at element 2048 which ofcourse was out of bounds. So point goes to JeremyM :D


I'm sorry for the late response, but I had taken the day of yesterday when the customer called and wanted to test some things. I told them I was not ready but they really wanted to test before christmas. Turned out I had some more unwanted "features" that I had to resolve, so had to put a couple of hours into it.


Once again; Thank you and I wish you all a "God jul" from Sweden (y)
 
Thank you Friedrich for getting back with the cause of your controller faulting.

From your initial post, I "assumed" you had tried to re-size the array online, which I have already said was not possible, so the cause of the controller faulting out was an indirection into the array was "too big", not that the array itself was "too big".

You initially said ....

Friedrich said:
When I did this the controller faulted, saying the array was too big.

Now that we know that the controller faulted when transitioning to Run mode after a download, I am totally happy with everything, because that is exactly what should happen during the scan of the code. The error checking picks up the fact that an array index is "out-of-bounds" and the controller major-faults.....

I believe that if you had taken the time to copy down the exact error message, the seconds taken to do so would have given you the answer you needed.

Never mind, a lesson learned, perhaps. But in the meantime there has been some good (and some not so good) information posted, which may, or may not, help you in the future.

Now, one more thing to consider....

The "out-of-bounds" index was trapped by the controller, because it would have meant access outside of the boundaries of the target tag.

However, be aware that if that array were inside a UDT tag, (but not the last element), then that in-built error-checking no longer protects you. The index just calculates an offset into the tag element, and if that offset exceeds the target array boundaries, but still lies within the overall UDT tag, then nothing faults out, and you can read or write garbage.

It is always a good recommendation to LIM test any indirect addresses into array tags, one day you will build UDT tags with embedded arrays, and the "out-of-bounds" checking is no longer 100% effective as a safeguard.

God jul och ett gott nytt år från Storbritannien
 
that the reason I always add a few extra elements to my arrays just in case the index over runs.
usually when that happens the processor though's a major fault and shuts down
then when you restart it the fault is cleared and the index is reset until the next time
 
that the reason I always add a few extra elements to my arrays just in case the index over runs.
usually when that happens the processor though's a major fault and shuts down
then when you restart it the fault is cleared and the index is reset until the next time

What if your illegal index exceeds those new boundaries ?

EDIT: My OCD would not let me create an array bigger than it needs to be, and how do you document why you've done it ?

Much better to not let it try to access out-of-bounds in the first place. And why waste the memory ?

EDIT2 : You're the programmer, ensure that it doesn't ....
 
Last edited:
i am old school i learned to program on SLC100, PLC2, PLC3
in those systems arrays were just data table location they were addressed in Octal
we always kept 2 words above and below empty "NULL" it helped to identify those addresses as an array collection we also didn't have tags or symbols back them everything was addresses only but the file search has an index but if it wen over the number of valid addresses it would crash
as for documenting the extra elements why i assume that anybody following me can see what's going on and if they can't then they really shouldn't be in their poking around
it's not uncommon to have empty elements in any array
do you document every single element of an array
 
The error stated that the array was too big, but also stated that it might be a problem with .LEN (too many characters in the string). So after checking that I was under 82 characters in all elements it hit me that I didn't know how big an array could be and that it might be the real problem after all. Could not find any info about it in the help file of Studio 5k, so posted the question here.

Thank you daba for the info about UDT.


A tip for anyone reading this thread in the future is to use the "Size" command and use the result of this to determine the end of your array and with that reset your index counter. That way you don't have to manually keep track of the size and make changes in the code.
 
A tip for anyone reading this thread in the future is to use the "Size" command and use the result of this to determine the end of your array and with that reset your index counter. That way you don't have to manually keep track of the size and make changes in the code.

Using SIZE, and resetting, or clamping, the index means that you are effectively going to be reading/writing the wrong data.

You should be using SIZE together with the actual index value to generate an alarm whenever the index is invalid. If invalid, don't act upon it, especially if it's a Write Data, that way you'll be overwriting valid data in the wrong place ....

What I'm saying is that if the index is invalid - throw it away with an alarm generated - don't read data from the wrong location, don't write data to the wrong location. It's not hard to implement.
 
Last edited:
SIZE, IMHO, is only useful if you are using an AOI that can work with variable sized arrays - other than that, you will know the size of your data arrays and program your data access instructions accordingly.

As an example - if you want to sort the elements of an array, you could write a generic sorting AOI, and that will use SIZE to determine - well obviously - the size of the array to work with.

I understand the instruction, but never had to use it in over 30 years !
 
The string length is 82
How are you writing over 82 characters to a single string
keyboard , read from a serial port either way you can limit the string length
in received message
 

Similar Topics

I have a project where I will need around 20 IO cards. I'll probably have 5 on a compactlogix L320ER and 15 or 20 on a Point IO AENTR module. The...
Replies
4
Views
981
While trying to download produced and consumed tags with a new controller on the same network I get this error: The maximum number of nodes on...
Replies
8
Views
4,269
ok guys i know i have been blowing this forum up a lot here lately but i am venturing into some unknown waters for me. ok the situation is i have...
Replies
5
Views
1,512
So basically i have 2 queries : 1. I have a program file of S7-300 PLC which i want to migrate in RSLogix500.In short i want to convert my simatic...
Replies
15
Views
252
Hi everyone, i have a compact logic 1769-L18 PLC and I'm using FTalk View ME for the display. I wanted to do some visualization on Grafana. At...
Replies
1
Views
113
Back
Top Bottom