I can't work out whether it is possible to perform 2 levels of averaging. I would like to read a sensor (anemometer - pulse count) every 1 second, save this data to a table, then average it to 3 sec and save this to another table (that records 10 minute statistics of the 3s data). In other words I want to save 1s data, and also 10 minute statitistics of 3s data. Does anyone know how to do this?
Two ways (there's probably more):
Set up two tables - one set up for 1 second output and another for 3 second output of the same variable (is there a reason you don't want to do this?).
Use tablename.fieldname syntax to pull out the value you want from the 1 second table and store it into a 3 second table.
Hope this helps,
Dana
Can I have a table that reads another table? I need a table that stores 10min data, being the average, max, min, and std deviation of the 3s data. And the 3s data needs to be the average of the 1s data. At the moment I am using the 1s data instead, as below:
DataTable(CH01,True,13400)
DataInterval(0,10,Min,1)
Average(1,Spd1,FP2,False)
Maximum(1,Spd1,FP2,False,False)
Minimum(1,Spd1,FP2,False,False)
StdDev(1,Spd1,FP2,False)
EndTable
DataTable(CH01_HF,True,-1)
DataInterval(0,1,Sec,1)
CardOut(0,-1)
Sample(1,Spd1,FP2) 'Wind speed (sampled in main scan, since can't read pulses in subscan)
EndTable
BeginProg
Scan(1,Sec,1,0)
PulseCount(Spd1,1,1,2,1,0.1,0)
CallTable(CH01_HF)
CallTable(CH01)
NextScan
EndProg
It seems that you want to obtain the max. wind speed from 3 sec. averages following the IEC standarts.
Then you only need to make a running average of 3sec. with the 1 sec. samples and store it in a variable.
Then you will be able to obtain all the statistic that you want from this variable in the 10minutes data table.
Best regards.
Juan.
Can I have a table that reads another table?
The tablename.fieldname syntax will read values from another table. For instance,
NewVar = CH01_HF.Spd1(1,1)
will put the Spd1 sample from table CH01_HF into NewVar.
Refer to the CRBasic help.
This syntax can also be used in an output instruction. For example:
Sample(1,CH01_HF.Spd1(1,1),FP2)
Make sure you have the most recent precompiler and OS (can be downloaded from our web site). If I recall correctly, there was one version of the precompiler that would crash with this syntax in a data table.
Regards,
Dana
To reiterate the advice given above. If you are after windspeed statistics where you need max (for gusts), min etc of 3 sec averages as per WMO and IEC requirements you should be using the running average instruction not doing 3 sec block averages using data tables. (The WMO actually requires 4 Hz measurements too, but it does not make much difference running at 1 sec especially for low frequency pulse output sensors).
To do the running average just define a new variable to hold the average, e.g. Spd1_3s and include this instruction after the pulse count instruction:
AvgRun (Spd1_3s,1,Spd1,3)
Then use Spd1_3s as the input variable in the stats instructions in the 1 sec table.
Andrew
Thanks. It sounds like the AvgRun is a good solution. But I presume that I must only call the 10min datatable every 3s not every scan (1s), otherwise the table will receive 3s running averages every 1s. I guess I can do that with an If statement to only call the datatable if the number of seconds is a multiple of 3, ie
If (RTime(6) MOD 3)=0 Then CallTable(CH01)
Or maybe use a trigger in the table?
No, if you want to capture the maximum 3 second wind gust you should call the table every second, i.e. every time the 3 s average is updated. Otherwise you only stand a one in three chance of capturing the true maximum or minimum.
Calling the table every sec will also give the other statistics correctly, e.g. average, standard deviation etc, as most international meteorological guidelines recommend these are also based on the 3 sec average windspeed ideally updated at 4 Hz, but 1 Hz is good enough for low frequency pulse output sensors.
Hi,
I am interested in following up on this thread as I am just learning CRBasic and am trying to port an existing 21x program (that is not my own) to a CR850. Replicating the following fields in the 15 minute output block are giving me some trouble:
+ Maximum mean running 3-second gust: m/s
+ Time of Gust: HHMMSS
+ Maximum avg 1-minute horizontal wind speed: m/s
+ Unit vector mean horizontal wind direction during maximum 1-minute wind speed: degrees
+ Mean Standard Deviation of Relative Humidity from 1-minute values
I see how the 3-second gust can be obtained using the running average instruction, but am wondering what the best approach is to obtaining the other parameters. Would I use a scratch array to do this, or possibly use a hidden 1 minute table that I would extract values from (as indicated Dana above) and then reset every 15 minutes to avoid filling up the data logger?
Any comments, or suggestions would be greatly appreciated.
Thanks,
- Brendan