WP40 on the ATO PWM & Custom code
Posted: Wed Jun 19, 2013 11:52 am
Hello all,
I just wanted to share my experience in hooking up a Jebao WP40 to my RA via the ATO PWM port. Hopefully this will save someone some time in the future.
So I wanted to upgrade my tank flow and started getting curious about the WP40. From different forums and reviews, I gathered that it was worth the try and placed the order for this pump online.
After that, I had to figure out the way to connect it and make it work with the RA.
Here's the step by step of that:
1. Get the cable from RA. When you place the order, make sure to indicate that your cable is meant to be used with the ATO PWM because that port uses a different volt range than the light dimming PWMs on the relay box.
2. The cable is attached to the outer-most ATO pin. That's the dimmable one. Pump goes in the water
3. When I first hooked up my pump, it worked at (what looked like to be) full force. My fish looked like stray kites in the sky!
4. Upload your new code for controlling this pump.
For this, I had a lot of help from user 'lnevo'. He was amazing with me and explained everything thoroughly.
I used the 'template' of the ReefCrest Function and just made one change.
4.1 The way it's written, ReefCrest uses a random speed between an average speed and a deviation percentage. So if your avg. speed is 50 and your deviation is 10%, it will choose a random value between 40% and 60%. It will then run the pump in cycles that last 5 seconds at that power and after the 5 seconds, will choose a new random power value.
The original ReefCrest mode is defined as:
The only part I wasn't too fond of on this mode was the fact that the duration of the cycle was always 5 seconds. So we modified it to make it a random value between 5 and 15 seconds.
It looked then like this:
With that, I just went ahead and changed the name of the mode so it doesn't conflict with your previously existing definitions in the library. How to change the name of the mode? All you do is change ReefCrestMode for WhatYouWant or any other preferred name. Looks like this now:
4.2 Pasting this function in your code:
Just as explained by lnevo: "Just put it at the bottom on a new line or if you want you can put it in the global variable section. Either way it cant be inside any set of {}"
So I went ahead and pasted it directly above your "void loop ()" line
5 Invoking your function
Thanks to 'rimai', I was able to come-up with the line to invoke the WhatYouWant or old ReefCrest function.
Since you are hooking it up to your ATO PWM, it needs to be multiplied by a factor of 2.55.
It looked like this:
6. Including a parabola function to give stronger flow during the day and weaker at night:
With the help of 'lnevo' again, we were able to come up with this new function. It makes the pump start at 3am at an avg speed of 30 with a variance of 12% and 'peak' its power at 3pm with a power of 75% and a variance of 25%
The final code to be pasted on the "Custom Code' section:
Notice that the 2.55 factor was changed places but it shouldn't alter your results.
I really like this mode as it is truly random in duration, power and is variable throughout the 24 hours of the day.
I hope this helps someone in the future and you don't have to tie the forum gurus more than they already are.
Happy Reefing!
I just wanted to share my experience in hooking up a Jebao WP40 to my RA via the ATO PWM port. Hopefully this will save someone some time in the future.
So I wanted to upgrade my tank flow and started getting curious about the WP40. From different forums and reviews, I gathered that it was worth the try and placed the order for this pump online.
After that, I had to figure out the way to connect it and make it work with the RA.
Here's the step by step of that:
1. Get the cable from RA. When you place the order, make sure to indicate that your cable is meant to be used with the ATO PWM because that port uses a different volt range than the light dimming PWMs on the relay box.
2. The cable is attached to the outer-most ATO pin. That's the dimmable one. Pump goes in the water
3. When I first hooked up my pump, it worked at (what looked like to be) full force. My fish looked like stray kites in the sky!
4. Upload your new code for controlling this pump.
For this, I had a lot of help from user 'lnevo'. He was amazing with me and explained everything thoroughly.
I used the 'template' of the ReefCrest Function and just made one change.
4.1 The way it's written, ReefCrest uses a random speed between an average speed and a deviation percentage. So if your avg. speed is 50 and your deviation is 10%, it will choose a random value between 40% and 60%. It will then run the pump in cycles that last 5 seconds at that power and after the 5 seconds, will choose a new random power value.
The original ReefCrest mode is defined as:
Code: Select all
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{
static unsigned long lastwavemillis=millis();
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > 5000)
{
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,100);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
It looked then like this:
Code: Select all
byte ReefCrestMode(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{
static unsigned long lastwavemillis=millis();
static int delay;
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > delay)
{
delay=random(5000,15000);
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,100);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
Code: Select all
byte WhatYouWant(byte WaveSpeed, byte WaveOffset, boolean PulseSync)
{
static unsigned long lastwavemillis=millis();
static int delay;
static int newspeed=WaveSpeed;
if ((millis()-lastwavemillis) > delay)
{
delay=random(5000,15000);
if (random(100)<50) newspeed--; else newspeed++;
newspeed=constrain(newspeed,WaveSpeed-WaveOffset,WaveSpeed+WaveOffset);
newspeed=constrain(newspeed,0,100);
lastwavemillis=millis();
}
if (PulseSync)
return newspeed;
else
return WaveSpeed-(newspeed-WaveSpeed);
}
Just as explained by lnevo: "Just put it at the bottom on a new line or if you want you can put it in the global variable section. Either way it cant be inside any set of {}"
So I went ahead and pasted it directly above your "void loop ()" line
5 Invoking your function
Thanks to 'rimai', I was able to come-up with the line to invoke the WhatYouWant or old ReefCrest function.
Since you are hooking it up to your ATO PWM, it needs to be multiplied by a factor of 2.55.
It looked like this:
Code: Select all
pinMode(lowATOPin,OUTPUT);
analogWrite(lowATOPin,WhatYouWant(60,20,true)*2.55);
With the help of 'lnevo' again, we were able to come up with this new function. It makes the pump start at 3am at an avg speed of 30 with a variance of 12% and 'peak' its power at 3pm with a power of 75% and a variance of 25%
The final code to be pasted on the "Custom Code' section:
Code: Select all
pinMode(lowATOPin,OUTPUT);
analogWrite(lowATOPin, 2.55*WhatYouWant( PWMParabola(3,0,2,59,30,75,0), PWMParabola(3,0,2,59,12,25,0),true) );
I really like this mode as it is truly random in duration, power and is variable throughout the 24 hours of the day.
I hope this helps someone in the future and you don't have to tie the forum gurus more than they already are.
Happy Reefing!