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 SW12 control


sonye Feb 15, 2013 02:13 PM

I want to turn on and off the SW12 switch with 20/20 minute cycle. Is this will continuously work? I want to make sure about this code.

BeginProg
Scan (1,Sec,0,0)
If TimeIntoInterval(0,40,Min) Then SW12(1)
If TimeIntoInterval(20,40,Min) Then SW12(0)
NextScan
EndProg


Sam Feb 15, 2013 04:09 PM

The code you posted will definitely work.
It shows the simplicity of using TimeIntoInterval.


Following is an alternative way.
With this method, even if you happen to skip a scan or happen to go through a power cycle / reboot, the logger will still get a chance to turn SW12V high during the first 20 min of a 40 min cycle and low during the last 20 min of a 40 min cycle.

Public SecIntoDay As Long
Public TwentyMin = 20*60
Public FortyMin = 40*60
BeginProg
Scan (1,Sec,0,0)
SecIntoDay = Public.Timestamp(4,1)
If (SecIntoDay MOD FortyMin) < TwentyMin Then
SW12 (1 )
Else
SW12(0)
EndIf
NextScan
EndProg

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