Page 1 of 1

Can I have a port turn on & then back on & off again later?

Posted: Sat Oct 18, 2014 4:49 pm
by DavidinGA
I have mh as my main lights and want to have my supplemental T5's run before the MH for a while and then come back on again an hour after the mh turn off; how would I do that?

Would this code work? I simply listed Port2 twice, does that work?

Code: Select all

{
    ReefAngel.StandardHeater( Port1,795,800 );  ////2 Heaters
    ReefAngel.StandardLights( Port2,14,0,17,0 ); ////T5 Lights 2pm to 5pm
    ReefAngel.StandardLights( Port2,23,0,24,0 ); ////T5 Lights 11pm to 12am
    ReefAngel.StandardLights( Port3,24,0,15,0 );   ////scrubber lights 12am-3pm  15hrs on 9off
    
    ReefAngel.StandardLights( Port5,17,0,23,0 ); ////Metal Halide 5pm to 11pm
    ReefAngel.DosingPumpRepeat( Port6,0,660,10 ); /////mag 720min = 11hrs  15ml day
    ReefAngel.DosingPumpRepeat( Port7,0,360,26 );  /////alk 360min = 6hrs  78ml day
    ReefAngel.DosingPumpRepeat( Port8,0,300,21 );  ////cal 300min = 5hrs   78.75ml day 3cups per gal
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,60,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if (hour()<8)
{




Full code if needed too:

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 = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 845 );

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


    // Ports that are always on

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


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

void loop()
{
    ReefAngel.StandardHeater( Port1,795,800 );  ////2 Heaters
    ReefAngel.StandardLights( Port2,14,0,17,0 ); ////T5 Lights 2pm to 5pm
    ReefAngel.StandardLights( Port2,23,0,24,0 ); ////T5 Lights 11pm to 12am
    ReefAngel.StandardLights( Port3,24,0,15,0 );   ////scrubber lights 12am-3pm  15hrs on 9off
    
    ReefAngel.StandardLights( Port5,17,0,23,0 ); ////Metal Halide 5pm to 11pm
    ReefAngel.DosingPumpRepeat( Port6,0,660,10 ); /////mag 720min = 11hrs  15ml day
    ReefAngel.DosingPumpRepeat( Port7,0,360,26 );  /////alk 360min = 6hrs  78ml day
    ReefAngel.DosingPumpRepeat( Port8,0,300,21 );  ////cal 300min = 5hrs   78.75ml day 3cups per gal
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,60,10 );
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
else if (hour()==8 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,85,20);
else if (hour()>=8 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,75,40 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,85,4 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ReefCrest,56,20 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( LongPulse,80,5 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( LongPulse,70,14 );
else if (hour()==23 && minute()<4)
ReefAngel.DCPump.SetMode( LongPulse,90,5);
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

{
   ReefAngel.AddWifi();
}

{
if (ReefAngel.Relay.Status(Port5)) 
  ReefAngel.StandardFan(Port4,813,820);
else
  ReefAngel.Relay.Off(Port4);
}
    ////// Place your custom code above here

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );    
    pingSerial();

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

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

void DrawCustomGraph()
{
}


Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 7:03 am
by cosmith71
I'm not sure if doing it twice will work or not. I don't think it will.

Something like this should. I'm just not sure about how midnight is handled. I think it just rolls over to 0.

Code: Select all

    if ((hour()>=14 && hour()<17) || (hour()>=23)) ReefAngel.Relay.On(Port4);
--Colin

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 8:31 am
by lnevo
Yep that should do it.

Putting the command twice for the same port will just end up doing the one that is last.

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 10:41 am
by DavidinGA
OK thanks.

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 12:51 pm
by cosmith71
Actually, lets change it to this just to be thorough:

Code: Select all

if ((hour()>=14 && hour()<17) || (hour()>=23)) ReefAngel.Relay.On(Port4);
    else ReefAngel.Relay.Off(Port4);
--Colin

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 1:08 pm
by lnevo
Actually you'd need that for sure. Good catch Colin!

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 1:48 pm
by cosmith71
Thanks! :geek:

Re: Can I have a port turn on & then back on & off again lat

Posted: Sun Oct 19, 2014 2:05 pm
by DavidinGA
It didn't work. It turned on at 2pm like it should but it was supposed to turn off at 5pm (run 2pm-5pm) but it stayed on...



***Edit...the "else" addition made it work.

Thanks