Trying to set multiple on off times for 1 port

New members questions
Post Reply
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Trying to set multiple on off times for 1 port

Post by Elevatorguy1 »

Hello,

Total newbie here.

I've been looking for a simple way to turn my Kalk reactor on and off a couple times a day. I tried the standard lights but this only allows one on/off time.

Is there a simple way to do this?

Here's the code that I've come up with so far.
#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
    ReefAngel.AddStandardMenu(); // Add Standard Menu

    // 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 = Port1Bit | Port3Bit | Port4Bit | Port8Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 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( 869 );


    // Ports that are always on

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

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

void loop()
{
    ReefAngel.StandardLights( Port1,22,30,13,30 ); //*sump fuge light
    ReefAngel.StandardLights( Port2,13,30,22,30 ); //*top fuge light
    ReefAngel.StandardLights( Port3,13,30,22,30 ); //*Actinic
    ReefAngel.StandardLights( Port4,13,30,22,30 ); //*Daylight
    ReefAngel.StandardLights( Port5,0,0,0,1 ); //*kalk reactor
    ReefAngel.StandardATO( Port6,6000 ); //*Fresh water solenoid
    ReefAngel.StandardHeater( Port7,775,785 );
    ReefAngel.StandardLights( Port8,13,30,22,30 ); //*Light fan
    ReefAngel.PWM.SetDaylight( PWMSlope(13,30,22,30,5,60,30,5) );
    ReefAngel.PWM.SetActinic( PWMSlope(13,30,22,30,5,70,30,5) );
    ////// Place your custom code below here
    

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

    // This should always be the last line
    ReefAngel.ShowInterface();
}
void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

    
     
      ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Gonzo's Reef"); // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119); // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11); // Draw a black line under the banner
      x = 12;
      y += MENU_START_ROW+1; // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100); // Get pH reading and convert
      ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16); // Put pH on the screen
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10); // Get T1 temp and convert
      y += MENU_START_ROW*2;
      x = 10;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, COLOR_BLACK, x, y, text); // Draw the temperature, white numbers on a colored background
      x += (16*4) + 8;
      ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,8,y+25,"White %");
      ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, 24, y+35, 1); // Draw the white light %
      ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+8,y+25,"Blue %");
      ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+24, y+35, 1); // Draw the blue light %

      // Code for drawing the relay box
     byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
    }

void DrawCustomGraph()
{
}        

  
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Trying to set multiple on off times for 1 port

Post by rimai »

Very good start!!!
What about using dosing pump function?
How often and how long do you want to turn it on?
Roberto.
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Re: Trying to set multiple on off times for 1 port

Post by Elevatorguy1 »

Thanks Roberto!

Hmm. I did see that in the wizard. For now would like the reactor to turn on at 12:00am and off at 12:01am then a second time at 12:00pm and off at 12:01pm. Depending on cal and alk demands there maybe be a need in the future to turn the reactor on more than 2 times.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Trying to set multiple on off times for 1 port

Post by rimai »

Use something this then:

Code: Select all

ReefAngel.Relay.Set(Port1,now()%43200<60);
This code means it will turn on Port1 for 60s every 43200 seconds.
Roberto.
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Re: Trying to set multiple on off times for 1 port

Post by Elevatorguy1 »

You are fast!!!!

I went back to the wizard and used the dosing pump selection and came up with this. would this work?

#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
ReefAngel.AddStandardMenu(); // Add Standard Menu

// 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 = Port1Bit | Port3Bit | Port4Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 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( 869 );


// Ports that are always on

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


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

void loop()
{
ReefAngel.StandardLights( Port1,22,30,13,30 ); //*sump fuge light
ReefAngel.StandardLights( Port2,13,30,22,30 ); //*top fuge light
ReefAngel.StandardLights( Port3,13,30,22,30 ); //*Actinic
ReefAngel.StandardLights( Port4,13,30,22,30 ); //*Daylight
ReefAngel.DosingPumpRepeat( Port5,0,720,60 ); //*kalk reactor
ReefAngel.StandardATO( Port6,6000 ); //*Fresh water solenoid
ReefAngel.StandardHeater( Port7,775,785 );
ReefAngel.StandardLights( Port8,13,30,22,30 ); //*Light fan
ReefAngel.PWM.SetDaylight( PWMSlope(13,30,22,30,5,60,30,5) );
ReefAngel.PWM.SetActinic( PWMSlope(13,30,22,30,5,70,30,5) );
////// Place your custom code below here


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

// This should always be the last line
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
byte x;
byte y = 2;
char text[7];



ReefAngel.LCD.DrawText(DefaultFGColor, DefaultBGColor, 30, 2, "Gonzo's Reef"); // Put a banner at the top
ReefAngel.LCD.DrawDate(6, 119); // Put the date and time at the bottom
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11); // Draw a black line under the banner
x = 12;
y += MENU_START_ROW+1; // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
ReefAngel.LCD.DrawText(COLOR_BLUE, COLOR_WHITE, x, y+6, "Tank Temp pH");
ConvertNumToString(text, ReefAngel.Params.PH, 100); // Get pH reading and convert
ReefAngel.LCD.DrawLargeText(PHColor, DefaultBGColor, x+75, y+18, text, Font8x16); // Put pH on the screen
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10); // Get T1 temp and convert
y += MENU_START_ROW*2;
x = 10;
ReefAngel.LCD.DrawHugeNumbers(COLOR_WHITE, COLOR_BLACK, x, y, text); // Draw the temperature, white numbers on a colored background
x += (16*4) + 8;
ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,8,y+25,"White %");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, 24, y+35, 1); // Draw the white light %
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+8,y+25,"Blue %");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(), APColor, x+24, y+35, 1); // Draw the blue light %

// Code for drawing the relay box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 92, TempRelay);
}

void DrawCustomGraph()
{
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Trying to set multiple on off times for 1 port

Post by rimai »

Yeah, works too...
Roberto.
Elevatorguy1
Posts: 42
Joined: Wed Apr 17, 2013 6:21 pm

Re: Trying to set multiple on off times for 1 port

Post by Elevatorguy1 »

Thanks Roberto!

Really happy with my RA and its not even on the tank yet. Really nice to be able to lay out what you need and your fantastic support. You're best Roberto!
Post Reply