Page 1 of 1
Random Wavemaker
Posted: Tue May 08, 2012 4:18 am
by Govertical19
Hey all,
If I wanted port 3 and 4 to have random waves would this be the code I would use?
ReefAngel.WavemakerRandom1(Port3,15,60); // Turn Port3 on/off random cycles that lasts from 15 to 60 secs
ReefAngel.WavemakerRandom1(Port4,15,60); // Turn Port4 on/off random cycles that lasts from 15 to 60 secs
Or can the ports be put into one line of code?
Thanks in advance!
Re: Random Wavemaker
Posted: Tue May 08, 2012 5:14 am
by dmglakewood
This is how I have mine setup
Code: Select all
void setup(){
ReefAngel.Timer[1].SetInterval(random(15,60));
ReefAngel.Timer[1].Start();
ReefAngel.Timer[2].SetInterval(random(15,60));
ReefAngel.Timer[2].Start();
}
The above code will setup a timer to always run randomly between 15 and 60 seconds.
Code: Select all
void loop(){
//Left powerhead turn on
if(ReefAngel.Timer[1].IsTriggered()){
ReefAngel.Timer[1].SetInterval(random(15,60));
ReefAngel.Timer[1].Start();
ReefAngel.Relay.Toggle(Port3);
}
//Right powerhead turn on
if(ReefAngel.Timer[2].IsTriggered()){
ReefAngel.Timer[2].SetInterval(random(15,60));
ReefAngel.Timer[2].Start();
ReefAngel.Relay.Toggle(Port4);
}
}
The above code will wait until the random number between 15 and 60 is reached and then it will run the code inside the if statement. This code will Toggle the powerhead on or off depending on it's current state. It will also setup another timer to run randomly between 15 and 6 0 seconds.
Re: Random Wavemaker
Posted: Tue May 08, 2012 5:31 am
by Sebyte
In the latest libraries the hard work is already done, the following code is all you need.
Code: Select all
ReefAngel.WavemakerRandom(Port3,15,60);
ReefAngel.WavemakerRandom1(Port4,15,60);
EDIT: I missed the second line should read ReefAngel.WavemakerRandom1(Port4,15,60); now corrected above.
Sebyte
Re: Random Wavemaker
Posted: Tue May 08, 2012 7:17 am
by rimai
I'd highly recommend you using Port 5 and 6 for wavemakers.
You will just have problems on the other ports.
Re: Random Wavemaker
Posted: Tue May 08, 2012 8:56 am
by billybob
wait, I'm confused... I had been assuming that all the ports were identical, and we could mix/match and reassign them as needed.
is there something physically different about ports 5 and 6 from the rest of the ports?
Re: Random Wavemaker
Posted: Tue May 08, 2012 9:00 am
by Sebyte
Ports 5 & 6 are higher rated and have some extra components to allow for constant switching on and off. Which is what you need for wave makers.
Re: Random Wavemaker
Posted: Tue May 08, 2012 1:01 pm
by binder
Also, with using the WavemakerRandom functions, you cannot use them multiple times without potentially having problems.
So you would want to do
Code: Select all
ReefAngel.WavemakerRandom(Port5, 15, 60);
ReefAngel.WavemakerRandom1(Port6, 15, 60);
Re: Random Wavemaker
Posted: Tue May 08, 2012 11:59 pm
by abhi_123
Curt we have to put this code in loop or void or under custom code head?
Re: Random Wavemaker
Posted: Wed May 09, 2012 5:47 am
by binder
abhi_123 wrote:Curt we have to put this code in loop or void or under custom code head?
These will go under the loop just like the standard wavemaker functions.
Re: Random Wavemaker
Posted: Wed May 09, 2012 6:55 am
by abhi_123
binder wrote:abhi_123 wrote:Curt we have to put this code in loop or void or under custom code head?
These will go under the loop just like the standard wavemaker functions.
Do we need to change it with the standard wave maker. if i want to synchronized them than what should i add.
Re: Random Wavemaker
Posted: Wed May 09, 2012 8:12 am
by binder
abhi_123 wrote:Do we need to change it with the standard wave maker. if i want to synchronized them than what should i add.
I don't follow.
If you want to use it, change this line:
to this
Code: Select all
ReefAngel.WavemakerRandom(Port5, 15, 60);
It won't use your internal memory values, but it will randomly pick a time between 15 and 60 seconds to set as the intervals for on/off.
What are you wanting to synchronize? The on/off of the wavemakers? So when wavemaker 1 is off, wavemaker 2 is on and vice versa? If you want this control, you should use:
Code: Select all
ReefAngel.WavemakerToggle(Port5, Port6, 60);
which will toggle port 5 & 6 on/off (respectively) every 60 seconds. It can be changed to use the internal memory value of wavemaker 1 if you like:
Code: Select all
ReefAngel.WavemakerToggle(Port5, Port6, InternalMemory.WM1Timer_read());
This will use a continuous interval for toggling. If you want a random toggle interval, then you won't be able to use the WavemakerToggle function and will have to use another function like mentioned in this topic:
http://forum.reefangel.com/viewtopic.php?f=12&t=944
Re: Random Wavemaker
Posted: Wed May 09, 2012 8:33 am
by abhi_123
Thanks a lot curt. That's bundle of knowledge.