12.07.2015 Views

Logix5000 Controllers General Instructions - SLAC Confluence

Logix5000 Controllers General Instructions - SLAC Confluence

Logix5000 Controllers General Instructions - SLAC Confluence

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

368 Array (File)/Misc. <strong>Instructions</strong> (FAL, FSC, COP, CPS, FLL, AVE, SRT, STD, SIZE)File Average (AVE)The AVE instruction calculates the average of a set of values.Operands:Relay LadderOperand Type Format DescriptionArray SINT array tag find the average of the values in this arrayINTDINTREALspecify the first element of the group ofelements to averagedo not use CONTROL.POS in the subscriptDimensionto varyDINTimmediate(0, 1, 2)which dimension to usedepending on the number of dimensions, theorder isarray[dim_0,dim_1,dim_2]array[dim_0,dim_1]array[dim_0]DestinationSINTtagresult of the operationINTDINTREALControl CONTROL tag control structure for the operationLength DINT immediate number of elements of the array to averagePosition DINT immediate current element in the arrayinitial value is typically 0Structured TextStructured text does not have an AVE instruction, but you can achievethe same results using a SIZE instruction and a FOR...DO or otherloop construct.SIZE(array,0,length);sum := 0;FOR position = 0 TO length-1 DOsum := sum + array[position];END_FOR;Publication 1756-RM003I-EN-P - January 2007

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!