Logix5000 average the non-zero values in a real array of fixed length

tmadore

Member
Join Date
Jan 2016
Location
Connecticut
Posts
12
Hello,
Hoping somebody has some ideas that can help me out.
Looking for an easy way to average the nonzero values of a REAL array of fixed length. I'm using a FIFO load and unload to initially fill the array with cycle time values and I want the initial average cycle time to be accurate without having to run n cycles (n elements in array)

or

If I'm going about this all wrong and there's an easier solution....?

Thanks!
 
To me it's easier to prevent values that are zero to enter the FIFO. Then you don't have to worry about masking out the bad values, only allow good values in the first place.
 
1. Only load non-zero values into your array *Phrog30 beat me to it!
2. Upon a true FFL done bit use an AVE instruction to calculate the average
2a. Or you can adjust the length of the AVE instruction based on FFL position
 
Last edited:
+1 to only using the non-zero values, but if you want dynamic averages before the FIFO is done, use a "FSC" to find the first zero, then add one to the position for your denominator. Of course, you have be sure the FIFO is emptied at some point to make sure you have a zero at the end of your filled variables. And, of course, write the logic so you can't generate a divide by zero fault.

Oh, you also need to use a "FOR" to determine how many values to unload and add before dividing...
 
Last edited:

Similar Topics

Hi! So my problem is a little funky, I had Studio 5000 v 24 and 30 installed, but forgot to install RSLogix (which I cannot go without). Is there...
Replies
2
Views
112
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
427
I'm a Siemens person, and this is one of my first AB programs. The customer wants everything programmed in Ladder. I have a lot of data (3...
Replies
14
Views
215
Good day everyone. if you have a logic for 3 pumps (lead/lag/off), would you please email it to me? I really appreciate it!
Replies
7
Views
205
Maybe this is just not possible, or maybe I am doing something wrong. Background; I have a data array of over 1500 products. For sorting I...
Replies
6
Views
757
Back
Top Bottom