RSLogix 5000 AVE instruction

ErikG

Member
Join Date
Apr 2014
Location
Washington State
Posts
23
I"m trying to average an array of DINT's called FIFO_ARRAY. It has 1000 elements in it. Here is what I have entered into the AVE instruction:

Array- FIFO_ARRAY[0]
Dim. To Vary- 0
Dest- Average (DINT data type tag)
Control- AgerageControl (CONTROL type data tag)
Length- based on position of my FIFO.
Position- I initially set to 0

What happens is The instruction divides the value of FIFO_ARRAY[0] by the value in the length spot, but doesn't look at anything else in the Array. I have tried pointing the instruction to the entire array (FIFO_ARRAY) instead of to the specific element and it does the same thing.

Any help on this would be wonderful!
 
Even if you get this to work it won't be efficient. I would keep a sum of all the elements in the array. I would subtract the value of the old value that is being replaced and add the new value to update the sum. Then I would divide the sum by 1000. This way one avoids having to sum 1000 numbers each time.




If I want do learn how an instruction works a I make a small test program. In your case I would shrink the array down to four.
Why isn't it
FIFO_ARRAY[0..999]?
Why isn't the length 1000?
 
I put the length to the value of the position in my FIFO because if the FIFO isn't full yet I don't want it to be averaging a bunch of zero's, I just want the actual values that are filled in.
 
How do you write the length i.e. pass the length to AVG?

FYI, the best way to get help here is to post your code. Ego? Ha! Abandon all hope.

What quantity are you averaging? If it is delta-time, you are wasting same.
 
How do you write the length i.e. pass the length to AVG?

I assume that the OP has independent FFL and FFU instructions, so that the FIFO will have a variable number of values in it, not always 1000.

Both the FFL and FFU should use the SAME control word (Ex: FIFO_Ctrl), so that each knows when the FIFO is full or empty and where the last data is.

For the AVE instruction, then, use MOV(FIFO_Ctrl.POS AgerageControl.LEN) prior to executing the AVE instruction. I would also condition the MOV and AVE with a GRT(FIFO_Ctrl.POS 0), so that it doesn't try to take an average of an empty FIFO.
 
MOV 1000 AgerageControl.LEN

Edit: I copy/pasted that tag name from above.




That should have been "how did you write the length?" I.e. I know how to do it, but the thread is about a problem with the AVE instruction, so perhaps there was a misstep with the length.
 
That should have been "how did you write the length?" I.e. I know how to do it, but the thread is about a problem with the AVE instruction, so perhaps there was a misstep with the length.

Ahh, I see, I'm dumb. I've never used the instruction. But like all the other instructions that use a CONTROL tag, it has the Length right on the instruction. I posted in a hurry without putting enough thought into it.
 
Wouldn't you set the Length value in the AVE instruction to the FIFO.POS+1? The .POS gives the last written index in the array. If it was FIFO_Array[5] then 6 elements have been stored (0 ... 5)
 
Wouldn't you set the Length value in the AVE instruction to the FIFO.POS+1? The .POS gives the last written index in the array. If it was FIFO_Array[5] then 6 elements have been stored (0 ... 5)

Actually .POS points to the location where the next element will be added to the array, so it contains the number of elements in the array.

E.g. when the FIFO is empty, .POS is 0, and the next element loaded will be loaded at position 0, and .POS will be incremented to be 1.
 
The instruction manual in the description of .POS seems to indicate the "next write" interpretation. The flowchart of the instruction seems to me to indicate the "last written" interpretation. I don't have a system to test this on so I'll accept the "next write" consensus.
 

Similar Topics

Hello, Im getting aggrivated everytime Rslogix closes out I lose my Watchlist Tags.... Is there anyway to save a Tag lineup to use later??? Thanks
Replies
2
Views
2,092
Hello Guys, Please I need assistance on how to configure Powerflex 755 VSD as MASTER & SLAVE setup in Rslogix 5000 using TCP/IP network. Please...
Replies
0
Views
2,614
Hi all, First post in this forum. I am having trouble with a moving average (MAVE) instruction on an RSLogix 5000 controller. I have very...
Replies
3
Views
6,501
Is a save in RSLogix 5000 essentially an upload? Are all tag databases saved in either case? Are there any glaring differences between the two...
Replies
1
Views
2,326
H all Please help me, i have a big problem, i was trying many time but couldnot find out the way to solve it In my project I use 2 PLC and 1 HMI...
Replies
6
Views
8,136
Back
Top Bottom