Array instruction not working-need help

rroze002

Member
Join Date
Jun 2013
Location
Florida
Posts
39
Hi all,

One question - why doesn't this work?

SIZE Storage[0] 0 StorageSize COP Zeros[0] Storage[0] StorageSize

Storage and Zeros arrays are both one dimensional bool arrays. Storage array contains 32 bits and Zeros array 64 bits.

Thanks in advanced.
 
Please specify what type of PLC you are using, also your source is SIZE Storage[0] 0 StorageSize, i understand the Storage[0] being the element # in this case 0 but what is the 0 StorageSize followed right after it, is it part of the array structure??
Then it looks like you have two destinations, one is Zeros[0] and the other is Storage[0] both of them are again followed with the StorageSize?

you also mention that Storage and Zeros arrays are both one dimensional bool arrays which is an array that contains 32bits. Then you went on to say that Zeros array has 64 bits. So which one is it 64 or 32??

When ever you manipulate data in arrays its best to use the same data sizes other wise you can have data overflow's that can occur and give you unexpected results
 
OK, that didn't help a lot either. I don't know what an 'xps' type file is.

Please state, without attaching a manual excerpt, to which PLC you are referring.

If you want do add something about the 'SIZE' instruction please copy/paste it.
 
Also, when working with arrays, you mostly don't need to use SIZE, since in most (nearly all?) cases you certainly know the length of the arrays.

The only time I can think of to use SIZE is if you are using a subroutine, or iterative loop, to process multiple arrays of differing sizes, which may be the case here.
 
Also, when working with arrays, you mostly don't need to use SIZE, since in most (nearly all?) cases you certainly know the length of the arrays.

The only time I can think of to use SIZE is if you are using a subroutine, or iterative loop, to process multiple arrays of differing sizes, which may be the case here.

I've actually become quite found of the SIZE instruction lately. It allows me to make my software a bit more robust and reliable. I had an instance last year where a COP instruction was used to copy data from one array to another, with the length field hard-coded. Well another engineer made a mistake and incorrectly defined the length field. The array size was 20, they defined the length as 21. As you can imagine, some interesting things happened. Now anytime I am manipulating arrays I always use the SIZE instruction to make sure I have the correct lengths. I've since applied it to FOR instructions, FFL/FFU, FSC, all to make sure that any array indexes are not exceeded, and it allows my code to become dynamic. If I change the array size, my code adjusts to it.

It is one of those instructions that you may not find value in it, until you find value in it.

OP -

SIZE instruction, from the RSLogix5000 help file does not list BOOL as a valid source datatype for this instruction. I assume your problem is that the rung shows error and you cannot compile the project?

The error is pretty clearly listed in the error list:

"Error: Rung 2, SIZE, Operand 0: Invalid data type. Argument must match parameter data type."
 
Thank you all and sorry for the long response time.

So to clarify the situation, I'm working with a CompactLogix PLC (L45) and what I'm trying to do is find a way to clear all of the bits in a bool array, but now I see that most array functions are not applicable to bool arrays.

So the followup question is - what is the best data type for bit operations. For example, which data type is best suited for a sequencing application?

I've abandoned the bool array for an INT type and I have the following:

Untitled.jpg
 
The "as installed" default data-type is DINT, because the machine has a 32-bit architecture, DINT is the most efficient data-type.

Whenever the processor encounters a SINT or an INT, it converts it to a DINT for processing, then DINTs are comverted back again for storage - all this conversion takes time.

It is only really necessary to use 16-bit INTs or 8-bit SINTs when necessary, for example to provide compatibility with other devices.
 

Similar Topics

Logix 5000 v32 on 1769-L16ER I used the FBC instruction to scan an array of DINTs for true bits and it works but I found a thing that just...
Replies
2
Views
87
Does RSLogix5 have an instruction that outputs the overall size (elements) of an array? I am looking for a SIZE instruction equivalent in...
Replies
2
Views
1,198
I'm still a little remedial with my Step 7 classic knowledge. I'm working on in Simatic Manager 5.5, SP4, and I need a little insight of how to...
Replies
10
Views
2,744
Hello, I made a UDT with DINT[50] and REAL[50] data types. I cannot seem to get the whole data type array to transmit. I can do all the dints...
Replies
4
Views
2,157
Productivity3000. I have a 32 bit integer, 1d array that i need converted to a string. The string to array seems to work with the same time type...
Replies
0
Views
2,174
Back
Top Bottom