RSlogix 5000 find highest value of array

waterbottle

Member
Join Date
Mar 2019
Location
Florida
Posts
42
Hello



Currently have a project in which I have to find the highest value in a dint array. Once the highest value is found I will have to move the Dint tag that holds the highest value. Basically the array holds the amount of jams and I need to display the highest jam location. Each dint of the array is a location and the value is the addition of the number of jams it had. Any ideas will be highly appreciated.
 
I would program a loop to look at each dint in the array using a pointer. Increment the pointer after every scan or however often you need to check it. Store highest value and constantly compare each check to the highest. Once a new higher value is found, store that pointer's value, which is the element in the array's number.

Remember you can use the pointer inside of the array brackets: myDintArray[pointer]
 
Last edited:
To find the position of the Highest Value:

Array_Pos_HighestValue:=0;

for i:=0 to 99 do;
if DataArray>DataArray[Array_Pos_HighestValue] then
Array_Pos_HighestValue:=i;
end_if;
end_for;
 
Mickey,
Not sure that will do what he wants, that will sort the values, but will it tell the tag of the highest value?


Yes, just select the last register in the array after the sort. Ascending order.

See examples page 373 and 374 of pdf I posted.
 
It is not necessary to sort the array just to find the highest value as destination unknown proposed, a sort will most likely take longer
 
Why not keep a running max value and update it upon insertion into the array, if the new value is higher than the most recent max?

Beats searching over and over.
 
Not only is a sort not what the OP ultimately wants, it destroys the information he is really concerned about: which location originally contains the highest number. He is trying to determine what portion of his machine is contributing the most jams. The snippet of pseudocode that destination unknown posted is what you are looking for.

Keith
 
Not only is a sort not what the OP ultimately wants, it destroys the information he is really concerned about: which location originally contains the highest number. He is trying to determine what portion of his machine is contributing the most jams. The snippet of pseudocode that destination unknown posted is what you are looking for.

Keith

Yes this is exactly what I'm trying to do. I tried to sort but it changes the position of the highest value. Each tag on the array represent a jam location portion of an air conveyor that moves empty bottles. The tag is the sum of the jams in that section. Trying to have like a pointer that indicates which tag in the array has the highest value.


Example
JamArray[0] = 4
JamArray[1] = 10
JamArray[2] = 3
JamArray[3] = 2

I will then need to indicate that JamArray[1] is the highest value
 
Last edited:
Why not just put the Jam locations names stated on a HMI screen, with the corresponding registers next to it, and read it out.
 
Why not just put the Jam locations names stated on a HMI screen, with the corresponding registers next to it, and read it out.

The space is limited since is just one display screen used to spot jams in the lines for the operator to unjam with no touch capability for them to change pages. The Idea is to get the highest value and indicate the position then that value will indicate the location name in the hmi.:unsure::unsure::unsure:
 

Similar Topics

I'm troubleshooting a customer's machine, and I've been racking my brain trying to figure out an answer to a question of where a value is being...
Replies
22
Views
3,301
Hey all, So we have had this piece of equipment for a while but its a question that always blows my mind away when troubleshooting this piece of...
Replies
2
Views
1,403
In Rslogix 5000, when searching for tags, is there a way to look only for destructives? Thanks.
Replies
8
Views
3,927
When i do the find all search from the drop down menu, it will do the search but the pop up box that shows all the found search's wont pop up...
Replies
3
Views
1,790
Back
Top Bottom