AVG Instruction in Omron PLC :-
Symbol :- AVG S N D
Where S - is the source word whose average value is to be found out. N - is the number of cycles for which the average value will be calculated. D is the Result word where the average value will be stored.
Every time the AVG Instruction is execute the contents of S are stored in D+2 to D+N+1 , for the first execution of AVG Instruction the value of S is stored in D+2 , for the second execution of Instruction the value of S is stored in D+3 and so on. When the Execution of Instruction reaches N times then the average value of D is stored in D.
NOTE :- N must be BCD from #0001 to #0064
Example :- Consider AVG D100 #4 D200
So when this instruction condition goes from off to on for first time then the value of D100 is stored in D202 , at Second execution it is stored in D203 , at third execution it is stored in D204 , at fourth execution it is stored in D204 and average value is also calculated and stored in D200.
We have also made a Sample PLC Program using AVG Instruction for better understanding of yours.
Download.