Page 1 of 1

moon lights always on and jebao portal problem

Posted: Sun Jun 01, 2014 5:38 pm
by psyrob
I've got two problems:
My moonlights stay on 24/7, I want them to go off when the moon isn't up. I am using moonphase from the wizard set up.

Also, I can't control my jebao from the portal, meaning I can't change wave settings from the portal. What I want to do is either set the portal to "custom" and have it run my code (else mode during the day, sine at night) or take the portal off custom and be able to change it to some other wave pattern.

Here is the code...any ideas are appreciated...
Thanks
Rob

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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

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


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

    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Frag Pump";  
    ReefAngel.CustomLabels[1]="Actinics";  
    ReefAngel.CustomLabels[2]="Daylights";  
    ReefAngel.CustomLabels[3]="Frag LED";  
    ReefAngel.CustomLabels[4]="ATO Pump";  
    ReefAngel.CustomLabels[5]="Reactor";  
    ReefAngel.CustomLabels[6]="Heater";  
    ReefAngel.CustomLabels[7]="Fan";  

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.ActinicLights( Port2 );
    ReefAngel.DayLights( Port3 );
    ReefAngel.ActinicLights( Port4 );
    ReefAngel.SingleATOLow( Port5 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.StandardFan( Port8 );
    ReefAngel.PWM.SetDaylight( MoonPhase() );
    ReefAngel.DCPump.UseMemory = true;
   
 
       if (hour()>=8 && hour()<21)
   
     {
             
        if (ReefAngel.DCPump.Mode==Custom)
          {
         ReefAngel.PWM.SetActinic(ElseMode(65, 20, true));
         
            ReefAngel.DCPump.UseMemory = false;
          } 
          
          else
            {
            ReefAngel.DCPump.UseMemory = true;
            }
      }
           
          else 
         {
         ReefAngel.PWM.SetActinic(SineMode(75,35, 15, true));
         }
           
    
  
    ////// Place your custom code below here
    

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

    // This should always be the last line
    ReefAngel.Portal( "psyrob" );
    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, 1500);           // 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;
  }
}
   

Re: moon lights always on and jebao portal problem

Posted: Mon Jun 02, 2014 8:06 am
by rimai
I think this is what you want:

Code: Select all

ReefAngel.DCPump.UseMemory = true;
if (hour()>=8 && hour()<21)
{
  ReefAngel.PWM.SetDaylight(0);
  if (ReefAngel.DCPump.Mode==Custom)
  {
    ReefAngel.PWM.SetActinic(ElseMode(65, 20, true));
  }
  else 
  {
    ReefAngel.PWM.SetActinic(SineMode(75,35, 15, true));
  }
}

Re: moon lights always on and jebao portal problem

Posted: Tue Jun 03, 2014 9:27 pm
by psyrob
Thanks, I tried it, but it's just running sine mode no matter what I do on the portal...changing to other wave patterns or to custom, doesn't change how the pump is running...

moon lights always on and jebao portal problem

Posted: Wed Jun 04, 2014 4:03 am
by lnevo
Is the mode set to custom? Nvm reread.. Not sure, code looks fine.

Re: moon lights always on and jebao portal problem

Posted: Wed Jun 04, 2014 6:01 am
by howaboutme
I think this:

Code: Select all

if (hour()>=8 && hour()<21)
Needs to be after this:

Code: Select all

{
             
        if (ReefAngel.DCPump.Mode==Custom)
This is my code for reference. It does very similar to yours:

Code: Select all

     if (ReefAngel.DCPump.Mode==Custom)
                {
                  if ( (now()%SECS_PER_DAY >= 77400) || (now()%SECS_PER_DAY<= 34200) )
                  {
                    ReefAngel.PWM.SetActinic(30); // Constant at 30% on sync mode
                  }
                  else if ( (now()%SECS_PER_DAY >= 34200) && (now()%SECS_PER_DAY<= 48600) )
                  {
                    ReefAngel.PWM.SetActinic(33); // Constant at 33% on sync mode
                  }
                  else if ( (now()%SECS_PER_DAY >= 48600) && (now()%SECS_PER_DAY<= 77400) )
                  {
                    ReefAngel.PWM.SetActinic( ElseMode(37,7,true));   // Else on sync mode, 37 +/- 7%
                  }
                }  
Look at my thread here:

http://forum.reefangel.com/viewtopic.ph ... 5&start=20