TON_SamplingPulse(IN:=NOT(TON_SamplingPulse.Q), PT:=REAL_TO_TIME(SamplingTime));
IF TON_SamplingPulse.Q THEN
FOR INDEX:=1 TO 19 BY 1 DO
PastMeasuredValues[INDEX]:=PastMeasuredValues[INDEX+1];
END_FOR
PastMeasuredValues[20] := MeasuredValue;
ENDİF
AveragedValue := (PastMeasuredValues[1]+PastMeasuredValues[2]+PastMeasuredValues[3]+PastMeasuredValues[4]+PastMeasuredValues[5]+PastMeasuredValues[6]+PastMeasuredValues[7]+PastMeasuredValues[8]+PastMeasuredValues[9]+PastMeasuredValues[10]+PastMeasuredValues[11]+PastMeasuredValues[12]+PastMeasuredValues[13]+PastMeasuredValues[14]+PastMeasuredValues[15]+PastMeasuredValues[16]+PastMeasuredValues[17]+PastMeasuredValues[18]+PastMeasuredValues[19]+PastMeasuredValues[20])/20;