File Average (Ave); Relay Ladder; Structured Text - Allen-Bradley Logix5000 Reference Manual

1756 controllogix, 1768 compactlogix, 1769 compactlogix, 1789 softlogix, 1794 flexlogix, powerflex 700s with drivelogix
Hide thumbs Also See for Logix5000:
Table of Contents

Advertisement

Chapter 8
Array (File)/Misc. Instructions (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE)

File Average (AVE)

380
The AVE instruction calculates the average of a set of values.
Operands:

Relay Ladder

Operand
Array
Dimension to
vary
Destination
Control
Length
Position

Structured Text

Structured text does not have an AVE instruction, but you can achieve the same
results by using a SIZE instruction and a FOR...DO or other loop construct.
SIZE(array,0,length);
sum := 0;
FOR position = 0 TO length-1 DO
sum := sum + array[position];
END_FOR;
destination := sum / length;
See
Structured Text Programming
within structured text.
Rockwell Automation Publication 1756-RM003N-EN-P - October 2011
Type
Format
SINT
Array tag
INT
DINT
REAL
DINT
Immediate
(0, 1, 2)
SINT
Tag
INT
DINT
REAL
CONTROL
Tag
DINT
Immediate
DINT
Immediate
for information on the syntax of constructs
Description
Find the average of the values in this array
Specify the first element of the group of elements
to average
Do not use CONTROL.POS in the subscript
Which dimension to use
Depending on the number of dimensions, the order
is:
array[dim_0,dim_1,dim_2]
array[dim_0,dim_1]
array[dim_0]
Result of the operation
Control structure for the operation
Number of elements of the array to average
Current element in the array
Initial value is typically 0

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents