Page 1 of 1

new wavemaker snippet in .9.4

Posted: Fri Mar 30, 2012 10:07 am
by rossbryant1956
How do I change my code in which I do this:

Code: Select all

ReefAngel.WavemakerRandom(Port5,15,60); // Turn Port5 on/off random cycles that lasts from 15 to 60 secs
    ReefAngel.Relay.Set(Port6,!ReefAngel.Relay.Status(Port5)); // 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.
to use the new code

Code: Select all

ReefAngel.WavemakerToggle(WMRelay1, WMRelay2, WMTimer);
Thx in advance.

Re: new wavemaker snippet in .9.4

Posted: Fri Mar 30, 2012 4:00 pm
by binder
This should accomplish that for you. First, you gotta randomize the timer. Once you get the random value for the timer, you have to check if the timer is expired or not, then update.

Place this code inside your loop()

Code: Select all

// Randomize the Timer
static time_t timer=now()+15;
if (now()>timer)
{
	timer=now()+random(15, 60);
}

ReefAngel.WavemakerToggle(Port5, Port6, timer);
I have not tested this code. It should work, but I would test it out first or at least watch it to ensure it works as expected. I'm planning on testing this out later tonight or tomorrow.

Re: new wavemaker snippet in .9.4

Posted: Mon Apr 23, 2012 6:52 pm
by rossbryant1956
I finally got time to play with this and although it works it seems weird.

The first two times it switched okay, it first was in about 15-20 seconds, the second in a minute or so, the third, fourth, and fifth are getting longer and longer, now up to about 6 or so minutes prior to switching...

So perhaps that is as designed but I wanted to check in... What do others think that have used this new code?

Thx in advance.

Re: new wavemaker snippet in .9.4

Posted: Tue Apr 24, 2012 3:44 pm
by binder
Yeah, I could see how it could possibly increase at times. The reasoning is you are randomizing all of the intervals and that could cause some lengthening of the timers. This function was ideally created for those who use a static interval instead of a random interval. I may have to test it more to see how this code functions in real time.

Re: new wavemaker snippet in .9.4

Posted: Thu May 10, 2012 6:41 am
by knapp870
Any updates on this? I'm fine using a standard wave maker interval, but think it would be great to have a random toggle like this, taking into account of the status of the other wave maker.

Re: new wavemaker snippet in .9.4

Posted: Thu May 10, 2012 6:47 am
by binder
No updates on it currently. I've been working on expansion relay support inside the Android Reef Angel Status app.

Re: new wavemaker snippet in .9.4

Posted: Thu May 10, 2012 7:49 am
by rimai
Have you tried one of the example codes?
File->Sketchbook->Example Codes->Wavemaker_Random_Sync

Re: new wavemaker snippet in .9.4

Posted: Fri May 11, 2012 6:48 am
by abhi_123
This timer facility is not coming to my expectations. i have calculated a 5 min switch off between the pumps.

Re: new wavemaker snippet in .9.4

Posted: Fri May 11, 2012 6:52 am
by binder
abhi_123 wrote:This timer facility is not coming to my expectations. i have calculated a 5 min switch off between the pumps.
What code exert are you using that you calculated a 5 minute switch off?

Re: new wavemaker snippet in .9.4

Posted: Fri May 11, 2012 8:10 am
by abhi_123
Curt,

the same one which you have posted in the beginning of this thread.

FYI I have posted the timer inside the loop.