My Jebao "Else" mode

Expansion modules and attachments
cjrudy
Posts: 135
Joined: Sat Nov 10, 2012 2:47 pm

Re: My Jebao "Else" mode

Post by cjrudy »

So if you pick reefcrest it automatically runs them in anti sync mode ?
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

cjrudy wrote:Can the portal set anti sync modes ?
The setting under Internal Memory in the Portal are only Mode, Speed and Duration. You can't change anything else through the portal.
cjrudy wrote:So if you pick reefcrest it automatically runs them in anti sync mode ?
I don't think so. How can it do an anti sync if you only have 1 pump?
cjrudy
Posts: 135
Joined: Sat Nov 10, 2012 2:47 pm

Re: My Jebao "Else" mode

Post by cjrudy »

Ill be setting up my second today, Lee said above thy automatically run one sync one anti sync
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: My Jebao "Else" mode

Post by lnevo »

You define it in the wizard which pumps are sync which are anti-sync...

I dont know the syntax but something like this..

ReefAngel.DCPump.Daylight=Sync;
...Actinic=AntiSync;
..channel0=Sync;

However you define it is how it will run.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

This is the code the wizard generates....

Code: Select all

    ReefAngel.DCPump.DaylightChannel = AntiSync;
    ReefAngel.DCPump.ActinicChannel = Sync;
cjrudy
Posts: 135
Joined: Sat Nov 10, 2012 2:47 pm

Re: My Jebao "Else" mode

Post by cjrudy »

I have both pumps, WP25 and WP40 set up and running in Else mode, one sync one antisync

So far so good, love the randomness of the Else mode
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

I set my 25 up this weekend and have the 40 (Sync) and 25 (Anti-Sync).

I like the flow. The 25 is placed toward the bottom of the tank and really is just blowing behind my reefscape and pointed up a bit to keep things moving.

I have the 40 at 40,20 (so it runs from 60% to 20%) and the 25 is running 80, 20 (100% to 60%). It seems to work real nice.
cjrudy
Posts: 135
Joined: Sat Nov 10, 2012 2:47 pm

Re: My Jebao "Else" mode

Post by cjrudy »

So if both mine are set at 70, 30 then they're really not running up to 100% ??

How does this work ?
Last edited by cjrudy on Mon Aug 12, 2013 10:41 am, edited 1 time in total.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

The way I understand it is that the 70 is you base or center point and it will vary 30% above and below that center point. So if I have it correct you would be running 100% to 40%.

Here is a partial quote from cosmith71 in the original post about how it works...
cosmith71 wrote:Call with ElseMode( MidPoint, Offset, Sync );

Where Midpoint is the middle of the range you want, and Offset is the +/- range. Sync and anti-sync are opposites (true for sync or false for anti-sync) For example, ElseMode ( 70, 30, true ) will return values from 40% to 100%. The speed changes every 0.5 to 5 seconds and can be anywhere in between MidPoint +/- Offset.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

cjrudy wrote:So if both mine are set at 70, 30 then they're really not running up to 100% ??

How does this work ?
What Steve said.

They will run at anywhere from 40 (70-30) to 100 (70+30).

--Colin
cjrudy
Posts: 135
Joined: Sat Nov 10, 2012 2:47 pm

Re: My Jebao "Else" mode

Post by cjrudy »

Ok, I get it now.......thanks
anderzon_
Posts: 67
Joined: Sun Oct 27, 2013 11:35 am

Re: My Jebao "Else" mode

Post by anderzon_ »

Hi

Ive tried to get this work but it doesn't work. Where in the code should I paste the code.

Here is my code:

Code: Select all

#include <ReefAngel_Features.h> #include <Globals.h> #include <RA_Wifi.h> #include <Wire.h> #include <OneWire.h> #include <Time.h> #include <DS1307RTC.h> #include <InternalEEPROM.h> #include <RA_NokiaLCD.h> #include <RA_ATO.h> #include <RA_Joystick.h> #include <LED.h> #include <RA_TempSensor.h> #include <Relay.h> #include <RA_PWM.h> #include <Timer.h> #include <Memory.h> #include <InternalEEPROM.h> #include <RA_Colors.h> #include <RA_CustomColors.h> #include <Salinity.h> #include <RF.h> #include <IO.h> #include <ORP.h> #include <AI.h> #include <PH.h> #include <WaterLevel.h> #include <Humidity.h> #include <DCPump.h> #include <ReefAngel.h>

////// Place global variable code below here

////// Place global variable code above here

void setup() { // This must be the first line ReefAngel.Init(); //Initialize controller ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature

ReefAngel.Use2014Screen(); // Let's use 2014 Screen // Ports toggled in Feeding Mode ReefAngel.FeedingModePorts = Port6Bit; // Ports toggled in Water Change Mode ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port8Bit; // Ports toggled when Lights On / Off menu entry selected ReefAngel.LightsOnPorts = 0; // Ports turned off when Overheat temperature exceeded ReefAngel.OverheatShutoffPorts = Port1Bit; // Use T1 probe as temperature and overheat functions ReefAngel.TempProbe = T1_PROBE; ReefAngel.OverheatProbe = T1_PROBE; // Set the Overheat temperature setting InternalMemory.OverheatTemp_write( 270 );

// Feeeding and Water Change mode speed ReefAngel.DCPump.FeedingSpeed=0; ReefAngel.DCPump.WaterChangeSpeed=0;

// Ports that are always on ReefAngel.Relay.On( Port2 ); ReefAngel.Relay.On( Port3 ); ReefAngel.Relay.On( Port4 ); ReefAngel.Relay.On( Port5 ); ReefAngel.Relay.On( Port6 ); ReefAngel.Relay.On( Port8 );

////// Place additional initialization code below here

////// Place additional initialization code above here }

void loop() { ReefAngel.StandardHeater( Port1,250,254 ); ReefAngel.StandardLights( Port7,17,0,20,0 ); ReefAngel.DCPump.UseMemory = true; ReefAngel.DCPump.SetMode( ReefCrest,100,10 ); ReefAngel.DCPump.DaylightChannel = Sync; ReefAngel.DCPump.ActinicChannel = Sync; ////// Place your custom code below here

////// Place your custom code above here

// This should always be the last line ReefAngel.Portal( "anderzon_" ); ReefAngel.ShowInterface(); }
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

anderzon_ wrote:Hi

Ive tried to get this work but it doesn't work. Where in the code should I paste the code.

Here is my code:

Code: Select all

// This should always be the last line ReefAngel.Portal( "anderzon_" ); ReefAngel.ShowInterface(); }
After this line. Can someone else chime in on the DCPump stuff? I don't use it. I really should break down and get the WiFi unit for this tank.

--Colin
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: My Jebao "Else" mode

Post by ReEfnWrX »

Hey Guys,

Just got my RA connected and trying to add in Else mode as well as a schedule to go from Else(Higher speed) to Nutrient to Else(lower speed)

Schedule is
Else(Higher speed) - 11am-8pm
Nutrient Transport - 8pm-11pm
Else(Lower speed) - 11pm-11am


So I added the Else code at the very end of everything.
When calling the modes in the custom section, I removed the Actinic(antisync) lines since I only have one WP-40. Will this affect anything?

Other than that, is the way i implemented the code correct? Based on the codes I have seen I'm guessing that

//This should always be the last line //Is not always the last line?lol


Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit | Port8Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 825 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardHeater( Port1,775,780 );
    ReefAngel.StandardLights( Port2,21,30,12,0 );
    ReefAngel.StandardLights( Port3,12,0,21,30 );
    ReefAngel.MHLights( Port4,14,0,20,30,5 );
    ReefAngel.SingleATO( true,Port7,300,0 );
    ReefAngel.StandardLights( Port8,12,0,21,45 );
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( ReefCrest,75,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = None;
    ////// Place your custom code below here
    
if (hour()>=11 && hour()<20)
{
    ReefAngel.PWM.SetDaylight( ElseMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
}
else if (hour()>=20 && hour()<23)
{
    ReefAngel.PWM.SetDaylight( NutrientTransportMode(40,80,200,true) ); // Nutrient Transport 40%minspeed - 80%maxspeed - 200ms 
}    
    else if (hour()>=23 && hour()<11)
{
    ReefAngel.PWM.SetDaylight( ElseMode(45,15,true) ); // ReefCrest at 45% +/- 15% on sync mode
}

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "ReEfnWrX" );
    ReefAngel.ShowInterface();
}

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 3000);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

LOL, yeah, it's not always the last line. It should be the last line of the loop() function, though. You could actually put it before setup() if you like, it's just a style choice.

I don't use the DCPump stuff, so I can't advise on that. If it were me, I'd remove it all since your code isn't using it (you're writing directly with the PWM.SetDaylight function).

Otherwise looks fine.

--Colin
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

My code is setup to use the DCPump.
lnevo also set it up to randomly choose a mode from a designated list which Else Mode is part of.
It is actually running the Else mode today.

A link to my code is in my signature.
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: My Jebao "Else" mode

Post by ReEfnWrX »

By remove it, you are saying to remove the line #include <DCPump.H>
?

Also, I just uploaded the code, I changed the current time on the controller to 9am and the Daylight dimming shows it slowly fluctuating between 80-90 so far does not seem like Else mode at all... This does not seem to be working correctly since it should be 45% with a 15% swing.
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

ReEfnWrX wrote:By remove it, you are saying to remove the line #include <DCPump.H>
?

Also, I just uploaded the code, I changed the current time on the controller to 9am and the Daylight dimming shows it slowly fluctuating between 80-90 so far does not seem like Else mode at all... This does not seem to be working correctly since it should be 45% with a 15% swing.
Remove this stuff:

Code: Select all

ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( ReefCrest,75,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = None;
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: My Jebao "Else" mode

Post by ReEfnWrX »

So I removed those lines and reuploaded.

Now on the controller it shows 0 for Daylight Dimming, there is no activity and the pump is now off

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit | Port8Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 825 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardHeater( Port1,775,780 );
    ReefAngel.StandardLights( Port2,21,30,12,0 );
    ReefAngel.StandardLights( Port3,12,0,21,30 );
    ReefAngel.MHLights( Port4,14,0,20,30,5 );
    ReefAngel.SingleATO( true,Port7,300,0 );
    ReefAngel.StandardLights( Port8,12,0,21,45 );
    ////// Place your custom code below here
    
if (hour()>=11 && hour()<20)
{
    ReefAngel.PWM.SetDaylight( ElseMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
}
else if (hour()>=20 && hour()<23)
{
    ReefAngel.PWM.SetDaylight( NutrientTransportMode(40,80,200,true) ); // Nutrient Transport 40%minspeed - 80%maxspeed - 200ms 
}    
else if (hour()>=23 && hour()<11)
{
    ReefAngel.PWM.SetDaylight( ElseMode(45,15,true) ); // ReefCrest at 45% +/- 15% on sync mode
}

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "ReEfnWrX" );
    ReefAngel.ShowInterface();
}

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 3000);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}
Image
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: My Jebao "Else" mode

Post by ReEfnWrX »

Ok, so when the controller is inbetween 11pm-11am (Slower speed Else) it stops adjusting the pumps speed.

If I change controller time to after 11am for Else(Faster speed) it works properly.
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

My Jebao "Else" mode

Post by lnevo »

It's a commonly made logic mistake...

You can't have an hour greater than 23 AND less than 11.

&& = AND
|| = OR

So you can change the && to || to fix that last else if statement
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: My Jebao "Else" mode

Post by ReEfnWrX »

You know, 15 years ago I would have told you, the reason I will not get into coding is because if I spend hours trying to find that one space or character that is out of place, I would throw my computer through my window.....

Good thing I have calmed down with age :)
Image
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

ReEfnWrX wrote:Ok, so when the controller is inbetween 11pm-11am (Slower speed Else) it stops adjusting the pumps speed.

If I change controller time to after 11am for Else(Faster speed) it works properly.
Change this:

Code: Select all

else if (hour()>=23 && hour()<11)
to this:

Code: Select all

else if (hour()>=23 || hour()<11)
That should fix it.

Edit: Sorry, didn't see that Lee had chimed in. :D
--Colin
anderzon_
Posts: 67
Joined: Sun Oct 27, 2013 11:35 am

Re: My Jebao "Else" mode

Post by anderzon_ »

cosmith71 wrote:
anderzon_ wrote:Hi

Ive tried to get this work but it doesn't work. Where in the code should I paste the code.

Here is my code:

Code: Select all

// This should always be the last line ReefAngel.Portal( "anderzon_" ); ReefAngel.ShowInterface(); }
After this line. Can someone else chime in on the DCPump stuff? I don't use it. I really should break down and get the WiFi unit for this tank.

--Colin
Thx, Do I need this in my custom code:

if (ReefAngel.DCPump.Mode==Custom) { ReefAngel.PWM.SetDaylight( ElseMode(70,30,true )); // ElseMode on sync mode, 70 +/- 30% ReefAngel.DCPump.UseMemory = false; } else { ReefAngel.DCPump.UseMemory = true; } static time_t StartFeeding=0; if (ReefAngel.DisplayedMenu==FEEDING_MODE) StartFeeding=now(); // if we entered feeding mode, register what time it was. if (now()-StartFeeding > 1800 && now()-StartFeeding < 5400) // if feeding started between 1800 and 5400 seconds ReefAngel.PWM.SetActinic(100); else ReefAngel.PWM.SetActinic(45);

And below my portal name the rest of the code. Should I then change to custom portal?
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

Yes. I believe that is correct.
anderzon_
Posts: 67
Joined: Sun Oct 27, 2013 11:35 am

Re: My Jebao "Else" mode

Post by anderzon_ »

If I use this code, I can then switch between this and other programs through the portal?

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h> 
#include <RA_Joystick.h> 
#include <LED.h> 
#include <RA_TempSensor.h> 
#include <Relay.h> 
#include <RA_PWM.h> 
#include <Timer.h> 
#include <Memory.h> 
#include <InternalEEPROM.h> 
#include <RA_Colors.h> 
#include <RA_CustomColors.h> 
#include <Salinity.h> 
#include <RF.h> 
#include <IO.h> 
#include <ORP.h> 
#include <AI.h> 
#include <PH.h> 
#include <WaterLevel.h> 
#include <Humidity.h> 
#include <DCPump.h> 
#include <ReefAngel.h>

////// Place global variable code below here

////// Place global variable code above here

void setup() 
{ 
  // This must be the first line 
  ReefAngel.Init(); //Initialize controller 
  ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius 
Temperature

  ReefAngel.Use2014Screen(); // Let's use 2014 Screen 
  // Ports toggled in Feeding Mode 
  ReefAngel.FeedingModePorts = Port6Bit; 
  // Ports toggled in Water Change Mode 
  ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit |
Port4Bit | Port6Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = 0;
  // Ports turned off when Overheat temperature exceeded 
  ReefAngel.OverheatShutoffPorts = Port1Bit; 
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 270 );

  // Feeeding and Water Change mode speed
  ReefAngel.DCPump.FeedingSpeed=0;
  ReefAngel.DCPump.WaterChangeSpeed=0;

  // Ports that are always on
  ReefAngel.Relay.On( Port2 );
  ReefAngel.Relay.On( Port3 );
  ReefAngel.Relay.On( Port4 );
  ReefAngel.Relay.On( Port5 );
  ReefAngel.Relay.On( Port6 );
  ReefAngel.Relay.On( Port8 );

  ////// Place additional initialization code below here

  ////// Place additional initialization code above here
}

void loop() 
{
  ReefAngel.StandardHeater( Port1,250,254 );
  ReefAngel.StandardLights( Port7,17,0,20,0 );
  ReefAngel.DCPump.UseMemory = true; 
  ReefAngel.DCPump.SetMode( ReefCrest,100,10 ); R
  ReefAngel.DCPump.DaylightChannel = Sync; 
  ReefAngel.DCPump.ActinicChannel = Sync;
  ////// Place your custom code below here
 if (ReefAngel.DCPump.Mode==Custom)
    {
      ReefAngel.PWM.SetDaylight( ElseMode(70,30,true ));                     // ElseMode on sync mode, 70 +/- 30%
    ReefAngel.DCPump.UseMemory = false;
    } else {
    ReefAngel.DCPump.UseMemory = true;
    }
       
         static time_t StartFeeding=0;
          if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            StartFeeding=now(); // if we entered feeding mode, register what time it was.
          if (now()-StartFeeding > 1800 && now()-StartFeeding < 5400) // if feeding started between 1800 and 5400 seconds
            ReefAngel.PWM.SetActinic(100);
          else   
            ReefAngel.PWM.SetActinic(45);
  ////// Place your custom code above here

  // This should always be the last line 
  ReefAngel.Portal( "anderzon_" );
  ReefAngel.ShowInterface();
 }
 
     void DrawCustomMain()
    {
        int x,y;
        char text[10];
        // Parameters
    #if defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
        ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
    #else // defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
    #endif // defined DisplayLEDPWM && ! defined RemoveAllLights
        pingSerial();

        // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
        pingSerial();

        // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
        TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
        ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
        pingSerial();

        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 122 );
        pingSerial();
    }

    void DrawCustomGraph()
    {
        ReefAngel.LCD.DrawGraph( 5, 5 );
    }
        byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
        {
          // Static's only initialize the first time they are called
          static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
          static int Delay = random( 500, 3000);           // Set the initial delay
          static int NewSpeed = MidPoint;                  // Set the initial speed
          static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
          if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
          {
            Delay=random(500,5000);                        // If so, come up with a new delay
            int ChangeUp = random(Offset);                 // Amount to go up or down
            if (random(100)<50)                            // 50/50 chance of speed going up or going down
            {
              NewSpeed = MidPoint - ChangeUp;
              AntiSpeed = MidPoint + ChangeUp;
            }
            else
            {
              NewSpeed = MidPoint + ChangeUp;
              AntiSpeed = MidPoint - ChangeUp;
            }
            LastChange=millis();                           // Reset the time of the last change
          }
          if (WaveSync)
          {
            return NewSpeed;
          }
          else
          {
            return AntiSpeed;
          }
        }
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: My Jebao "Else" mode

Post by Sacohen »

I'm not the best with code, but it looks like you have it to run ReefCrest mode unless you put it in custom and then it will run Else mode.

Is that what you want?
anderzon_
Posts: 67
Joined: Sun Oct 27, 2013 11:35 am

Re: My Jebao "Else" mode

Post by anderzon_ »

right now I run reef crest. I want to be able to choose between programs from the portal.
howaboutme
Posts: 246
Joined: Tue Jan 28, 2014 11:10 am
Location: Northern VA

Re: My Jebao "Else" mode

Post by howaboutme »

I am just plugged in my wp-25 last night and have it running on constant mode at a low power %. I created the code from the Wizard. Now I cant to get into something similar to what's in this thread but I am at a lost as to where to begin. I have been trying to look through codes and comments and have been getting confused. What is also confusing me is that this (and others) are older threads and I know that the current libraries have all (or most?) of the wave patterns built in which simplifies the code. For those reasons, I don't want to just do some copy and pasting and have things not go right.

I like this thread because it's dealing w/ else mode w/ 1 pump (or at least it started out this way) and that's my current set up. What I eventually want to do is use the else mode when the lights are on and then ramp down the pump the remainder of the day/night at a low power (like 30%, constant). But before I get into the schedule code, I want to get the else mode to work.

First question:
Where does this go in the code?

Code: Select all

Call with ElseMode( MidPoint, Offset, Sync )
Or is it not code since i dont even see the exact wording in other codes.

2nd question:
Can anyone help me (based on the code in this thread for 1 pump) figure out what the code is? The only difference is I do not want the pump to go higher than 45% (assume lowest is still 30%) and I have my 1 pump plugged into the actinic port. I may adjust that later as I get my tank accustomed to the extra flow. There never was one last post on this thread that states what the correct code is after reconciling all of the problems, questions, answers, etc.

3rd question:
Will I be able to make adjustments on the fly for this mode and will I be able to switch to the pre-set modes via the portal?

Excuse me if these have been answered in 1 way shape or form. It's just confusing for a newbie when I reconcile different posts about the same, or somewhat the same, subject matter. Thanks in advance!
Jack
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: My Jebao "Else" mode

Post by cosmith71 »

Put this in your loop() section:

Code: Select all

  ReefAngel.PWM.SetActinic( ElseMode(37,7,true));                     // ElseMode on sync mode, 37 +/- 7%
This will get you a range from 30-44% 37 +/- 7%). The "true" sets sync mode, which really doesn't matter since you're only using one pump. It has to be there for the sake of proper syntax.

I have no clue about the Portal question. I don't use it that way. Maybe someone else can chime in?

Hope this helps,

--Colin
Post Reply