Array compare

micahg

Member
Join Date
Feb 2007
Location
Georgia
Posts
35
I'm working on a project using a Flexlogix plc. I need to be able to compare 2 arrays of 15 words and see if they are the same. I want to comapare (array1[0] = array2[0]) all the way thru (array1[14] = array2[14]) and see if both arrays are equal. Is there any easier way than using 15 equal statements. I've got to do this for 20 functions and that would be 300 equal functions. There must be an easier way. Thanks..
mg
 
You could also use a For/Next loop. The L5K platforms all support For/Next loops in ladder and ST. Check out the FOR instruction.
 
It looks like the FSC will work to do what I asked for. How about if I want to start with word 2 of array one and compare it to word 2 of array two, length 10. It looks like the FSC will only allow me to start with word 0 and what ever length I set. When I try to set the starting word, it gives me an error. Any suggestions here, or maybe I'm doing it wrong. Thanks..

mg
 
You can initialize the control word .POS to whatever offset you want to start at. You must also change the Length accordingly. For example, if you want to check from offset 2 to 15, the Length would need to be 16. The expression should look something like the following:

array1[cntr1.POS]<>array2[cntr1.POS]

where cntr1 is the control word. If the cntr1.FD bit is on right after the FSC instruction, then there is at least one word in the arrays that do not not match.
 

Similar Topics

I'm working on an array that contains a UDT of 5 Items Array[4] DataType[0] - Part 1 - Part 2 - Part 3 - Part 4...
Replies
1
Views
859
Hi out there is it possible to Compare a bool array to a bool, in studio 5000. I'm think that if One of the bool's in my array is true, then i...
Replies
10
Views
6,423
All, We have a 6 lane conveyor to carry bars and at the end we have a pick and place which picks up the bars if a sensor detects it. For all 6...
Replies
0
Views
2,215
I've come across an application that might be hard to explain, however I think there might be a simple explanation. I am doing an array of...
Replies
3
Views
3,446
Hello again- after the nice thread on filling the .pre's on timer arrays, I'm in another bind. I need to look at 60 timer_array.dn bits and see...
Replies
20
Views
3,994
Back
Top Bottom