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.

Variable DataInterval on CR1000


galexioza Sep 15, 2015 12:54 AM

I am trying to record the Daily table at a different hour depending on whether it is daylight saving time or not. This is something that has always been done for my company's weather station network. With the older CR10s it was possible to record at 9am during standard time and 8am during DST.

The CR200Xs seem to be able to accept and If Else statement for DataInterval (see below). However, when I try this with a CR1000, I get the compile error "DataInterval cannot be used within a conditional statement".

TIntoInt will accept a Constant, but those can only be set once. Is there a way to have a conditional time interval with a CR1000?

DataTable (Daily,True,-1)
If DayOfYear >=270 OR DayOfYear <95 Then
DataInterval(480,1440,Min,10) 'RECORD AT 8AM IF NZDT
Else
DataInterval(540,1440,Min,10) 'RECORD AT 9AM IF NZST
EndIf
Sample (1,SiteID,FP2)
Minimum(1,AirTemperature,FP2,False,False)
Maximum(1,AirTemperature,FP2,False,False)
Average(1,AirTemperature,FP2,False)
Totalize(1,Rain,FP2,False)
Totalize (1,WindRun,FP2,False)
Totalize (1,SolarEnergy,FP2,False)
EndTable

* Last updated by: galexioza on 9/14/2015 @ 6:55 PM *


JDavis Sep 16, 2015 02:39 PM

To accomplish what you are trying to do, it would be simplest to adjust the datalogger clock with daylight savings time. You could either set Loggernet to automatically adjust the datalogger clock or use the DaylightSaving instruction in the datalogger program.


galexioza Sep 16, 2015 09:05 PM

We also record hourly data (which is more important), so the clock is kept on NZST so that there there aren't any duplicated or missing hours in the data. This is important for the plant disease modelling we do. The issue with the Daily data is a side-effect of that.

It would probably be easier to either ignore daylight saving and just have the daily recording an hour off, or change the clock as suggested. However, adjusting the daily hour is something that's been done since before my time, so unless I completely change things, I have to find a way to make it work with the new loggers.

I may have come up with something, though. I have removed the DataInterval instruction from the DataTable setup. Then I have used an If Then statement to call the table based on day number.

'Table 2 - Daily (9am NZST; 8am NZDT)
DataTable (Daily,True,-1) 'No DataInterval; time determined at CallTable
Sample (1,SiteID,FP2)
Minimum(1,AirTemperature,FP2,False,False)
Maximum(1,AirTemperature,FP2,False,False)
Average(1,AirTemperature,FP2,False)
Totalize(1,Rain,FP2,False)
EndTable

'Check whether NZDT or NZST and store Daily table at different hour
If DayOfYear < 95 OR DayOfYear >= 270 Then
If IfTime(480,1440,Min) Then 'Store at 8am if NZDT
CallTable(Daily)
EndIf
Else
If IfTime(540,1440,Min) Then 'Store at 9am if NZST
CallTable(Daily)
EndIf
EndIf

* Last updated by: galexioza on 9/16/2015 @ 3:06 PM *


pokeeffe Sep 16, 2015 09:38 PM

You're on the right track. But if you only call the table once a day, you'll only have one data point in those min/max/avg values. Try calling the table as you were and instead of `True`, provide a boolean variable to the second argument of `DataTable()` then use that boolean to control when a record is written.

FWIW, I don't understand the desire to shift daily values by 1 hour just to compensate for daily savings time. IMO it's best to completely ignore DST.


galexioza Sep 16, 2015 11:11 PM

Thanks. That looks like it will solve my problem.

I agree that adjusting the hour is more hassle than it's worth, but as I said in my previous post, it's something that has always been done and so for now I need to keep it going. The logic is that with the shifted hour, every recording is at 9am NZST. That means that historically, each daily record is exactly 24 hours after the previous one. In practice, I don't think that's important enough to bother, but for now I'm stuck with it.


galexioza Sep 16, 2015 11:24 PM

If anyone in the future is trying to figure out how to do something similar, here is my code that seems to do the trick.

Dim DailyRecord 'Boolean value to determine when Daily table is recorded

'Table 2 - Daily (9am NZST; 8am NZDT)
DataTable (Daily,DailyRecord,-1) 'Table recorded when DailyRecord = True
Sample (1,SiteID,FP2)
Minimum(1,AirTemperature,FP2,False,False)
Maximum(1,AirTemperature,FP2,False,False)
Average(1,AirTemperature,FP2,False)
Totalize(1,Rain,FP2,False)
EndTable

'Main Program
'Main Scan
'Call Data Tables and Store Data

'Check whether NZDT or NZST and store Daily table at different hour
DailyRecord = False
If DayOfYear < 95 OR DayOfYear >= 270 Then
If IfTime(480,1440,Min) Then 'Store at 8am if NZDT
DailyRecord = True
EndIf
Else
If IfTime(540,1440,Min) Then 'Store at 9am if NZST
DailyRecord = True
EndIf
EndIf

CallTable(Daily)

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