Hi Crew,
I'm new to the programming in CR Basic. Please bare with me...
I am trying to write a code that will record rainfall tip data, but also create a cumulative rainfall variable that is a running total. Furthermore, a secondary table for 'calibration mode' and reset function for both. I've used 'TotalRun' to create the total(s), however if I input the number of seconds to record the total over (4 months worth of data per say) I recieve 'out of memory'. Is there a better way to do this?
'Program begins below'
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'Logger Compile Mode'
SequentialMode
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'Variables/Alias/ReadOnly Declarations'
'System Data'
Public SITE_ID As String *30 'Go to Main Program to set ID
Public Pannel_Temp As Float 'Default measurement of logger pannel temperature
Public External_Battery_V As Float ' Defult measurement of external battery voltage
'Air Temperature'
Public AirTemp_DegC As Float
'4-20mA sensor with 2 outputs (Temperature and EC)
Public Electrical_Conductiviy_4_20mA_uS As Float '4-20mA EC Sensor
Public Water_Temperature_4_20mA_DegC As Float ' 4-20mA Temperature Sensor
'SDI-12 Data + Configuration'
Public Sensor_ID As String * 32 'SDI12 sensor identification
Public Water_Level_m As Float 'This is stage height which can be adjusted to match SG readings via 'Water_Level_Offste_m'
Public Water_Level_Offset_m As Float 'Adjustable water level offset (m)
Public Water_Temperature_DegC 'This is the reported water temperature
Public Microsiemens_uS 'This is for an EC measurement
Dim SDI12(3) As Float 'HIDDEN (So the nurmerical display hides the raw data - Raw data still saved to "RAWDATA table"). This declares there is 1 SDI12 sensor (connected to 1 com port) with 3 associated measurements (Temp, WL, WQ)
'Rainfall Data + Rainfall Calibration'
Public Rainfall_mm As Float 'This is just the tip data
Public Rainfall_Cumulative_mm As Float 'This is Rainfall Cumlative (This can be Reset via 'Rainfall_RESET')
Public Rainfall_Calibration_Cumulative_mm As Float
Public Rainfall_RESET As Boolean 'Resets "Rainfall_Cumulative_mm"
Public Rainfall_Calibration_Mode As Boolean
Public Rainfall_Calibration_Timer As Float 'Set Rainfall calibration timer duration in "Rainfall Totalizing, Data Tables and Calibration Mode"
Dim Rainfall_Calibration_AUTOZERO As Boolean
'Alias Declarations'
Alias SDI12(1) = Raw_Water_Level_mm
Alias SDI12(2) = Raw_Water_Temperature_DegC
Alias SDI12(3) = Raw_Microsiemens_uS
'ReadOnly Declarations'
ReadOnly SITE_ID
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'Units Declaration'
Units Electrical_Conductiviy_4_20mA_uS = uS
Units Water_Temperature_4_20mA_DegC = DegC
Units External_Battery_V = V
Units Pannel_Temp = Deg C
Units Raw_Water_Level_mm = mm
Units Water_Level_Offset_m = m
Units Water_Temperature_DegC = Deg C
Units Rainfall_mm = mm
Units AirTemp_DegC = Deg C
Units Rainfall_Calibration_Timer = Sec
Units Raw_Microsiemens_uS = uS/cm
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'Constant Declaration For Site Configuration i.e What gear is on site'
'This is not functional...... yet'
ConstTable (Site_Instrumentation)
Const Rain_Gauge = False
Const LT500 = False
Const Thermocouple = False
Const AD375 = False
EndConstTable
'---------------------------------------------------------------------------
'Other Constant Declarations
Const Timer_Start_Value_Sec = 1800
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
DataTable(Reported_Data,True,-1)
DataInterval(0,10,Min,0)
Sample (1,Water_Level_m,FP2)
Sample (1,Water_Temperature_DegC,FP2)
Sample (1,AirTemp_DegC,FP2)
Average (1,Electrical_Conductiviy_4_20mA_uS,FP2,False)
Average (1,Water_Temperature_4_20mA_DegC,FP2,False)
EndTable
DataTable (RAW_Data,True,-1)
DataInterval(0,10,Min,0)
Sample (1,Raw_Water_Level_mm,FP2)
Sample (1,Raw_Water_Temperature_DegC,FP2)
EndTable
DataTable (Reported_RF_Data,(Rainfall_mm >= 0.2),1000)
DataInterval (0,2,sec,0)
Sample (1,Rainfall_mm,FP2)
Sample (1,Rainfall_Cumulative_mm,FP2)
EndTable
DataTable (Calibration_RF_Data,(Rainfall_mm >= 0.2),500)
DataInterval (0,2,sec,0)
Sample (1,Rainfall_mm,FP2)
Sample (1,Rainfall_Calibration_Cumulative_mm,FP2)
EndTable
DataTable(SystemData,True,-1)
DataInterval(0,1,Hr,10)
Minimum(1,External_Battery_V,FP2,False,False)
Average(1,Pannel_Temp,FP2,False)
EndTable
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
'Main Program
BeginProg
'---------------------------------------------------------------------------
PreserveVariables
'Main Scan
Scan(1,Sec,0,0)
'Site Identification
SITE_ID = "10 Jessamine Court Rain Gauge"
'Default CR800 Datalogger Battery Voltage measurement 'BattV'
Battery (External_Battery_V)
'Default CR800 Datalogger Wiring Panel Temperature measurement 'PTemp_C'
PanelTemp (Pannel_Temp,_50Hz)
'Generic Voltage Diff measurement 'AirTemp'
TCDiff (AirTemp_DegC,1,AutorangeC,3,TypeT,Pannel_Temp,True ,0,250,1.0,0)
'---------------------------------------------------------------------------
'Rainfall Pulse measurement -
PulseCount (Rainfall_mm,1,1 ,2,0,0.2,0)
'Normal Rainfall Operation
If Rainfall_Calibration_Mode = False Then TotalRun (Rainfall_Cumulative_mm,1,Rainfall_mm,90000000,Rainfall_RESET)'
If Rainfall_Calibration_Mode = False Then CallTable Reported_RF_Data
If Rainfall_Cumulative_mm = 0 Then Rainfall_RESET = False
'Rainfall Calibration Mode
If Rainfall_Calibration_Mode = True Then TotalRun (Rainfall_Calibration_Cumulative_mm,1,Rainfall_mm,18000,Rainfall_Calibration_AUTOZERO = True)
If Rainfall_Calibration_Mode = False Then Rainfall_Calibration_Timer = Timer_Start_Value_Sec
If Rainfall_Calibration_Mode = True Then Rainfall_Calibration_Timer = Timer_Start_Value_Sec - Timer (1,Sec,0)
IF Rainfall_Calibration_Mode = True Then CallTable Calibration_RF_Data
If Rainfall_Calibration_Timer = 1 Then Rainfall_Calibration_AUTOZERO = True
If Rainfall_Calibration_Timer = 0 Then Rainfall_Calibration_Mode = False
If Rainfall_Calibration_Timer = 0 Then Timer (1,Sec,3)
If Rainfall_Calibration_Timer = 0 Then Rainfall_Calibration_AUTOZERO = False
If Rainfall_Calibration_Mode = False Then Timer (1,Sec,3)
If Rainfall_Calibration_Timer = Timer_Start_Value_Sec Then Rainfall_Calibration_AUTOZERO = True Else Rainfall_Calibration_AUTOZERO = False
If Rainfall_Calibration_AUTOZERO = True Then Rainfall_Calibration_Cumulative_mm = 0
'---------------------------------------------------------------------------
'Moved Sensor Readings to Slow Sequence to update every 60secs
NextScan
SlowSequence
Scan (60,Sec,3,0)
'---------------------------------------------------------------------------
'4-20mA Sensor Read EC
VoltDiff (Electrical_Conductiviy_4_20mA_uS,1,mV2500,1,True ,0,_50Hz,43.75,-17500)
'4-20mA Sensor Read Water Temp
VoltDiff (Water_Temperature_4_20mA_DegC,1,mV2500,2,True,0,_50Hz,0.03125,-12.5)
'---------------------------------------------------------------------------
'SDI-12 Sensor query of ID
SDI12Recorder(Sensor_ID,1,"0","I!",1,0,-1)
'SDI-12 Sensor measurements 'Raw_Water_Level', 'Water_Temperature' and 'Left_Blank_For_WQ_Readings_uS'
SDI12Recorder(SDI12(),1,"0","M!",1,-1)
'Water level offset
Water_Level_m = (Raw_Water_Level_mm/1000) + (Water_Level_Offset_m)
'Water Temperature
Water_Temperature_DegC = Raw_Water_Temperature_DegC
'Water Quality Measurment
Microsiemens_uS = Raw_Microsiemens_uS + 99
'---------------------------------------------------------------------------
'Call Data Tables for Non Rainfall Tables
CallTable Reported_Data
CallTable Raw_Data
CallTable SystemData
NextScan
'---------------------------------------------------------------------------
'---------------------------------------------------------------------------
EndProg
Thank you!
Please ignore this. Figured it out - I was making it way harder than it had to be.
Missing this simplification:
"Rainfall_Cumulative_mm = Rainfall_mm + Rainfall_Cumulative_mm"
TotalRun not required.... solving all my issues.
The maximum value of the instruction I tried was '33554428'
"TotalRun (Rainfall_Cumulative_mm,1,Rainfall_mm,33554428,Rainfall_RESET)"
This instruction in the program did not report an error, but whether the specific use needs to be tested.
Of course, it's easier to use summation.