File Average (AVE)

This table lists the controllers and applications that support this instruction.
Architecture
Standard applications
Safety applications
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers
Yes
No
CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers
Yes
Yes
The AVE instruction calculates the mean of a set of values.
Available Languages
Ladder Diagram
File Average (AVE) (1)_v31
Function Block
This instruction is not available in function block.
Structured Text
This instruction is not available in structured text.
Operands
There are data conversion rules for mixed data types within an instruction. See Data Conversion.
Ladder Diagram
Operand
Type
Format
Description
Array Tag
SINT
INT
DINT
REAL
tag
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
Dimension to vary
DINT
immediate
(0, 1, 2)
Which dimension to use
the order of the dimensions is: array[0,1,2]
Destination
SINT
INT
DINT
REAL
tag
Result of the operation
Control
CONTROL
tag
Control structure for the operation
Length
DINT
immediate
Number of elements of the array to average
Position
DINT
immediate
Offset into the specified array which identifies the current element that the instruction is accessing.
initial value is typically 0
Length and Position (corresponding to .LEN and .POS in the control tag) are pseudo-operands. For details, see Pseudo-operand initialization.
Description
The AVE instruction calculates the average of a set of values.
IMPORTANT:
Make sure the Length does not cause the instruction to exceed the specified Dimension to vary. If this happens, the destination will be incorrect. For more information, see Viewing an Array as a Block of Memory.
If an overflow occurs during expression evaluation, the instructions reads past the end of an array, the instruction sets the ER bit and stops execution
Affects Math Status Flags
Controllers
Affects Math Status Flags
CompactLogix
5380,
CompactLogix
5480,
ControlLogix
5580,
Compact GuardLogix
5380, and
GuardLogix
5580 controllers
Conditional, see Math Status Flags.
CompactLogix
5370,
ControlLogix
5570,
Compact GuardLogix
5370, and
GuardLogix
5570 controllers
Yes
Major/Minor Faults
None specific to this instruction. See Common Attributes for operand related faults.
Execution
Ladder Diagram
Condition/State
Action Taken
Prescan
The .EN bit is cleared.
The .DN bit is cleared.
If .ER bit is zero during prescan, all the control bits (.DN, .EN, .EU, .EM, .UL, .IN and .FD) will be cleared to zero.
Rung-condition-in is false.
See AVE Flow Chart (False)
Rung-condition-in is true.
The AVE instruction calculates the average by adding all the specified elements in the array and dividing by the number of elements.
Postscan
N/A.
AVE Flow Chart (False)
AVE Flow Chart False
Example 1
AVE Example 1
Ladder Diagram
RSL5K_AVE Ladder Diagram Example_v31
Example 2
AVE Example 2
Ladder Diagram
RSL5K_AVE Ladder Diagram Example 2_v31
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.