PDA

View Full Version : if statement


tinnghe
02/05/2009, 11:54 AM
can i right an if statement like this

if A7=ON
then
A8=OFF

A7 OSC 2/2

something like this so i can have it oscallation and turn off if A7 is on and vice versa

kenargo
02/05/2009, 04:30 PM
Yes, you want your 'if timer' after the OSC command like this:

OSC 002/002 ON/OFF Then A7 ON
If Timer A7 = On Then A8 OFF
If Timer A7 = Off Then A8 ON

A7 and A8 need to be replaced with the names and not addresses but you should get the idea...

RussM
02/05/2009, 10:25 PM
Would this accomplish the same thing with 1 less line?

OSC 002/002 ON/OFF Then A7 ON
OSC 002/002 ON/OFF Then A8 OFF

kenargo
02/06/2009, 12:15 AM
Yes, except using 2 OSC it is possible that the pumps will get out of sync and you can end up with them on at the same time and off at the same time. If you are OK that this can happen then use the 2 lines of code but if you want to guarantee that 1 is on while the other is off then the 3 lines is the solution.

d0ughb0y
02/06/2009, 11:24 AM
though I cannot say for sure that two osc can end up both on and both off state forever cannot happen, I have not seen that situation happen.

what I have observed is if I had (this will put d1 on d2 off, then both d1 and d2 on, then d1 off and d2 on)
osc 5/10 on/off then d1 on
osc 5/10 on/off then d2 off

no matter what I do to manually turn d1 or d2 on or off to get them out of sync, at the top of the hour, it will go back to the correct cycle of d1 on and d2 off, regardless of where in the cycle it was before the top of the hour. Or say if I start the program at 6:03, and for 15 minute cycles, the 5th cycle will be at 7:03, but I notice it will start a new cycle at 7:00 at the correct initial state specified in the osc command.

likewise, if d1 is in auto, and say 3 minutes into the cycle, then I put d2 into auto, d2 will not run the off part for 5 minutes, but rather just for 2 minutes, to sync up with the running d1 cycle. this I think is a good thing. I have since went back to the two line method for simplicity.

kenargo
02/06/2009, 12:06 PM
I can say for certain that they will remain out of sync forever or until the program is modified/reset, power out, etc. Basically if you do something that restarts the program then they will resync. Once you use manual control on one of the timers they will be out of sync until something happens to reset the program. Making a change to the program is one way to reset the program but if you don't tinker then the timers will remain out of sync for a very long time. That said; if minor out of sync isn't an issue then use 2 lines; you could use RND (over OSC) and that would lessen the chance to be out of sync as each cycle completion will generate a new value for the next on. It really comes down to what you want to accomplish; if you want to 'guarantee' a behavior then use the 3 line model.

d0ughb0y
02/06/2009, 03:30 PM
<a href=showthread.php?s=&postid=14332729#post14332729 target=_blank>Originally posted</a> by kenargo
I can say for certain that they will remain out of sync forever or until the program is modified/reset, power out, etc. Basically if you do something that restarts the program then they will resync. Once you use manual control on one of the timers they will be out of sync until something happens to reset the program. Making a change to the program is one way to reset the program but if you don't tinker then the timers will remain out of sync for a very long time. That said; if minor out of sync isn't an issue then use 2 lines; you could use RND (over OSC) and that would lessen the chance to be out of sync as each cycle completion will generate a new value for the next on. It really comes down to what you want to accomplish; if you want to 'guarantee' a behavior then use the 3 line model.

I am curious if other can do this test.
I am certain that come top of the hour, everything was back in sync. I tested several times.
And I know when I start my 15 minute cycle at an odd minute (say at 1:13), I can come back later and can see the devices cycle on the quarter hour (2:00, 2:15, 2:30, etc).
perhaps curt can answer.

kenargo
02/06/2009, 04:59 PM
My test was over a number of days and the pumps never came back into sync.

Doing a search there are a number of replies from Curt, 1 below (Note: there where additional program lines for lighting control that I edited out to keep the reply focused to just OSC


Do this and they are guaranteed always be in the opposite state of each other.

OSC 015/015 M Then PH1 ON
If Timer PH1 = ON Then PH2 OFF
If Timer PH1 = OFF Then PH2 ON

d0ughb0y
02/06/2009, 05:21 PM
<a href=showthread.php?s=&postid=14334833#post14334833 target=_blank>Originally posted</a> by kenargo
My test was over a number of days and the pumps never came back into sync.

Doing a search there are a number of replies from Curt, 1 below (Note: there where additional program lines for lighting control that I edited out to keep the reply focused to just OSC

thats not quite what I was looking for from Curt. To say "to be guaranteed it will be in opposite state" is not the same thing as "it will eventually sync to the correct state".

It won't hurt for someone else to verify. I know before you said you are absolutely certain it was impossible for If time to end up in UNK state, but later you see that it can. :)