Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Generating an Avergage during specific hours of the day


Bugman Jul 19, 2019 11:11 AM

Hi All: 

I have code snips below that I hope will accomplish the following, so thus a request to review and confirm. Thanks in advance. 

I'm trying to obtain an average over a two hour time period in a datatable using DataEvent. The goal is to sample waterlevel and a few other parameters on a lake (Waterlog SDI-12 radar) during the calmest periods in the evening (between 2 - 4 AM) and output the data at 4 AM. See code below. Will this accomplish what I seek? I have another data table above this one collecting every 10 minutes and writing hourly data. For this table I want a single record for each day collected from 2-4 AM only. 

DataTable(Table2,True,-1)
DataInterval(2,2,Hr,10)
DataEvent (10,ModSecsWin>=7200,ModSecsWin<14400,10)
Minimum(1,BattV,FP2,False,False)
Totalize(1,Rain_in,FP2,False)
Minimum(1,WaterLevel_Inches,FP2,False,True)
Maximum(1,WaterLevel_Inches,FP2,False,True)
Average(1,WaterLevel_Inches,FP2,False)
StdDev(1,WaterLevel_Inches,FP2,False)

Thanks, 

Dan


smile Jul 20, 2019 05:22 PM

Hi

I would try that.
The boolean variable elab_OK is able to process or no, the table2.

In practice, table2 would come out every 2 hours, but in this way it should go out in memory and work only at 4 o'clock.

Done so the main scan should run every minute, but if it is a problem and it works it can be changed.

DataTable(Table2,elab_OK,-1)
DataInterval(0,2,Hr,0)
Minimum(1,BattV,FP2,False,False)
Totalize(1,Rain_in,FP2,False)
Minimum(1,WaterLevel_Inches,FP2,False,True)
Maximum(1,WaterLevel_Inches,FP2,False,True)
Average(1,WaterLevel_Inches,FP2,False)
StdDev(1,WaterLevel_Inches,FP2,False)
EndTable

........

BeginProg
Scan (1,min,0,0)
PanelTemp (PTemp,60)
Battery (Batt_volt)
If IfTime ( 240,1440,min) Then elab_ok=true
If IfTime ( 241,1440,min) Then elab_ok=false
'Enter other measurement instructions


Bugman Jul 25, 2019 02:58 PM

Thanks, Smile for the tip. I had to play around a bit to get it to work but the key was placing this in the data table calls. Table 1 was hourly, and table 2 properly output data collected between 2-4 AM only, one record per day. I also deleted the DataEvent line in my first post. 

'Call Data Tables and Store Data
CallTable Table1
ModSecsWin=Public.TimeStamp(1,1) MOD 86400
If (ModSecsWin>=7200 AND ModSecsWin<=15000) Then
CallTable Table2
Else
EndIf

NextScan

Log in or register to post/reply in the forum.