Biggest Number in an Array RSLogix5000

BMLLER6758

Member
Join Date
Aug 2006
Location
Kiel
Posts
93
Ladies and Gentlemen,

I made a Measurement station.

The result of the measurement goes into an Array. Array[0]...Array[349]

I allready sort them with the SRT. But now my Customer also wants the biggest an lowest Number out of that array shown in a Protocol. I try to write some code but that really looks horrible and very complicated.

Maybe somebody did it allready and has some solutions ???

regards

Bernd
 
You'll have to have logic to compare all the values to "LowValue" and "HighValue" storage tags for display.

You can used indirect addressing for this:

EDIT: working on example
 
Last edited:
I really suck at the ladder editor here!

I'll type my response, my example uses tags
Array
Index
HighValue
LowValue

Rung 1
If Array[Index] > 0 AND Array[Index] > HighValue MOV Array[Index] High Value

Rung 2
IF Array[Index] > 0 AND Array[Index] < LowValue MOV Array[Index] Low Value

Rung 3
ADD 1 Index

Rung 4
If Index GRT 349 CLR Index

If you aren't familiar with indirect addressing this may not be easy to understand.
 
Last edited:
This is a perfect application for indirect addressing. Scan through your array, comparing each value against the highest and lowest value. You'll need to adjust the limit on the index register depending on the size of your array. See the attached screen shot, which is using an array of DINT[100].

Array Indexing.jpg
 
Whether the array is full or not, once sorted the highest value will be at the top end of the array (highest index), and the lowest value will be at the bottom.

If we assume the array was initially filled with zeroes, then the lowest, non-zero value will be some distance into the array, and a FSC can be used to find it.
eg.
Array[0] 0
Array[1] 0
Array[2] 0
Array[3] 0
Array[4] 3
Array[5] 17
.....
Array[349] 2357

If zero is a valid number for the measurement, then it would be better to intialise the array with a number that can be recognised as NOT being a valid measurement, say max-ve (-2,147,483,648 for a DINT).

Sorting the array with SRT, then taking the highest value from Array[349], and then using FSC to find the lowest valid measurement will undoubtedly be the most efficient method.
 
I am sorry, I didn´t mean the biggest and the lowest number.

I mean the numbers that are mostly exist in that array.

Sorry for that confusion

The array has the size of 350

There are no zeroes in the array. All Number are between 3600 and 4100.

Hanx !

regards

Bernd
 
Last edited:
The thread cited was looking for a solution to occasional outlier readings. Their requested help was for a method to find those readings which occurred most often (sound familiar). After the poster FINALLY explained why they wanted the calculation some suggested that a filter would be a better solution. But that's irrelevant. What you need to pay attention to are the discussions on finding the number of occurrences of each value which will lead to finding the greatest (as in this case) and the least number of occurances.
 

Similar Topics

Hello I wanna know if are some function to check what is the max value from an array or if I have to loop the array to compare all numbers to get...
Replies
4
Views
1,888
I just want to get others thoughts on what is the biggest obstacle one faces in migrating to a newer system? For me with the few systems I have...
Replies
17
Views
4,105
Good Afternoon , My biggest fear came true. I lost a USB stick that had my RS Logix 5000 activation on it . What is the best way to get...
Replies
8
Views
7,154
I am working on a project using a NB screen and NX1P2 PLC. I am having a really hard time getting a real number to properly translate through to...
Replies
3
Views
120
Complete noob here, using a Click C0-02DD1-D to run a test stand. Requirement is to turn on motor run for X seconds, turn off and dwell for X...
Replies
6
Views
1,071
Back
Top Bottom