Maximum/Average_Campbellsci论坛问答

Originally posted under: "Average" Function
02/22/10 7:10 AM

I have a question. This is how my CR1000 program works (simplified):

Maximum/Average_Campbellsci论坛问答

'Program start/////////////////////
Public MyVar

DataTable(MyTable,1,-1)
DataInterval(0,30,Min,10)
Average(1,MyVar,IEEE4,False)
Maximum(1,MyVar,IEEE4,False,False)
EndTable

BeginProg
Scan(30,Sec,0,0)
[measure something and put it in MyVar]
If TimeIntoInterval(0,30,min) Then CallTable MyTable
NextScan
EndProg
'Program end/////////////////////

The IF statement should have been left out. I have corrected the code now but I have valuable data from earlier on from this station that I hope to recover. Please tell me in more detail how Average and Maximum works.

The data before I erased the IF statement is corrupted I can tell but now it looks fine. What are the difference between before and now?

When does Average and Maximum get cleared and ready for a new run?


I hope someone can help me with this. If so I might be able to make an inverse filter to get the original data.

Thank you.

* Last updated by: Bo on 2/23/2010 @ 3:57 AM *

新对话如下:

As far as I understand this program the Average and Maximum functions expect 30min/30sec=60 values before they calculate(only Average), save and clear the accumulator/maximizer. But the function is only run once every 30min because of the IF-statement. This could lead to an average value 60 times too small or a filtering of the data since the average could be calculated based on the 60 last 30min measurements.

This all depends on how these functions work under these not intended conditions. And this is my question. ?

The Average and Maximum value are not the same and they both look about 60 times too small and filtered in a non-trivial way.

新对话如下:

The average function works such that every time the table is called the value is added to the accumulator and the counter is incremented. Then when the table is called and the data interval is reached the accumulator is divided by the counter and that value is written to the table. At this time the accumulator and counter are also reset to zero. The maximum function would work by just keeping track of the maximum value every time the table is called.

It sounds like you might have something else going on. I would expect your program to output the same value for the average and maximum since it is only getting to the table once every data interval.

新对话如下:

"The average function works such that every time the table is called the value is added to the accumulator and the counter is incremented."

That's one way it might work, but, if so, the result would be a good average regardless of how many times the table was called. It may be that the counter is preset to the assumed value, and then whatever is in the accumulator is divided by that fixed number. Or it could be done using a digital filter, i.e., as a running average. Or an array of values might be allocated and processed. The details are in the code, and that's not available to us. Normally the details are not and should not be important, but the OP is trying to recover information after identifying the fixing the problem, if that's possible to do.

We had a similar but different issue once when a pulse count was done in a conditional expression, and not run on every scan as it should have been. By asking for help we eventually were able to understand what was going on, and were able to get some information from the incorrectly processed data.

The documentation, understandably, doesn't go into sufficient detail to clarify these edge cases, but through such cases we might ideally get a better understanding of what, exactly, is going on.

新对话如下:

Bo wrote:

The Average and Maximum value are not the same

Based on the code you posted that cannot be. There must be some other programmatic reason they're not the same. The following program is much like your example.

'CR800 Series Datalogger

'Declare Public Variables
Public batt_volt

'Define Data Tables
DataTable (MyTable,1,-1)
DataInterval (0,15,Sec,10)
Maximum (1,batt_volt,IEEE4,False,False)
Minimum (1,batt_volt,IEEE4,False,False)
Average (1,batt_volt,IEEE4,False)
Sample (1,batt_volt,IEEE4)
EndTable

'Main Program
BeginProg
Scan (1,Sec,0,0)
Battery (batt_volt)
If TimeIntoInterval(0,15,Sec) Then CallTable MyTable
NextScan
EndProg

Because of the if statement causing the CallTable to only be executed once for every table output period at the output time, only one measurement goes into the output processing instructions. With the one second scan rate the program is throwing away 14 out of 15 measurements and all its getting for output is a snapshot of the measurement. With the CallTable below the measurement instruction in the program, which is where it should be, the snapshot is of the measurements taken during the scan that corresponds to the output time. The resulting data file looks like this:

"TOA5","BenchCR800","CR800","1006","CR800.Std.09","CPU:CallTest.CR8","62637","MyTable"
"TIMESTAMP","RECORD","batt_volt_Max","batt_volt_Min","batt_volt_Avg","batt_volt"
"TS","RN","","","",""
"","","Max","Min","Avg","Smp"
"2010-02-24 09:36:45",0,13.58481,13.58481,13.58481,13.58481
"2010-02-24 09:37:00",1,13.57918,13.57918,13.57918,13.57918
"2010-02-24 09:37:15",2,13.58464,13.58464,13.58464,13.58464
"2010-02-24 09:37:30",3,13.58464,13.58464,13.58464,13.58464
"2010-02-24 09:37:45",4,13.58458,13.58458,13.58458,13.58458
"2010-02-24 09:38:00",5,13.55686,13.55686,13.55686,13.55686

You can see that the maximum, minimum, and average are the same as the sample output beacuse only one measurement went into each of them.

* Last updated by: ChipsNSalsa on 2/24/2010 @ 10:25 AM *

新对话如下:

I was looking at the wrong version of the program. I am sorry for this. Now I have all 3 versions that ever run on this station. The version that I explained in the beginning of this thread has only been running for 3 hours and gave the same values for Maximum and Average as you all agree it should.

This explains the wrong multiplier (since this real old version has a wrong multiplier by a factor of 60). The only other difference in this program compared to the earlier described is that DataInterval is set to 5 instead of 30 (DataInterval(0,5,Min,10)).

I still can't explain the different Maximum/Average values and what looks to be filtering of the data. Does this new DataInterval-value change anything? Can this cause the filtering of the data and/or the different Maximum/Average values?

分享到:

原文链接:,转发请注明来源!
海洋仪器网 仪器使用 Maximum/Average_Campbellsci论坛问答
「Maximum/Average_Campbellsci论坛问答」评论列表

发表评论