Page 1 of 1

a pump on for 3 hours then off for 3 hours?

Posted: Fri Jun 19, 2015 5:10 pm
by MDB1029
I am still no good at the code writing, I think this will work but not sure.

Code: Select all

ReefAngel.Relay.On(Port8);
if (hour()==03 && minute()<180) ReefAngel.Relay.Off(Port8);
if (hour()==09 && minute()<180) ReefAngel.Relay.Off(Port8);
if (hour()==15 && minute()<180) ReefAngel.Relay.Off(Port8);
if (hour()==21 && minute()<180) ReefAngel.Relay.Off(Port8);
Any thoughts or suggestions? Am i totally wrong?

Re: a pump on for 3 hours then off for 3 hours?

Posted: Fri Jun 19, 2015 5:44 pm
by rimai
no.
minute() is how many minutes in an hour. So, max is 59.

Re: a pump on for 3 hours then off for 3 hours?

Posted: Fri Jun 19, 2015 7:46 pm
by MDB1029
Am i still off?

Code: Select all

ReefAngel.Relay.On(Port8);
if (hour()==03 && hour()<3) ReefAngel.Relay.Off(Port8);
if (hour()==09 && hour()<3) ReefAngel.Relay.Off(Port8);
if (hour()==15 && hour()<3) ReefAngel.Relay.Off(Port8);
if (hour()==21 && hour()<3) ReefAngel.Relay.Off(Port8);
If so, i may need a hint

Re: a pump on for 3 hours then off for 3 hours?

Posted: Fri Jun 19, 2015 8:07 pm
by rimai
That's going to turn port 8 off for 3 minutes at 3,9,15 and 21 hours.
This is an easy to understand code:

Code: Select all

ReefAngel.Relay.On(Port8);
if (hour()==03) ReefAngel.Relay.Off(Port8);
if (hour()==04) ReefAngel.Relay.Off(Port8);
if (hour()==05) ReefAngel.Relay.Off(Port8);
So, it would turn off for the full hour of hour 3,4 and 5.
Then you can go and repeat for the other hours you would like.
But, a more compact code that would do what you want would be:

Code: Select all

ReefAngel.Relay.Set(Port8, now()%21600<10800);
The code above would make port 8 turn on for 3 hours and off for 3 hours. Just a little bit harder to understand without some math knowledge behind it, but both would work for what you want. Different ways of coding.

Re: a pump on for 3 hours then off for 3 hours?

Posted: Sat Jun 20, 2015 6:32 pm
by MDB1029
rimai wrote:That's going to turn port 8 off for 3 minutes at 3,9,15 and 21 hours.
This is an easy to understand code:

Code: Select all

ReefAngel.Relay.On(Port8);
if (hour()==03) ReefAngel.Relay.Off(Port8);
if (hour()==04) ReefAngel.Relay.Off(Port8);
if (hour()==05) ReefAngel.Relay.Off(Port8);
So, it would turn off for the full hour of hour 3,4 and 5.
Then you can go and repeat for the other hours you would like.
But, a more compact code that would do what you want would be:

Code: Select all

ReefAngel.Relay.Set(Port8, now()%21600<10800);
The code above would make port 8 turn on for 3 hours and off for 3 hours. Just a little bit harder to understand without some math knowledge behind it, but both would work for what you want. Different ways of coding.

Code: Select all

ReefAngel.Relay.Set(Port8, now()%21600<10800);
So this in saying out of 21600 seconds, 10800 of those seconds the relay would be off?

Re: a pump on for 3 hours then off for 3 hours?

Posted: Sat Jun 20, 2015 9:03 pm
by rimai
yes :)

Re: a pump on for 3 hours then off for 3 hours?

Posted: Sun Jun 21, 2015 9:37 am
by MDB1029
Is this what it should look like in internal memory?

Code: Select all

    ReefAngel.Relay.Set(Port8, now()%21600<10800);

Re: a pump on for 3 hours then off for 3 hours?

Posted: Sun Jun 21, 2015 11:42 am
by lnevo
This type of code would not use internal memory. If you wanted to be able to change any of the values, you'd have to put them in some custom memory locations. This is an advanced topic so if that's what you want we can walk you through the process. A good place to start would be to post your full code.

Re: a pump on for 3 hours then off for 3 hours?

Posted: Mon Jun 22, 2015 7:02 pm
by MDB1029
I can just change the code when i need it changed. I don't need to be able to change it on the app or portal. I did get it working with the code above. Thanks Roberto!