fleetz, if I understand this correctly, that's what this does.
If you wanted even numbered days, you'd start off with something like
WHENEVER THE TIME IS 3:00 AM
AND THE DAY OF THE MONTH IS A MULTIPLE OF 2
What the code shown does is start a 24 hour timer at the beginning of each even numbered day. When that timer elapses, you're now at the beginning of the odd day and then the rest of the logic picks up..
At least that's what I get from the original thread on the Elk site that I posted.
Here were my basic requirements:
1. Six Zone Sprinkler control system
2. Ability to modify the timer in each zone without re-writing the rules for same
3. Ability to water on even or odd dasy of the month
4. Ability to incorpoate a rain sensor in the system
I added a M1XOVR Relay Expansion module in metal enclosure in garage to provide NO Contacts for the Valves and started to test my code and finally got it working today but had to really tinker with the rules to get the M1 to do what I wanted.
The Odd/Even day suggestion worked great and the External Rain Sensor can be connected to an un-used Input Zone and programmed for non-Alarm function. My real problem was using the WHEN statements to activate the Valves (Output Relays) in succession because the M1 aparrently looks at every WHEN statement concurrently.
I finally had to set up a loop timer that toggles every 10 seconds as a Zone toggle, then use phantom outputs (as suggested on the ElK Forum to actually control the Valves in sucession.
I used Custom Values for Valve timers so I can change individual zone times without having to modify my rules. By using a different Custom Value for each Zone you can change any zone time without tinkering with the Rules
NOTE: From my testing, The Custom time value appears to be in Seconds.
The 10 second counter also provides some time delay between sucessive valve activation to prevent water hammer.
Below is the Complete 6 Zone Sprinkler Valve Code which I have Tested. (Updated with final code 9/12/2007)
WHENEVER TIME IS 12:01 AM (
Check at 12:01 AM)
AND THE DAY OF THE MONTH IS MULTIPLE OF 2 (
if Even Numbered Day of Month)
THEN TURN OUTPUT 200 ON FOR 23 HOURS 59 MINUTES (
Turn Output 200 flag ON for 23 Hours 59 Minutes- then it turns off )
WHENEVER TIME is 12:01 AM
AND THE DAY OF THE MONTH IS 1 (
use this to catch 1st day of month and insure that output 200 is off)
THEN TURN OUTPUT 200 OFF
WHENEVER EVERY 10 SECONDS (
Establish a counter to trigger each zone in order)
THEN TOGGLE SPRINKLER (Counter 5) BETWEEN 0 and 1
WHENEVER RF KEYFOB BUTTON 4 IS ACTIVATED (
I used an RF Keyfob to test it, an absolute time value goes here)
AND OUTPUT 200 STATE IS OFF
(only run if Odd Numbered day of Month, ie OUTPUT 200 OFF)
AND ZONE 32 IS SECURE (
Only run if rain sensor is not triggered on input zone )
THEN TURN Sprinkler Z1 (Out 17) ON FOR (Cust Set 1), RESTART TIMER IF RUNNING (
Turn on Zone 1 for Custom set time #1)
THEN TURN OUTPUT 201 ON (
Turn on Output 201 as flag for Zone 2)
WHENEVER Sprinkler (Counter 5) CHANGES TO 1 (
When the Sprinkler counter toggles to 1)
AND OUTPUT Output 201 STATE IS ON (
And the Z2 flag is set)
AND Sprinkler Z1 (Out 17) STATE IS OFF (
And Z1 has timed out and turned off)
THEN TURN Sprinkler Z2 (Out 18) ON FOR Sprinkler 1 (Cust Set 1), RESTART TIMER IF RUNNING(
Then turn on Zone 2 Custom Set Time)
THEN TURN OUTPUT 201 OFF (
Then turn 201 flag off)
THEN TURN OUTPUT 202 ON (
Then turn on 202 flag for Zone 3)
WHENEVER Sprinkler (Counter 5) CHANGES TO 1
AND OUTPUT Output 202 STATE IS ON
AND Sprinkler Z2 (Out 18) STATE IS OFF (
And Z2 has timed out and turned off)
THEN TURN Sprinkler Z3 (Out 19) ON FOR Sprinkler 1 (Cust Set 1), RESTART TIMER IF RUNNING(
Then turn on Zone 3 Custom Set Time)
THEN TURN OUTPUT 202 OFF (
Then turn 202 flag off)
THEN TURN OUTPUT 203 ON
WHENEVER Sprinkler (Counter 5) CHANGES TO 1 (
This cycle repeats for as many zones as you need)
AND OUTPUT Output 203 STATE IS ON
AND Sprinkler Z3 (Out 19) STATE IS OFF
THEN TURN Sprinkler Z4 (Out 20) ON FOR Sprinkler 1 (Cust Set 1), RESTART TIMER IF RUNNING
THEN TURN OUTPUT 203 OFF
THEN TURN OUTPUT 204 ON
WHENEVER Sprinkler (Counter 5) CHANGES TO 1
AND OUTPUT Output 204 STATE IS ON
AND Sprinkler Z4 (Out 20) STATE IS OFF
THEN TURN Sprinkler Z5 (Out 21) ON FOR Sprinkler 1 (Cust Set 1), RESTART TIMER IF RUNNING
THEN TURN OUTPUT 204 OFF
THEN TURN OUTPUT 205 ON
WHENEVER Sprinkler (Counter 5) CHANGES TO 1
AND OUTPUT Output 205 STATE IS ON
AND Sprinkler Z5 (Out 21) STATE IS OFF
THEN TURN Sprinkler Z6 (Out 22) ON FOR Sprinkler 1 (Cust Set 1), RESTART TIMER IF RUNNING
THEN TURN OUTPUT 201 OFF (
Since the valves are triggered by outputs)
THEN TURN OUTPUT 202 OFF (
I wanted to make sure they were all OFF )
THEN TURN OUTPUT 203 OFF
(to prevent the possibility of 1 or more remaining on for 2 days)
THEN TURN OUTPUT 204 OFF
THEN TURN OUTPUT 205 OFF
Hope this saves some one some time and loss of hair :huh: