Random Wavemaker

Do you have a question on how to do something.
Ask in here.
Post Reply
Govertical19
Posts: 27
Joined: Wed Feb 15, 2012 6:52 am

Random Wavemaker

Post 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!
dmglakewood
Posts: 26
Joined: Thu Mar 01, 2012 1:31 pm

Re: Random Wavemaker

Post 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.
Sebyte

Re: Random Wavemaker

Post 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
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Random Wavemaker

Post by rimai »

I'd highly recommend you using Port 5 and 6 for wavemakers.
You will just have problems on the other ports.
Roberto.
billybob
Posts: 21
Joined: Tue Apr 17, 2012 2:47 pm
Location: Colorado

Re: Random Wavemaker

Post 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?
Sebyte

Re: Random Wavemaker

Post 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.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Random Wavemaker

Post 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);
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Random Wavemaker

Post by abhi_123 »

Curt we have to put this code in loop or void or under custom code head?
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Random Wavemaker

Post 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.
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Random Wavemaker

Post 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.
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Random Wavemaker

Post 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:

Code: Select all

ReefAngel.Wavemaker1(Port5);
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
abhi_123
Posts: 216
Joined: Tue Mar 20, 2012 8:34 am

Re: Random Wavemaker

Post by abhi_123 »

Thanks a lot curt. That's bundle of knowledge.
Image
Post Reply