I found another post that sort of addressed this, but I want to do something a little different....
Right now I have my wavemaker going left side one for 45 seconds or so, then the right one on for 45 seconds or so...then I have a night time mode where there is a 1 minute delay between them when neither is on at all...
What I was thinking of doing was during the daytime mode was every fifth time (or some interval) have both pumps on at the same time to really stir things up, and then back to one pump on, one pump off for the random interval....what would I need to insert in the code?
Thanks in advance...
This is the wavemaker section of code...
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
if (now()%300<50)
{
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
}
Place this as the last check in your function and it should have higher priority than the other checks.
It will turn both on every 300s for 50s. You can adjust it accordingly.
should this be "rely on" instead of relay off? I uploaded and both pumps went off...
And if I want this to only happen during the daytime cycle, (between 8 am and 9 pm), do I put this "if"statement in the if/else for the 9 am to 8 pm loop (I don't know the right terms to use in describing this) :
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
if (now()%300<30)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);
}
}
}
Ok, it is working, except the timer for when both are on doesn't seem to be using the <30, it seems to be using the random timer I set in the wizard of Random between 35 and 45 seconds...
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
if (now()%300<30)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);
}
}
OK, thanks Roberto, but this code still has the "overlap" time going for the random times I set with the wizard, not the time set in this code, which is 20 seconds...
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
}
}
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
WMRTimer=now();
}
}
Oh, and the overlap is happening during the night time mode as well, not just from 8 am to 9 pm, and it is using the 20 second time to be on at night, just like happens with the pumps when they are on one at a time during the 9 pm to 8 am time period...
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
WMRTimer=now();
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
}
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
WMRTimer=now();
}
}
}
}
Update: I just updated it right after I submitted. So, don't copy the one in the email. Use the one posted above.
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
WMRTimer=now();
}
}
}
}
I just tested it and they did here.
It's programmed to come on at the first 20 seconds of every 5 minutes.
So, 15:00:00 to 15:00:20, 15:05:00 to 15:05:20, 15:10:00 to 15:10:05 and so on.
Can you double check?
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
if ((hour() > 8) && (hour() < 21)) //from 9p-8a
{
if (now()%300<20)
{
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
}
}
}
OK, this is what is doing now: Every five minutes both pumps come on and the timer I have on the screen shows the countdown. Both pumps come on and the timer counts down from 10 secs to 0, then resets to 40 seconds down to zero, then both pumps go off. So both are on for 50 seconds every 5 minutes instead of 20. I don't understand the "double countdown" either...
void MyWavemakerRandom(byte WMRelay1, byte WMRelay2, int MinWMTimer, int MaxWMTimer)
{
if (now()>WMRTimer)
{
if ((hour() >= 21) || (hour() <= 8)) //from 9p-8a
{
if (wmdelay)
{
WMRTimer=now()+60;
ReefAngel.Relay.Off(WMRelay1);
ReefAngel.Relay.Off(WMRelay2);
if (wmport==Port5) wmport=Port6;
else wmport=Port5;
wmdelay=false;
}
else
{
WMRTimer=now()+20;
ReefAngel.Relay.On(wmport);
wmdelay=true;
}
}
else
{
WMRTimer=now()+random(MinWMTimer, MaxWMTimer);
ReefAngel.Relay.Toggle(WMRelay1);
ReefAngel.Relay.Set(WMRelay2,!ReefAngel.Relay.Status(WMRelay1)); // Turn Port6 on/off on opposite cycle as Port 5
// Port 5 and 6 are synchronized.
// They work in opposing motion of each other at random times.
}
}
if ((hour() > 8) && (hour() < 21)) //from 9p-8a
{
if (now()%300==0)
{
WMRTimer=now()+20;
ReefAngel.Relay.On(WMRelay1);
ReefAngel.Relay.On(WMRelay2);//they are supposed to be on at the same time for 20 seconds
//every 5 minutes
}
}
}