Page 1 of 1

Help

Posted: Thu Oct 15, 2015 12:00 pm
by mrwlf
Hi,
i need help coding my zeolite reactor on port 2:

I need to switch on port 2 at 11.00 and 23.00 for 2 minutes then OFF for the rest of the day.

Thanks for your help

Re: Help

Posted: Thu Oct 15, 2015 12:20 pm
by rimai
Try this:

Code: Select all

ReefAngel.Relay.Set(Port2,(now()-3600)%43200<120);

Re: Help

Posted: Fri Oct 16, 2015 2:58 am
by mrwlf
Thanks Roberto. How to set the interval starting at 23.00?

Re: Help

Posted: Fri Oct 16, 2015 9:26 am
by rimai
All times are based on midnight, so I decreased 3600 seconds from it.

Re: Help

Posted: Mon Oct 19, 2015 1:06 pm
by dedvalson
Hi,

That seems like a pretty arcane way to do this.

How about:

Code: Select all

ReefAngel.Relay.Set (Port2, (hour() == 11 || hour() == 23) && minute() < 2);
I think that would be simpler and is certainly more readable.

Don

Re: Help

Posted: Mon Oct 19, 2015 1:09 pm
by rimai
There you go :)
That's why it is good to have a second eye on things.. lol

Re: Help

Posted: Tue Oct 20, 2015 3:44 am
by lnevo
dedvalson wrote:Hi,

That seems like a pretty arcane way to do this.

How about:

Code: Select all

ReefAngel.Relay.Set (Port2, (hour() == 11 || hour() == 23) && minute() < 2);
I think that would be simpler and is certainly more readable.

Don
Its certainly a good way, but not the best long term and for many who do time based operations can lead to the wrong actions. Yes it is more readable, but its less flexible for many of the repeat scheduling people want to do. The way I try to explain the previous usage would be

(now() + offset) % repeat < runtime

Hope that helps clarify. Fun part of coding is coming up with different ways to accomplish things. Always good to see different ideas.