My standard program with the other O/S's output a maximum wind speed hourly. I also output the wind direction of the max wind speed using the "sample on Max" instruction which is not available with the 200's.
Am I out of luck or can I find out how many records back the max speed occurred (which would also allow me to retrieve the wind direction) ? Has anyone found a (better) solution? I used that instruction for a few other outputs also (ie. max 10 minute mean wind speed in the previous hour(with direction)). Any advice would be much appreciated
Thanks
Mike
I haven't tried this, but you could perhaps set up a special table that uses a condition for its trigger and the trigger is that the variable has a new maximum. Just store a few records and then retrieve the last record (or a fieldname from that record) at the end of the hour (using GetRecord or TableName.Fieldname). Something like:
Public Value, Max, StoreRec as Boolean
DataTable (MaxTable,StoreRec,5)
Sample(1,max)
EndTable
'and in the body of the program
If Value > Max Then
Max = Value
StoreRec=True
Else
StoreRec=False
EndIf
Like I say, I haven't tried it but it seems like, logically, it would work (unless my logic needs more sugar today!)
Hope this helps to spark some ideas...
Dana
Mike,
As you noted the CR200 instruction set is limited compared to the CR800 / CR1000 series. You will need to keep up with the values for max windspeed and associated direction manually, especially if you are reading your sensors faster than once per minute; The CR200 has a minimum data interval for tables of 1 min. Similarly to Dana's suggestion:
'not tested in CRBasic or CR200
'variables
public ws, wd
public maxspd, maxdir
'save data based on an hour of observations
DataTable (myTable,True,-1)
DataInterval (0,60,min)
Sample (1,maxspd)
Sample (1,maxdir)
EndTable
BeginProg
Scan (5,Sec) 'interval must divide evenly into 60 min
'if top of hour then reset max values to nonsense
'will find new max values for this hour
if iftime(0,60,min) then
maxspd = -999
maxdir = -999
endif
'read wind speed and direction to ws and wd, respectively
'determine if current ws is the fastest
seen this hour. if so save it and associated dir away
if ws > maxspd then
maxspd = ws
maxdir = wd
endif
calltable myTable
NextScan
EndProg
I took Sam's example and modified it slightly:
Public ws, wd
Public maxspd, maxdir
DataTable(HourlyTable,True,-1)
DataInterval(0,1,hr)
Sample(1,maxspd)
Sample(1,maxdir)
EndTable
BeginProg
Scan (5,Sec)
If ws>=maxspd OR IfTime(5,3600,Sec) Then
maxspd=ws
maxdir=wd
EndIf
CallTable HourlyTable
NextScan
EndProg
The primary differences being that you don't want to clear the tracking variables until the next scan after the hour and also when you clear the tracking variables you may as well make the current real time values the new max and sample on max for the hour because they are.
Thank you to Dana, Sam and ChipsNSalsa
I've just returned from a long maint tour of our stations an d was happy to see such an effort put forth by all of you. Thank you once again. When I complete my solution (I'll try a few methods) I'll post them. This is very good stuff for people like me who, just as they are becoming experts with Edlog and developing a wicked data standard....along comes CRBasic with all its flex.
Thanks again
Mike