adding arrays

asterof

Member
Join Date
May 2007
Location
Califonia
Posts
554
so I have 32 arrays of real
each array has 4 words
array1[0] - [3]
array2[0] - [3]
and so on

I need to add each element to the next array same element
example x = array1[0] + array2[0] + array3[0]
and so on

using a cpt would be ugly and hard to read

is there a way maybe to use an FAL to do this
 
Set up a For-Next loop;

For I = 0 to 3
x(I) = array1 + array2 + array3
Next I
 
Last edited:
tried that also, but you still need a ton of expressions
have not seen a way to index the arrays, I can use .pos to
index the array its self like array1[fal.pos] but not
array[FAL.POS][0]+ Holding_Array[0]
 
I don't know - I have set up For Next loops in RSLogix, so I would think it could be done with Controllogix. The PLC loops every scan, so all you have to do is implement the index counter.

If you can't index an array, then in my book it is not a true array. The main reason to use the array structure is to allow easy automated access with indexing. Without that, all you have is a collection of data.
 
Last edited:
The FAL instruction is perfect for this.

It would get even simpler if you made a single 32x4 array.

Could do that if I was using Step7 or Modicon
However Controllogix does not have that capability
You are mistaken. The CLX has a FOR/NEXT instruction in both ladder and ST languages, or you can roll your own using JMP/LBL pairs.
 
Last edited:
The FAL instruction is perfect for this.

It would get even simpler if you made a single 32x4 array.


You are mistaken. The CLX has a FOR/NEXT instruction in both ladder and ST languages, or you can roll your own using JMP/LBL pairs.


I will look for it
Never had to use one before
what tap is that under as I do not see it
 
For some reason it doesnt look like there is a FOR instruction listed in the structured text tabs. I couldnt find it; however it does show up if you look for it in the instruction help. There are two of them. One is a ladder style instruction that allows you to cycle through a routine a number of times. The other is the FOR / DO pair that are for structured text and works pretty much like a FOR / NEXT pair.
 
screen shot

could you drop a screen shot here
would appreciate it
running on 2008 server standard and for some reason the
ver 16 help files are no longer supported
 
Most of you all know that For-Next loops can be nested, so that multi-dimensional arrays can be manipulated, for example:
 
For J = 0 to 30 Step 3
For I = 0 to 3 Step 1
x(I) = array[J, I] + array[J+1,I] + array[J+2,I]
Next I
Next J

 
Last edited:
clarity

yea but maybe I was not clear

I have 32 arrays of different names
each array has four elements
I need to add element 0 of each array to each other
tot_array1[0] = array1[0] + array2[0] + array3[0] + .... + array32[0]
tot_array1[1] = array1[1] + array2[1] + array3[1] + ....
+ array32[1]

I can not make a 32 x 4 element array
I can do this using an FAL with and external indexing dint

and I need to do this in an AOI because of the number
of these required
so I am passing the arrays by reference
 

Similar Topics

Hi Everyone, Currently we have three plants running with Controllogix PLCs (L72, L73, L74). In each of these plants we have 2 FTView SE...
Replies
0
Views
54
Hello, Im building project with 1756-L82ES controller and 1756-IB16S card but i cant find it when trying to add the card to IO configuration...
Replies
3
Views
134
Hello, I have a pair of redundant 1756-L71 controllers rev 24. These controllers currently have produced and consumed tag interfaces to 3 other...
Replies
2
Views
158
I'm adding an IAI Gateway with 2 axes connected to it. To an ethernet network on my PLC. So, I think the math is correct on the Input and Output...
Replies
0
Views
143
Hi Folks. I am gearing up to add a 2nd identical HMI to a project. This 2nd HMI will basically be an exact clone of the 1st one. The equipment...
Replies
3
Views
258
Back
Top Bottom