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.

CR800 Timer Based Program


SEMN Dec 10, 2012 08:35 PM

I am trying to write a CR800 program that will control an ISCO sampler on a time based routine. In the simple language below, Stage_avg = water level and Act_stage is the activation stage (level I want to start the routine). I want to pulse the sampler immediately when the threshold is crossed, and every 60 minutes after Stage_avg >= Act_stage. This needs to continue for 96 hours. At this point, the sample routine needs to end.

The language below is how it should work, but I know I have a ways to go to get it to work on the datalogger.

'ETI Sampling Routine
If (Stage_avg >= Act_stage) Then
PortSet(2, 1)
Delay(0,1,Sec) Then
Start a timer, and pulse every 60 minutes 95 additional times
EndIf

Does anyone have experience with a routine like this? Any help would be appreciated.

Thanks


Gav Dec 13, 2012 11:24 PM

Something Like this...

Public StageTimerActive As Boolean
Public ISCO_Pulse_Counter
Const ISCO_TIMER = 1
Public ISCODelayTime

If NOT StageTimerActive Then
If (Stage_avg >= Act_stage) Then
'pulse the port
WriteIO (&B10,&B10) 'same as PortSet(2,1), but for conditional control
Delay(1,1,Sec)
WriteIO (&B10,&B00) 'same as PortSet(2,0), but for conditional control
'Increment Isco pulse counter
ISCO_Pulse_Counter += 1
'reset the Timer
Timer(ISCO_TIMER,Sec,2)
'Start the Timer
'Activate Stage Timer
StageTimerActive = True
EndIf
Else ' Once the Stage Timer is activated
'Read Timer
ISCODelayTime = Timer(ISCO_TIMER,Sec,4)
'After 1 hour,
If ISCODelayTime > 3600 Then
'pulse the port
WriteIO (&B10,&B10) 'same as PortSet(2,1), but for conditional control
Delay(1,1,Sec)
WriteIO (&B10,&B00) 'same as PortSet(2,0), but for conditional control
'Increment Isco pulse counter
ISCO_Pulse_Counter += 1
'reset the Timer
Timer(ISCO_TIMER,Sec,2)
EndIf
EndIf

'If the water level falls below stage level, stop pulsing
If (Stage_avg < Act_stage) Then
'Clear the StageTimerActive (stops hourly pulsing continuing)
StageTimerActive = False
'Stop and clear the timer
Timer(ISCO_TIMER,Sec,3)
EndIf



SEMN Dec 14, 2012 04:28 PM

Gav,

Thank you for the help. With a few modifications, I was able to turn the code you provided into what I needed. Thanks again.

The next challenge with the program as I have it written is how to adjust stage (wire weight to instrument/data logger). The way I have this written, my stage adjust (STGADJ) is in the Const Table. This allows for keypad changes to the offset to correct stage at the site. In order for this to take effect, it will compile the program. This will reset my timer and mess up by sampler.

Is there another way to have access to an offset that will not affect the timer? I copied my program below.

Thanks

'CR800
'Declare Constants
ConstTable
Const Act_stage = 0.9
Const STGADJ = 0
Const ISCO_TIMER = 1
Const ETI_Interval = 3600 'seconds
Const ETI_Pulses = 96 '1 sample per hour * 96 times = 4 day ETI
EndConstTable

'Declare Variables and Units
Public Batt_Volt
Public Cr800Temp_C
Public CS450_Stg
Public SFSTG_ft
Public Stage_avg
Public CS450(2)
Public CS650(3)
Public StageTimerActive As Boolean
Public ISCO_Pulse_Counter
Public ISCODelayTime

Alias CS450(1)=CS450_PS
Alias CS450(2)=CS450_WTemp

Alias CS650(1)=VolWatCon
Alias CS650(2)=ElecCondu
Alias CS650(3)=SoiltTemp

Units Batt_Volt=Volts
Units Cr800Temp_C=Deg C
Units CS450_Stg=feet
Units SFSTG_ft=feet
Units Stage_avg=feet
Units VolWatCon=m^3/m^3
Units ElecCondu=ds/m
Units SoiltTemp=C

Dim LogerTime(10)
'1 - Year, 2 - Month, 3 - Day of Month, 4 - Hour, 5 - Minute
'6 - Second, 7 - Microsecond, 8 - Day Of Week (Sunday = 1), 9 - Day of Yea

'Define Data Tables
DataTable(SR3_ETI_FLOW10,True,-1)
DataInterval(0,10,Min,10)
Average (1,Cr800Temp_C,FP2,False)
Average(1,SFSTG_ft,IEEE4,False)
Average(1,Stage_avg,IEEE4,False)
Average (3,CS650(),FP2,False)
Minimum(1,Batt_Volt,FP2,False,False)
EndTable

DataTable (ETI_SampleOut, 1, -1)
DataInterval (0, 0, Sec, 0)
Sample (1, ISCO_Pulse_Counter, FP2)
EndTable

'Main Program
BeginProg
Scan(60,Sec,1,0)
SW12 (1 )
'Default Datalogger Battery Voltage measurement Batt_Volt:
Battery(Batt_Volt)
'Wiring Panel Temperature measurement PTemp_C
PanelTemp(Cr800Temp_C,_60Hz)
'CS650 Soil Moisture Probe Generic SDI-12 Sensor measurements VolWatCon, ElecCondu, SoiltTemp,
SDI12Recorder(CS650(),3,"0","M!",1,0)
'CS450 Pressure Transducer Generic SDI-12 Sensor measurements
SDI12Recorder (CS450,1,0,"M!",1.0,0)
'Convert PS to Stage (ft)
CS450_Stg=(CS450_PS)*2.31

'Allows for stage offset to be adjusted
SFSTG_ft= (CS450_Stg) + (STGADJ)
'Calculate 15 minute average stage to activate samplers
AvgRun (Stage_avg,1,SFSTG_ft,10)

'ETI Sampling Routine
If NOT StageTimerActive Then
If (Stage_avg >= Act_stage) Then
'pulse the port
WriteIO (&B10,&B10) 'same as PortSet(2,1), but for conditional control
Delay(1,1,Sec)
WriteIO (&B10,&B00) 'same as PortSet(2,0), but for conditional control
'Increment Isco pulse counter
ISCO_Pulse_Counter = 1
CallTable ETI_SampleOut
'reset the Timer
Timer(ISCO_TIMER,Sec,2)
'Start the Timer
'Activate Stage Timer
StageTimerActive = True
EndIf

Else ' Once the Stage Timer is activated
'Read Timer
ISCODelayTime = Timer(ISCO_TIMER,Sec,4)
'After 1 hour,
If ISCODelayTime > ETI_Interval Then
'pulse the port
WriteIO (&B10,&B10) 'same as PortSet(2,1), but for conditional control
Delay(1,1,Sec)
WriteIO (&B10,&B00) 'same as PortSet(2,0), but for conditional control
'Increment Isco pulse counter
ISCO_Pulse_Counter = ISCO_Pulse_Counter+ 1
CallTable ETI_SampleOut
'reset the Timer
Timer(ISCO_TIMER,Sec,2)
EndIf
EndIf

'AFter desired number of samples collected, stop pulsing
If (ISCO_Pulse_Counter >= ETI_Pulses) Then
'Clear the StageTimerActive (stops hourly pulsing continuing)
StageTimerActive = False
'Stop and clear the timer
Timer(ISCO_TIMER,Sec,3)
ISCO_Pulse_Counter = 0
ISCODelayTime = 0
EndIf

CallTable(SR3_ETI_FLOW10)

NextScan
EndProg


MattR Apr 27, 2023 01:30 PM

This post is under review.

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