Hmmm.... no attachment allowed. Let do it this way: ================= INDEPENDENT_SEQUENCE{******************************* RUNNING AVERAGE CALCULATION ** 06 DEC 2000: LS Kong - Made Generic ** ***************************************************} CONSTANTS WINDOW = 1440; { 1440 Minutes / 24 Hours Window } SAMPLE = 48; { 48 Sample in Window Period } VARIABLES QUEUE : R[SAMPLE]; { Queue Length=No of Samples } I : I; USER_LABELS NEW_READING : RI0001; { Current reading } AVERAGE : RO0001; { Calculated average } SUM : RO0002; { Sum of All Readings } HEAD : IO0001; { Current head of queue } STATEMENTS { Initialisation } WAIT 10; { Wait for things to settle } QUEUE := SET_ARRAY (NEW_READING); { Set all values in } { array to current value } HEAD := 1; { Head of queue } <<loop>> { Push current reading to the head of the queue } QUEUE[HEAD] := NEW_READING; { Calculate Sum of All Readings } SUM := 0; FOR I := 1 TO SAMPLE DO SUM := SUM + QUEUE[I]; ENDFOR; { Calculate Average over [SAMPLE] number of readings } AVERAGE := SUM / SAMPLE; { Move the head of queue to the next reading } IF HEAD < SAMPLE THEN HEAD := HEAD + 1; ELSE HEAD := 1; ENDIF; RO0002 := 0; RO0003 := QUEUE [SAMPLE - 12]; RO0004 := QUEUE [SAMPLE - 11]; RO0005 := QUEUE [SAMPLE - 10]; RO0006 := QUEUE [SAMPLE - 9]; RO0007 := QUEUE [SAMPLE - 8]; RO0008 := QUEUE [SAMPLE - 7]; RO0009 := QUEUE [SAMPLE - 6]; RO0010 := QUEUE [SAMPLE - 5]; RO0011 := QUEUE [SAMPLE - 4]; RO0012 := QUEUE [SAMPLE - 3]; RO0013 := QUEUE [SAMPLE - 2]; RO0014 := QUEUE [SAMPLE - 1]; RO0015 := QUEUE [SAMPLE]; { Endless Loop } WAIT WINDOW / SAMPLE * 60; { wait til next calculation cycle } GOTO loop; ENDSEQUENCE ----- Original Message ----- From: LS Kong <lskong@xxxxxxxxxxxxx> To: <foxboro@xxxxxxxxxxxxx> Sent: Friday, November 30, 2001 11:06 AM Subject: Re: [foxboro] 24 hr rolling average > > Not the best but this should work. > > > ----- Original Message ----- > From: Matic.Hank <Hank.Matic@xxxxxxxxx> > To: <foxboro@xxxxxxxxxxxxx> > Sent: Friday, November 30, 2001 2:37 AM > Subject: Re: [foxboro] 24 hr rolling average > > > > We do a rolling three hour average with a sequence block , taking a sample > > once per minute. To trend the average , you need only to put the sequence > > block real output into a historian and assign that value to a trend point. > > If you like , I can send you a copy of the code. > > > > -----Original Message----- > > From: Jaudon, Michael [mailto:MJAUDON@xxxxxxx] > > Sent: Thursday, November 29, 2001 7:27 AM > > To: 'foxboro@xxxxxxxxxxxxx' > > Subject: [foxboro] 24 hr rolling average > > > > > > > > I know we have already ventured down this path once but at the time > rolling > > average didn't interest me and I didn't give it a passing thought...now it > > does. > > > > My question is: How would you program for a 24 hour rolling average (my > case > > is a flow) say sampled every 5 minutes (288 samples per day)? I also need > > to trend the result. > > > > Regards, > > > > Michael L. Jaudon > > Kerr-McGee Chemical LLC > > (662)343-8710 > > mjaudon@xxxxxxx > > > > > > > ___________________________________________________________________ This list is neither sponsored nor endorsed by The Foxboro Company. Use the information obtained here at your own risk. For disclaimer, see http://www.thecassandraproject.org/disclaimer.html#maillist list info: //www.freelists.org/list/foxboro subscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=join unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave