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.

24 hour running total


tcrabtree Jun 5, 2013 08:08 PM

Hello all.
I'm monitoring rainfall and have a question about the 24 hour running total option. Will this option, by default, give me results from any consecutive 24 hour period, or just from start time to end time? I need to know when >=0.30" occurs during any consecutive 24 hours, not from midnight to midnight. I've just began using Loggernet and RTMC so please forgive my ignorance.

Here's my program:
'CR200/CR200X Series
'Created by Short Cut (2.9)

'Declare Variables and Units
Public BattV
Public Rain_in
Public Tot24

Units BattV=Volts
Units Rain_in=inch

'Define Data Tables
DataTable(Rainfall,True,-1)
DataInterval(0,10,Min)
Totalize(1,Rain_in,False)
Sample(1,BattV)
Sample(1,Tot24)
EndTable

'Main Program
BeginProg
'Main Scan
Scan(1,Sec)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Generic Tipping Bucket Rain Gauge measurement 'Rain_in'
PulseCount(Rain_in,P_SW,2,0,0.01,0)
'24 hour running total calculation 'Tot24'
Tot24=Tot24+Rain_in
If IfTime(0,1440,Min) Then Tot24=0
'Call Data Tables and Store Data
CallTable(Rainfall)
NextScan
EndProg


aps Jun 6, 2013 03:58 PM

That program will not do what you wish as the total is only reset once per day at midnight.

If the intention is that at any time you wish to be able to connect to the logger and see if the total in the past 24 hours timed from that instant back in time, you will need to make a compromise in some way as the CR200 does not have enough memory or speed to hold 24 hours worth of one second data in a rolling buffer which is processed every second to work out a total.

If you could slow things down a bit and store say ten minute rain totals (as the program does) then process those every ten minutes to get the last 24 hours total that is more acheivable.

So is a ten minute update to the previous 24 hours rain total acceptable? If not it should be possible to pull this down to one minute updates but at some cost of long term storage.

An alternative approach is to make this calculation in RTMC Pro, which is just possible I think, but the problem with that is you will loose accuracy in the total if the comms breaks down to the datalogger, i.e. some of the data is missed.

* Last updated by: aps on 6/6/2013 @ 9:59 AM *


tcrabtree Jun 6, 2013 05:21 PM

One hour resolution is plenty, I definitely don't need 1 second resolution. I plan to have a table store records hourly and keep at least a few days worth of records. The calculation can be made from this table. I just not sure how to go about it. I would like an alert when .3" is reached in any 24 hour period, but I wouldn't necessarily want to be alerted for each hour as long as that condition is still true.


mjb Jun 7, 2013 03:22 AM

Either use GetRecord() in a loop to pull out the last 24 values, or store the values in an array as you measure them.

Calculate your condition each hour, and have a boolean variable that you can store your condition. If condition is true, but not the stored condition, perform your alerting.


aps Jun 7, 2013 11:46 AM

Something like this should do what you want:

Public BattV
Public Rain_in
Public Rainalarm
Public Tot24
Dim work_tot, i

Units BattV=Volts
Units Rain_in=inch

'Define Data Tables
DataTable(Rainfall,True,-1)
DataInterval(0,60,Min) 'Store hourly
Totalize(1,Rain_in,False)
Sample(1,Tot24)
Sample(1,BattV)
EndTable

'Main Program
BeginProg
'Main Scan
Scan(1,Min)
'Default Datalogger Battery Voltage measurement 'BattV'
Battery(BattV)
'Generic Tipping Bucket Rain Gauge measurement 'Rain_in'
PulseCount(Rain_in,P_SW,2,0,0.01,0)
'Call Data Tables AND Store Data
CallTable(Rainfall)

'24 hour running total calculation
'Add the last 24 hourly values together into a working total
'The values are pulled from the Rainfall table that holds hourly totals
work_tot=0
For i=1 To 24
work_tot= work_tot + Rainfall.Rain_in_Tot(1,i)
Next i
'Copy this to the displayed value
Tot24=work_tot
'Set an alarm value
Rainalarm = Tot24 > 0.3
'Optionally set a control port high based on the alarm>
PortSet (C1,Rainalarm )
NextScan
EndProg

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