What is the best way to code a port to run 3 times a week?
Re: What is the best way to code a port to run 3 times a wee
The code is working right. When it's 3am your adding 21 hours and then it does the function as if it were midnight. The rest of the function to the right of % assumes its midnight. So at 3am it is fast forwarding to midnight and working. If you want it at 9pm then add 14400 if you want to use 21 hours (75600) then try subtracting it instead of adding
Re: What is the best way to code a port to run 3 times a wee
Wow, now I'm totally confused.
Just when I thought I was starting understand this a little bit.
I thought now equalled midnight and then you add the amount of seconds that you want to get to your desired time.
OK I'll will try adding 14400 and see what happens.
Thanks Lee.
Just when I thought I was starting understand this a little bit.
I thought now equalled midnight and then you add the amount of seconds that you want to get to your desired time.
OK I'll will try adding 14400 and see what happens.
Thanks Lee.
Re: What is the best way to code a port to run 3 times a wee
Yes but the condition your checking %(3 days)<300 is assuming midnight left of the %. The +whatever is the offset and if your doing something hourly or something divisible evenly throughout the day it won't make a difference (like every 3 hours or something) but since your looking at a once a day we need to be more precise. The now+whatever will make it midnight at the time you want
Re: What is the best way to code a port to run 3 times a wee
Ok. That makes a bit more sense. Thanks for explaining it.
I really should find an online tutorial or something, I just don't have the time.
I really should find an online tutorial or something, I just don't have the time.
Re: What is the best way to code a port to run 3 times a wee
Well it went off today as it should (3rd day), but it went off at 8pm.
So 10800 would be 9pm?
So 10800 would be 9pm?
Re: What is the best way to code a port to run 3 times a wee
Did you reset your clock for daylight savings? Would either will or won't go for it.
Re: What is the best way to code a port to run 3 times a wee
Yes I reset the clock for daylight savings.
Re: What is the best way to code a port to run 3 times a wee
FYI. changing the time to 10800 set it off at 9pm last night.
The working code for every 3 days at 9pm is...
The working code for every 3 days at 9pm is...
Code: Select all
//Flush RO/DI Membrane 3 times a week
ReefAngel.Relay.Set(Main_RODI,(now()+10800)%(SECS_PER_DAY*3)<300);
Re: What is the best way to code a port to run 3 times a wee
Yeah, 10800 is 3 hours... 9pm + 3 hours = Midnight.
Re: What is the best way to code a port to run 3 times a wee
If I wanted to change this code from every 3 days to Monday, Wednesday & Friday, how would it differ?
I'm just thinking about something I'm going to add in the future and it may be better to run on specific days rather than every 3 days.
Code: Select all
//Flush RO/DI Membrane 3 times a week
ReefAngel.Relay.Set(Main_RODI,(now()+10800)%(SECS_PER_DAY*3)<300);
Re: What is the best way to code a port to run 3 times a wee
Easy enough. I'd have to test the syntax, but a switch/case statement should be able to handle that easy enough.
Honestly I think flushing the membrane though once a week should be sufficient.
Anyway, what days is it running now. You could always add a day to the now() to fast forward it a day or whatever is needed And then make it another day while skipping saturday/sunday
Honestly I think flushing the membrane though once a week should be sufficient.
Anyway, what days is it running now. You could always add a day to the now() to fast forward it a day or whatever is needed And then make it another day while skipping saturday/sunday
Re: What is the best way to code a port to run 3 times a wee
The Time library offers day of the week.
I think this should do it:
I think this should do it:
Code: Select all
ReefAngel.Relay.Set(Main_RODI, ((weekday()==dowMonday || weekday()==dowWednesday || weekday()==dowFriday) && (now()+10800)<300 ));
Roberto.
Re: What is the best way to code a port to run 3 times a wee
Lee;
I was talking with Russ at Buckeye Hydro on Reef Central (http://www.reefcentral.com/forums/showt ... ?t=2369559) and he said "You should make water at least once per week. Flushing once a week or more often is a good idea too."
Right now it is running every 3 days so if I first started it on Monday then it would run Monday, Thursday. Sunday, Wednesday, Saturday and so on.
Falling back 1 day every week.
What I ultimately want to do is have it turn on port 7 to flush the membrane like Monday and Wednesday and on Friday I will have it turn on port 6 & 7 to make just RO water. It will bypass the DI resin and just flow the water out to the garden bed outside the garage.
Again this is the ultimate end goal. I would also like to have some safety statements in there that would not run either of these if my RO/DI system was triggered by my water level sensors, to make RO/DI water to refill my 20 Gallon Brute ATO Reservoir or my 20 Gallon Brut Salt Water Reservoir for Automatic water changes with in the past 48 hours.
I was going to try to attempt that on my own later, but that is what I'm going for to automate, the water change and ATO stations in terms of refilling them.
Thanks Roberto. I'll try the time library code and see how that does.
I was talking with Russ at Buckeye Hydro on Reef Central (http://www.reefcentral.com/forums/showt ... ?t=2369559) and he said "You should make water at least once per week. Flushing once a week or more often is a good idea too."
Right now it is running every 3 days so if I first started it on Monday then it would run Monday, Thursday. Sunday, Wednesday, Saturday and so on.
Falling back 1 day every week.
What I ultimately want to do is have it turn on port 7 to flush the membrane like Monday and Wednesday and on Friday I will have it turn on port 6 & 7 to make just RO water. It will bypass the DI resin and just flow the water out to the garden bed outside the garage.
Again this is the ultimate end goal. I would also like to have some safety statements in there that would not run either of these if my RO/DI system was triggered by my water level sensors, to make RO/DI water to refill my 20 Gallon Brute ATO Reservoir or my 20 Gallon Brut Salt Water Reservoir for Automatic water changes with in the past 48 hours.
I was going to try to attempt that on my own later, but that is what I'm going for to automate, the water change and ATO stations in terms of refilling them.
Thanks Roberto. I'll try the time library code and see how that does.
Re: What is the best way to code a port to run 3 times a wee
This didn't work.rimai wrote:The Time library offers day of the week.
I think this should do it:Code: Select all
ReefAngel.Relay.Set(Main_RODI, ((weekday()==dowMonday || weekday()==dowWednesday || weekday()==dowFriday) && (now()+10800)<300 ));
I originally changed Friday to Thursday to test it that night and nothing, so I set it back to the way Roberto wrote it and although I wasn't home last night at 9pm there was no evidence there it happened.
Re: What is the best way to code a port to run 3 times a wee
I'm not sure why it is not working. I though t it was the double &, but that means "and".
So to me it reads as turn on the port for Main_RODI on Monday, Wednesday and Friday and 3 hours before midnight for 300 seconds (5 min).
So to me it reads as turn on the port for Main_RODI on Monday, Wednesday and Friday and 3 hours before midnight for 300 seconds (5 min).
Re: What is the best way to code a port to run 3 times a wee
Does anyone have a suggestion on how to do this?
I can't seem to get it to work.
I can't seem to get it to work.
Re: What is the best way to code a port to run 3 times a wee
Try doing several if conditions and see if it works better for you.
Do something similar for the other times.
Code: Select all
ReefAngel.Relay.Off(Main_RODI);
if (weekday()==dowMonday && hour()==9 && minute()<5)
ReefAngel.Relay.On(Main_RODI);
Roberto.
Re: What is the best way to code a port to run 3 times a wee
Thanks. I'll try it.
Re: What is the best way to code a port to run 3 times a wee
hou()==9 is going to be 9am though...
Re: What is the best way to code a port to run 3 times a wee
So it should be the following?
Code: Select all
ReefAngel.Relay.Off(Main_RODI);
if (weekday()==dowMonday && hour()==21 && minute()<5)
ReefAngel.Relay.On(Main_RODI);
Re: What is the best way to code a port to run 3 times a wee
I tried the code and it worked fine.
I'll set up the other days later.
Thanks everyone.
I'll set up the other days later.
Thanks everyone.
Re: What is the best way to code a port to run 3 times a wee
So if I wanted 9:05pm would it be...
Code: Select all
ReefAngel.Relay.Off(Main_RODI);
if (weekday()==dowMonday && hour()==2105 && minute()<5)
ReefAngel.Relay.On(Main_RODI);
Re: What is the best way to code a port to run 3 times a wee
no hour() only returns the hour not the time. You'd have to check minute >= 5 && < 10
Re: What is the best way to code a port to run 3 times a wee
So i tried this...
and I'm getting an "expected primary-expression before '<' token" error with the line I'm working on highlighted and the 1st "(" circled.
I'm obviously missing a comma or something, but don't know where.
Code: Select all
ReefAngel.Relay.Off(Main_RODI);
if (weekday()==dowSunday && hour()==9 >= 5 && < 10 && minute()<5)
ReefAngel.Relay.On(Main_RODI);
I'm obviously missing a comma or something, but don't know where.
Re: What is the best way to code a port to run 3 times a wee
No. You need to check for day of the week, hour and minutes.
If you want minutes >= 5 and minutes < 10, it would be minute()>=5 && minute() <10
If you want minutes >= 5 and minutes < 10, it would be minute()>=5 && minute() <10
Roberto.
Re: What is the best way to code a port to run 3 times a wee
Ok. That makes sense.
Thanks.
So I've got this now and an still getting an error of expected ')' before 'minute'.
I hate trying to figure out error messages. Ugh.
I tried putting a parenthesis () around (minute()>=25 && minute()<30 and got 11 can not be used as a function.
Thanks.
So I've got this now and an still getting an error of expected ')' before 'minute'.
Code: Select all
ReefAngel.Relay.Off(Main_RODI);
if (weekday()==dowSunday && hour()==11 minute()>=25 && minute()<30 && minute()<5)
ReefAngel.Relay.On(Main_RODI);
I tried putting a parenthesis () around (minute()>=25 && minute()<30 and got 11 can not be used as a function.
Re: What is the best way to code a port to run 3 times a wee
I figured out the error message. I was missing && in between the 11 and the minute, but it doesn't seem to be working.
The way I understand it with this code the Test+Light port, which is port 5 on the main relay, will run Tuesdays from 9:20pm to 9:25pm.
Nothing happened at 9:20pm.
Help???
The way I understand it with this code the Test+Light port, which is port 5 on the main relay, will run Tuesdays from 9:20pm to 9:25pm.
Code: Select all
ReefAngel.Relay.Off(Test_Light);
if (weekday()==dowTuesday && hour()==21 && minute()>=20 && minute()<25 && minute()<5)
ReefAngel.Relay.On(Test_Light);
Help???
Re: What is the best way to code a port to run 3 times a wee
You have an impossible condition: minute >= 20 AND minute < 5. Those 2 conditions are mutually exclusive hence nothing happens. If you remove the " &&minute()<5" clause you should get something between 21:20 and 21:24:59.
Re: What is the best way to code a port to run 3 times a wee
Thanks.
I'll try it later.
I'll try it later.