How to code alk cal dosing pumps beyond basic wizard setup..

Do you have a question on how to do something.
Ask in here.
Post Reply
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

How to code alk cal dosing pumps beyond basic wizard setup..

Post by DavidinGA »

I setup two dosing pumps using the reef angel wizard and they have worked fine thus far; but I would like to be able to control exactly what time each day I dose by stating a time rather than the wizard way of doing it (dose for xx seconds every 60min or whatever).

Right now my 2 dosing pumps are port 7 and 8 below in the code.

ReefAngel.DosingPumpRepeat( Port7,0,480,25 );
ReefAngel.DosingPumpRepeat( Port8,0,480,24 );

So every 480 minutes they come on for 25sec and 24sec. How can I change this to a time format where I can put in say to dose port7 at 7:00am for 25 seconds then again at 7:00pm for 25 seconds and then something similar for port8

Thanks


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( 810 );

    // 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 );
    ReefAngel.StandardHeater( Port2,793,800 );
    ReefAngel.StandardLights( Port3,1,0,24,0 );
    ReefAngel.StandardLights( Port4,11,0,21,0 );
    ReefAngel.DosingPumpRepeat( Port6,0,240,600 );
    ReefAngel.DosingPumpRepeat( Port7,0,480,25 );
    ReefAngel.DosingPumpRepeat( Port8,0,480,24 );
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( LongPulse,40,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 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,80,10 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,60,5 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ShortPulse,70,10 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( ReefCrest,60,20 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( ShortPulse,80,10 );
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

    ////// 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()
{
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to code alk cal dosing pumps beyond basic wizard set

Post by rimai »

You can use something like this:

Code: Select all

if ( (hour()==7 && minute()==0 && second()<25) || (hour()==19 && minute()==0 && second()<25) )
  ReefAngel.Relay.On(Port7);
else
  ReefAngel.Relay.Off(Port7);

Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: How to code alk cal dosing pumps beyond basic wizard set

Post by DavidinGA »

rimai wrote:You can use something like this:

Code: Select all

if ( (hour()==7 && minute()==0 && second()<25) || (hour()==19 && minute()==0 && second()<25) )
  ReefAngel.Relay.On(Port7);
else
  ReefAngel.Relay.Off(Port7);


Ok.

If I do that do I leave my original code like it is and add your new code?

ReefAngel.DosingPumpRepeat( Port7,0,480,25 );

...or do I need to change it?





....and


Do I put that code right after ////// Place your custom code below here where my other custom code is?



{
ReefAngel.StandardHeater( Port1,795,800 );
ReefAngel.StandardHeater( Port2,793,800 );
ReefAngel.StandardLights( Port3,1,0,24,0 );
ReefAngel.StandardLights( Port4,11,0,21,0 );
ReefAngel.DosingPumpRepeat( Port6,0,240,600 );
ReefAngel.DosingPumpRepeat( Port7,0,480,25 );
ReefAngel.DosingPumpRepeat( Port8,0,480,24 );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( LongPulse,40,10 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
NEW CODE IN HERE?
if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
else if (hour()>=8 && hour()<10)
ReefAngel.DCPump.SetMode( ShortPulse,80,10 );
else if (hour()>=10 && hour()<12)
ReefAngel.DCPump.SetMode( LongPulse,60,5 );
else if (hour()>=12 && hour()<14)
ReefAngel.DCPump.SetMode( ShortPulse,70,10 );
else if (hour()>=14 && hour()<16)
ReefAngel.DCPump.SetMode( ReefCrest,60,20 );
else if (hour()>=16 && hour()<22)
ReefAngel.DCPump.SetMode( ShortPulse,80,10 );
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}

////// Place your custom code above here
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How to code alk cal dosing pumps beyond basic wizard set

Post by rimai »

Yes, place where you mentioned, but you must remove the old code.
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: How to code alk cal dosing pumps beyond basic wizard set

Post by DavidinGA »

rimai wrote:Yes, place where you mentioned, but you must remove the old code.

Thanks!
Post Reply