Page 1 of 1

Feed Mode

Posted: Fri Jul 12, 2013 5:15 pm
by ganjero
I have two jebao pumps on my dimming ports, one in the display and one in the sump. What I need is the one in the display to run in the custom random ode 24/7 and the one in the sump to run at a constant flow at 30% and 30min after feed mode is entered run at 100% for an hour.

Thanks

Re: Feed Mode

Posted: Sat Jul 13, 2013 8:06 am
by rimai
There are several random modes in the forums. Pick the one you like and use it.
For the feeding override, try this:

Code: Select all

  static 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(30);

Re: Feed Mode

Posted: Sat Jul 13, 2013 8:20 am
by lnevo
static time_t StartFeeding=0;

Re: Feed Mode

Posted: Sat Jul 13, 2013 8:27 am
by rimai
:) good catch

Re: Feed Mode

Posted: Sat Jul 13, 2013 12:34 pm
by ganjero
Thank you, I'll try it out Im new to this controller and languange. COuld you please point out where do I insert that in my code?

Thanks

Re: Feed Mode

Posted: Mon Jul 15, 2013 6:46 pm
by ganjero
Tried the above but the pump runs at 45% constant but it doesnt do the 100% 1 hours that I want

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
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port7Bit | Port8Bit;
    ReefAngel.FeedingModePortsE[0] = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port4Bit;
    ReefAngel.LightsOnPortsE[0] = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit;
    ReefAngel.OverheatShutoffPortsE[0] = 0;
    // Use T2 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 851 );

    // Feeeding and Water Change mode speed
      


    // Ports that are always on
    ReefAngel.Relay.On( Port8 );
    ReefAngel.Relay.On( Box1_Port1);
    ReefAngel.Relay.On( Box1_Port2 );
    ReefAngel.Relay.On( Box1_Port3 );
    ReefAngel.Relay.On( Box1_Port4 );
    ReefAngel.Relay.On( Box1_Port7 );
    ReefAngel.Relay.On( Box1_Port8 );
    

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

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

void loop()
{
    ReefAngel.StandardLights( Port1,14,0,19,0 );
    ReefAngel.StandardLights( Port2,15,0,20,0 );
    ReefAngel.StandardLights( Port3,19,55,22,0 );
    ReefAngel.StandardLights( Port4,14,0,20,15 );
    ReefAngel.StandardHeater( Port5,780,785 );
    ReefAngel.StandardFan( Port6,780,800 );
    ReefAngel.Relay.DelayedOn( Port7,60 );
    ReefAngel.StandardLights( Box1_Port5,22,0,16,0 );
    ReefAngel.DCPump.UseMemory = true;
    ////// Place your custom code below here
    
    if (ReefAngel.DCPump.Mode==Custom)
{
  ReefAngel.PWM.SetDaylight( ElseMode(70,30,true ));                     // ElseMode on sync mode, 70 +/- 30%
}
    
     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( "ganjero" );
    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;
      }
    }

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:08 pm
by rimai
I just tested this code and it worked just fine.
I changed 1800 seconds and 5400s to 18 and 54 to make it faster.

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:14 pm
by ganjero
rimai wrote:I just tested this code and it worked just fine.
I changed 1800 seconds and 5400s to 18 and 54 to make it faster.
When you tested the code (i assumed you tested my entire code? or was it just the feeding part?) after activating the feed mode it the actinic channel when to 100 after 18 seconds and back to 45 after 54?

Thanks

BTW how long is the feed mode and can you change the length of it?

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:16 pm
by rimai
Yes, I tested as is posted.
I started the feeding and stopped it after 1 second. It didn't want to wait for 15min :)

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:22 pm
by ganjero
rimai wrote:Yes, I tested as is posted.
I started the feeding and stopped it after 1 second. It didn't want to wait for 15min :)
Thank you, I have to try it again. I'm not sure if you saw my q above, can you change the length of the feed mode? Let's say to 5min

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:23 pm
by rimai
Use this:

Code: Select all

ReefAngel.Timer[FEEDING_TIMER].SetInterval(300);

Re: Feed Mode

Posted: Mon Jul 15, 2013 7:51 pm
by ganjero
Thanks again