Page 1 of 1

Need a little help again

Posted: Mon Feb 11, 2013 8:25 am
by treetopflyn
I want to start over with my code as I was having a little trouble and wanted to eliminate a couple of things.
Below is my current code. For now the only things I would like to add is

1. Starting at 7:00am I would like one of the Wave Maker outlets to stay on for 3.5 hours while the other one switches on and off randomly. Every 3.5 hours I would like them to switch with both going off at 9pm and restarting at the cycle at 7:00am.


Roberto I know you did this for me before but I can't figure out what and where to add it in this code.


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


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

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


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

void loop()
{
ReefAngel.StandardATO( Port1,60 );
if (hour()>=21 || hour()<7)
{
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
}
else
{
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
}
else
{
ReefAngel.WavemakerRandom1( Port5,30,90 );
ReefAngel.WavemakerRandom2( Port6,30,90 );
}
}
ReefAngel.Relay.DelayedOn( Port7,0 );
////// Place your custom code below here


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

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

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

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

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

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

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

void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}

Re: Need a little help again

Posted: Mon Feb 11, 2013 10:32 am
by rimai

Re: Need a little help again

Posted: Mon Feb 11, 2013 10:36 am
by treetopflyn
I no longer wanted the pumps coming on for 10 min when the ATO comes on, so I went back to my original code. This stuff is all greek to me so I had no clue what to remove/insert so I went back to the code I knew worked without the ATO code

Re: Need a little help again

Posted: Mon Feb 11, 2013 10:43 am
by rimai
Let's try this:

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


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

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


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

void loop()
{
  ReefAngel.StandardATO( Port1,60 );
  if (hour()>=21 || hour()<7)
  {
    ReefAngel.Relay.Off(Port5);
    ReefAngel.Relay.Off(Port6);
  }
  else
  {
    if (ReefAngel.DisplayedMenu==FEEDING_MODE)
    {
      ReefAngel.Relay.On(Port5);
      ReefAngel.Relay.On(Port6);
    }
    else
    {
//      ReefAngel.WavemakerRandom1( Port5,30,90 );
//      ReefAngel.WavemakerRandom2( Port6,30,90 );
      if (elapsedSecsToday(now())%25200<12600)
      {
        ReefAngel.WavemakerRandom1( Port5,30,90 );
        ReefAngel.Relay.On(Port6);
      }
      else
      {
        ReefAngel.Relay.On(Port5);
        ReefAngel.WavemakerRandom2( Port6,30,90 );
      }
    }
  }
  ReefAngel.Relay.DelayedOn( Port7,0 );
  ////// Place your custom code below here


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

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

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

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

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

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

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

void DrawCustomGraph()
{
  ReefAngel.LCD.DrawGraph( 5, 5 );
}


Re: Need a little help again

Posted: Mon Feb 11, 2013 11:11 am
by treetopflyn
Appears to be working. I'll know for sure at 2:00 when they should switch. Thank you very much.

K