Re: [foxboro] Rolling Averages
- From: "patrick Den Haese" <phaese@xxxxxxxxxx>
- To: <foxboro@xxxxxxxxxxxxx>
- Date: Thu, 8 Dec 2005 16:40:26 +0100
There is an example of a running average on the CSC website (HH1042)
if you don't have access here is the printout
Regards,
Patrick Den Haese
HH#: HH1042
IA INFO: sja0401
File: Sequence Code,
Control, History
Release: All
Date: May 26, 2004
Subject: Generating a Moving or Running Average
Source: Experimentation in TAC
There are several ways in IA to obtain averages periodically. Often it is
desired, however, to have a running average that updates every minute or so
with
the average of some previous period of time.
The following IND block obtains a sample every minute from the process,
inserts
it into an array, and averages the previous 1440 values. If the value
equals
0.0, it is not included in the average.
This default value and other details can be changed to suit your needs, of
course.
The CALC block and code associated with RI0005 in the IND block are only
needed
if you want to know how long it takes the block to run. This would be a
consideration in a heavily loaded system.
Adjust the BPCSTM parameter if loading is an issue in your CP.
Note that at the end of the HLBL code is an example of converting a real
number
to a formatted number. If this is not done, real numbers written to strings
appear in exponential form ... i.e. 789 looks like "+7.890000e+2".
Boilerplate comments are not included.
Unused block parameters are not shown either.
----------------------------------------------------------------------------------
3AWD01# cat AVGR.s
INDEPENDENT_SEQUENCE{******************************}
CONSTANTS {****************************************}
default = 0.0;
VARIABLES {****************************************}
vals : R[1440];
i : I;
j : I;
k : I;
sum : R;
cnt : I;
save_minute : I;
time0 : R;
avgi : I;
dec : R;
d1 : I;
d2 : I;
d3 : I;
USER_LABELS{***************************************}
hour : II0001;
minute : II0002;
max : II0003;
avg : RO0001;
STATEMENTS{*****************************************
* Specify the statements here *
*****************************************}
i := 0;
max := 1440;
SN0001 := "initializing array ";
FOR j := 1 TO max DO
vals[j] := default;
ENDFOR;
<<start>>
/*** Wait for "MINUTE" to change ***/
SN0001 := "waiting";
save_minute := minute;
WAIT UNTIL save_minute <> minute;
SN0001 := "averaging";
time0 := RI0005;
{*** Collect a new value ***}
i := i + 1;
IF i > max THEN
i := 1;
ENDIF;
vals[i] := RI0001;
{*** Calculate the current average ***}
{* Don't use 0-values *}
sum := 0.0;
avg := 0.0;
cnt := 0;
FOR j := 1 TO max DO
IF vals[j] <> default THEN
sum := sum + vals[j];
cnt := cnt + 1;
ENDIF;
ENDFOR;
IF cnt <> 0 THEN
avg := sum / cnt;
ENDIF;
{***see how long it took us to do this ***}
RO0005 := RI0005 - time0;
{***calculate decimal digits of avg for sending to string ***}
avgi := TRUNC(avg);
dec := avg - avgi;
d1 := TRUNC(dec*10.0);
dec := dec * 10.0 - d1;
d2 := TRUNC(dec*10.0);
dec := dec * 10.0 - d2;
d3 := TRUNC(dec*10.0);
SN0005 := "average done at ",hour*100+minute," took ",RO0005," sec, ",
cnt, "
samples, avg= ",avgi,".",d1,d2,d3;
GOTO start;
ENDSEQUENCE
3AWD01# cat 3AWE01print
Integrated Control Configurator
Configuration = 3CP402
Fri Feb 25 18:28:17 2000
SJA:
NAME SJA
TYPE COMPND
. . .
SJA:AVGR
NAME AVGR
TYPE IND
. . .
BPCSTM 100
HSCI1 86400
LSCI1 0.0
DELTI1 1.0
EI1 %
HSCO1 100.0
LSCO1 0.0
. . .
II0001 3CP402_STA:STATION.HOUR
II0002 3CP402_STA:STATION.MINUTE
II0003 0
. . .
RI0001 23.45 <<<< connect to
value to be averaged.
. . .
RI0005 :TIME.RO01
. . .
RO0001 0.0
. . .
RO0005 0.0
. . .
SN0001
. . .
SN0005
. . .
CSPACE 20000
SJA:TIME
NAME TIME
TYPE CALC
. . .
HSCO1 86400
LSCO1 0.0
EO1 SEC
. . .
STEP01 TIM
STEP02 OUT RO01
STEP03 END
. . .
----- Original Message -----
From: "Wiggins, Bryan" <Bryan.Wiggins@xxxxxxxxxxxxxx>
To: <foxboro@xxxxxxxxxxxxx>
Sent: 08 December, 2005 16:28
Subject: [foxboro] Rolling Averages
> We are being ask to provide some rolling averages. They will not be =
> official numbers. We will use them for alarming purposes. The power =
> industry members might recognize these averages for continuous emission =
> mentoring. We will want a 30 day and a 90 day rolling average. During =
> the discussion our chemist spoke up and wanted an hourly average. Is =
> anybody doing this now and would you want to share?=20
>
>
>
> _______________________________________________________________________
> This mailing list is neither sponsored nor endorsed by Invensys Process
> Systems (formerly The Foxboro Company). Use the info you obtain here at
> your own risks. Read http://www.thecassandraproject.org/disclaimer.html
>
> foxboro mailing list: http://www.freelists.org/list/foxboro
> to subscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
> to unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
>
>
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
foxboro mailing list: http://www.freelists.org/list/foxboro
to subscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe: mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
- References:
- [foxboro] Rolling Averages
- From: Wiggins, Bryan
Other related posts:
- » Re: [foxboro] Rolling Averages
- » Re: [foxboro] Rolling Averages
- » Re: [foxboro] Rolling Averages
- » Re: [foxboro] Rolling Averages
- [foxboro] Rolling Averages
- From: Wiggins, Bryan