With IPNetPower and TimeIsbetween / TimeIntoIntervall it's easy to turn on and off my modem in cycles.
What if I Want to turn on my Modem on Monday and Friday or even just once a week?
If I get it right I can't just set TimeIntoInterval(9,17,168,Hr) = between 9am and 5 pm once a week/168 hours. Then it would depend on the actual time/ day the logger start up right? If I connect it to the power on Saturday it'll connects every Saturday.
Is there a way to do it?
Best
Pascal
For whom may concern:
When days are used, the first interval starts on a Monday. For example, TimeIsBetween(0,5,7,day) would perform a function every Monday through Friday.
It's in the Online CRBasic help but missing in the CRBasic Editor Help.
Cheers
Hello Pascal: Here an example combining TimeIsBetween and rTime (you can define which date of the week to turn on). Consider that these two functions can be applied to both the cr1000 and cr1000x:
------------------------------------------------------------------
CR1000X Series 'Created by Short Cut (4.4) 'Declare Variables and Units Public BattV Public PTemp_C Public SW12State As Boolean Public Rain_mm 'Variables dim Dim rTime(9) 'declare as public and dimension rTime to 9 Alias rTime(1) = Year 'assign the alias Year to rTime(1) Alias rTime(2) = Month 'assign the alias Month to rTime(2) Alias rTime(3) = Day_month 'assign the alias DOM to rTime(3) Alias rTime(4) = Hour 'assign the alias Hour to rTime(4) Alias rTime(5) = Minute 'assign the alias Minute to rTime(5) Alias rTime(6) = Second Alias rTime(7) = uSecond 'assign the alias uSecond to rTime(7) Alias rTime(8) = WeekDay 'assign the alias WeekDay to rTime(8) Alias rTime(9) = Day_of_Year 'assign the alias Day_of_Year to rTime(9) Units BattV=Volts Units PTemp_C=Deg C Units Rain_mm=mm 'Define Data Tables DataTable(Table1,True,-1) DataInterval(0,60,Min,10) Totalize(1,Rain_mm,FP2,False) EndTable DataTable(Table2,True,-1) DataInterval(0,1440,Min,10) Minimum(1,BattV,FP2,False,False) Totalize(1,Rain_mm,FP2,False) EndTable 'Main Program BeginProg 'Main Scan Scan(1,Sec,2,0) 'Datalogger real time RealTime(rTime()) 'Default CR1000X Datalogger Battery Voltage measurement 'BattV' Battery(BattV) 'Default CR1000X Datalogger Wiring Panel Temperature measurement 'PTemp_C' PanelTemp(PTemp_C,60) 'TE525/TE525WS Rain Gauge measurement 'Rain_mm' PulseCount(Rain_mm,1,P1,1,0,0.254,0) 'SW12 Timed Control 'Turn ON SW12 between 09:00 hours and 17:00 hours 'for monday (rTime(8) = 2) and friday (rTime(8) = 6) If TimeIsBetween(540,1020,1440,Min) AND (rTime(8)=2 OR rTime(8)=6) Then SW12State=True Else SW12State=False EndIf 'Always turn OFF SW12 if battery drops below 11.5 volts If BattV<11.5 Then SW12State=False 'Set SW12_1 to the state of 'SW12State' variable SW12(SW12_1,SW12State,0) 'Call Data Tables and Store Data CallTable Table1 CallTable Table2 NextScan EndProg
----------------------------------------------------------------
I hope it helps you. Regards,
Juan Caycho B.
This post is under review.