Hello,
I’m attempting to use a pair of compress records to calculate the average of a scalar PV over a window of time.
The first compress record is the “Circular Buffer”, which has a size of 360 samples, with a SCAN period of “10 second”, thereby sampling the scalar PV (which is INP) over one hour of time.
record(compress, “Buffer”) {
field(INP, “Current”)
field(ALG, “Circular Buffer”)
field(NSAM, “360”)
field(SCAN, “10 second”)
field(FLNK, “AvgCurrent”)
}
The second compress record is set to “N to 1 Average”, taking as INP the array obtained from the circular buffer compress record. This record should process each time the circular buffer receives new data,
therefore the circular buffer record has a forward link to this record:
record(compress, “AvgCurrent”) {
field(SCAN, “Passive”)
field(INP, “Buffer”)
field(ALG, “N to 1 Average”)
field(N, “360”)
}
What I find is that the “N to 1 average” record is invalid until the Circular buffer has filled up (e.g. after one hour in my case). After the circular buffer is full of samples, it works as expected.
I have also tried to compute the average with an acalcout record, but I got the same result.
Is this the expected outcome, or can anyone suggest how to implement so that average works before the circular buffer is full? Is there perhaps a way I can initialize the circular buffer?
Thanks,
Greg Guyotte