Page 5 of 5

Re: Dosing Pump not running on Schedule

Posted: Tue Jun 25, 2013 7:22 am
by lnevo
Yes, ato time is being backed up to to field 5 same as the alk and cal.

As far as keeping a running total, the problem is the field can't hold a number greater than 255.

We can do something else, but i'm working on something in my head that may help :)

Re: Dosing Pump not running on Schedule

Posted: Tue Jun 25, 2013 7:19 pm
by kirkwood
lnevo wrote:but i'm working on something in my head that may help :)
I'm listening..... ;-)

Re: Dosing Pump not running on Schedule

Posted: Tue Jun 25, 2013 8:20 pm
by lnevo
kirkwood wrote:
lnevo wrote:but i'm working on something in my head that may help :)
I'm listening..... ;-)
So...my RA knows when I refill my top off...and it knows how long it will last...it knows when I do water changes...It knows when my skimmate container is full... it knows when I last fed my fish (since setting up the AutoFeeder, I only feed frozen/manually once or twice a week) and of course as you said how much I'm dosing and how long my additives should last. (since I'm dosing by volume)

I think the only major tasks aside from cleaning glass, cleaning sponges, and changing filter socks is when I change my GFO and GAC.

Anyway what I was thinking of doing was coming up with some way to setup reminders for all my maintenance tasks. The main problem is that I don't want to store unsigned long numbers in memory and we need to be able to remember when things were done across resets..

I think I could do something similar to my acclimation routine where we keep a running countdown or count-up...till the task is due again or when last done.

In the case where we can calculate like additive refill or top off refill we can sub in our calculated numbers, We could easily trigger a reset function when we refill our dosing containers.. Or media reactor changing...using a byte we could then store countdowns almost 8 months long (RO/DI filter changes?)

We could then store the tasks in a byte using bit flags to indicate what needs to be done...or us WiFiAlert to send a reminder.

Hard part is making it easy to use.... :)

Re: Dosing Pump not running on Schedule

Posted: Fri Aug 23, 2013 12:27 am
by alexwbush
Lee, looking for some assistance with the code you've posted or what I might be missing.

Here is my current code:

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>

/*Port Designations
Port1 - Dosing Pump 1 (every 60min for 10s)
Port2 - Dosing Pump 2 (every 60min for 10s w/5 min offset)
Port3 - Left Radion
Port4 - Right Radion
Port5 - Heater
Port6 - ATO
Port7 - Skimmer
Port8 - Return

Box1_Port1 - Vortech
Box1_Port2 - Cabinet LED
*/

// Define Relay Ports by Name
#define DPump1             1
#define DPump2             2
#define LeftRadion         3
#define RightRadion        4
#define Heater             5
#define ATOPort            6
#define Skimmer            7
#define Return             8

#define Vortech            Box1_Port1
#define CabinetLED         Box1_Port2
#define Unused             Box1_Port3
#define Unused             Box1_Port4
#define Unused             Box1_Port5
#define Unused             Box1_Port6
#define Unused             Box1_Port7
#define Unused             Box1_Port8

// Initialize Buzzer variables
byte buzzer=0;
byte overheatflag=0;
byte atoflag=0;

////// Place global variable code below here
time_t running1, running2; //Records run time for dosing pumps (i.e. running1 = time for DP1)

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


    // Ports that are always on
    ReefAngel.Relay.On( LeftRadion );
    ReefAngel.Relay.On( RightRadion );
    ReefAngel.Relay.On( Return );
    ReefAngel.Relay.On( Vortech );

//    ATO locked on for now    
    ReefAngel.Relay.On( ATOPort );

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

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

void loop()
{
    ReefAngel.DosingPumpRepeat1( DPump1 ); //every 60min for 10s
//    Other format ReefAngel.DosingPumpRepeat( Port3,10,360,10 );
    ReefAngel.DosingPumpRepeat2( DPump2 ); //every 60min for 10s w/5 min offset
    ReefAngel.StandardHeater( Heater );
//    ReefAngel.StandardATO( ATOPort );
    ReefAngel.Relay.DelayedOn( Skimmer );
    ReefAngel.Relay.Set( CabinetLED, !ReefAngel.Relay.Status( Vortech ) );
    ReefAngel.PWM.SetActinic( MoonPhase() );
    ReefAngel.RF.UseMemory = true;
    ReefAngel.RF.ChannelWhiteParabola();
    ReefAngel.RF.ChannelRoyalBlueParabola();
    ReefAngel.RF.ChannelRedParabola();
    ReefAngel.RF.ChannelGreenParabola();
    ReefAngel.RF.ChannelBlueParabola();
    ReefAngel.RF.ChannelIntensityParabola();
    overheatflag = InternalMemory.read( Overheat_Exceed_Flag );
    atoflag = InternalMemory.read( ATO_Exceed_Flag );
    buzzer = overheatflag + atoflag;
    if ( buzzer >= 1 ) buzzer = 100;
    ReefAngel.PWM.SetDaylight( buzzer );

    ////// Place your custom code below here
    
    //*******************Dosing and ATO Pump Logging************************



const byte numPumps=3;
byte pump[numPumps] = { DPump1, DPump2, ATOPort };
byte portalMinutes[numPumps] = { 0, 2, 4 };
byte portalSeconds[numPumps] = { 1, 3, 5 };

static time_t pumpTimer[numPumps];
static boolean pumpStatus[numPumps];
static boolean atoDisabled;
static boolean clearTimer;

if (now()%SECS_PER_DAY!=SECS_PER_DAY-1) clearTimer=true;
if ( (now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer==true) {
// Backup timers to portal variable
ReefAngel.CustomVar[portalSeconds[0]] = pumpTimer[0]/60;
ReefAngel.CustomVar[portalSeconds[1]] = pumpTimer[1]/60;
ReefAngel.CustomVar[portalSeconds[2]] = pumpTimer[2]/60;
pumpTimer[0]=0; // Clear timer for DPump1
pumpTimer[1]=0; // Clear timer for DPump2
clearTimer=false;
} 
for (int i=0;i< numPumps;i++) {
  if (ReefAngel.Relay.Status(pump[i])) {
    if (!pumpStatus[i]) {
      pumpTimer[i]=now()-pumpTimer[i]; // Pump was off, timer is now a time
      pumpStatus[i]=true;
    }
  } else {
    if (pumpStatus[i]) {
      pumpTimer[i]=now()-pumpTimer[i]; // Pump was on, timer is now a timer
      pumpStatus[i]=false;

      // Normalize and assign to CustomVar for reporting on the portal
      ReefAngel.CustomVar[portalMinutes[i]]=pumpTimer[i]/60; // Number of Minutes
//      ReefAngel.CustomVar[portalSeconds[i]]=pumpTimer[i]%60; // Number of Seconds
    }
  }
}


if (now()%SECS_PER_DAY==SECS_PER_DAY-1) {
    // Backup timers to portal variable
    ReefAngel.CustomVar[portalSeconds[0]] = pumpTimer[0]/60;
    ReefAngel.CustomVar[portalSeconds[1]] = pumpTimer[1]/60;
    ReefAngel.CustomVar[portalSeconds[2]] = pumpTimer[2]/60;
    pumpTimer[0]=0; // Clear timer for Port3
    pumpTimer[1]=0; // Clear timer for Port4
}

if (bitRead(ReefAngel.Relay.RelayMaskOff, 6)==0) { // ATO relay is manually disabled
  atoDisabled=true;
} 
if (atoDisabled && (bitRead(ReefAngel.Relay.RelayMaskOff, 6)==1)) { // ATO override has been cleared
  pumpTimer[2]=0; // Clear timer for Port7
  atoDisabled=false;
}

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

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

// Add this for more than 1 screen
#define NumScreens 2
int ScreenID=0;

void DrawCustomMain()
{
  switch (ScreenID)
  {
  case 0:
    {
      //Draw screen 0
        byte x = 6;
  byte y = 2;
  byte t;
  byte radionchannel=0;
  byte radiontext=0;
  byte radioncolor=0;
  char text[7];

  /* Drawing this:
   
   01/01/12 00:00:00 AM
   ----------------------
   Disp 79.9  pH     8.00
   Sump 79.9  Sal    0.60
   Room 77.7  WtrLvl Ok
   
   1 2 3 4 5 6 7 8
   1 2 3 4 5 6 7 8
   
   Moon Waning Crescent
   Intensity 88%
   Sunrise   06:15
   Sunset    18:12
  */
   
  /* Colors used in this script:
     DefaultFGColor   - For basic font and line
     DefaultBGColor   - For background color
     PHColor          - For values that may change
     OutletOnBGColor  - For okay water level
     OutletOffBGColor - For low water level
     
     To change colors, modify these values in ReefAngel_CustomColors.h file
  */

  ReefAngel.LCD.DrawDate(6, 2);
  ReefAngel.LCD.Clear(DefaultFGColor, 1, 11, 128, 11);
  pingSerial();

  //ReefAngel.LCD.DrawText(fcolor,bcolor,x,y,"text");

  //Line 1 - Display Temp & pH
  x = 8;
  y = 15;
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Disp");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], PHColor, x, y, 10);
  x = 70; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"pH");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.PH, PHColor, x, y, 100);

  //Line 2 - Sump & Salinity
  x = 8;
  y += 10; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sump");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], PHColor, x, y, 10);
  x = 70; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Sal");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Salinity, PHColor, x, y, 10);

  //Line 3 - Room
  x = 8;
  y += 10; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Room");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], PHColor, x, y, 10);
  x = 70;
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"WL");
  x += 30;
  ReefAngel.LCD.DrawSingleMonitor(ReefAngel.WaterLevel.GetLevel(), PHColor, x, y, 1);
  
 
  //Lines 4 and 5 - Relays
  x = 12; 
  y += 12;
  // draw main relay
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox(x, y, TempRelay);

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

  

  pingSerial();
  break;
    }
  case 1:
    {
      //Draw quick screen
      byte x = 6;
      byte y = 2;
      byte t;
      byte radionchannel=0;
      byte radiontext=0;
      byte radioncolor=0;
      char text[7];

      /* Drawing this:
   
       01/01/12 00:00:00 AM
       ----------------------
       79.9 79.7 77.7    34.5
       Sump 79.9  Sal    34.5
       Room 77.7  WtrLvl 77
   
       1 2 3 4 5 6 7 8
       1 2 3 4 5 6 7 8
   
       Moon Waning Crescent
       Intensity 88%
       Sunrise   06:15
       Sunset    18:12
    */
   
    /* Colors used in this script:
       DefaultFGColor   - For basic font and line
       DefaultBGColor   - For background color
       PHColor          - For values that may change
       OutletOnBGColor  - For okay water level
       OutletOffBGColor - For low water level
     
       To change colors, modify these values in ReefAngel_CustomColors.h file
    */

    ReefAngel.LCD.DrawDate(6, 2);
    ReefAngel.LCD.Clear(DefaultFGColor, 1, 11, 128, 11);
    pingSerial();

    //ReefAngel.LCD.DrawText(fcolor,bcolor,x,y,"text");

    //Line 1 - Display Temp & pH
    x = 8;
    y = 15;
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T1_PROBE], PHColor, x, y, 10);
    x += 30;
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], PHColor, x, y, 10);
    x += 30;
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], PHColor, x, y, 10);
    x += 40;
    ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Salinity, PHColor, x, y, 10); 

  

  //Line 3
  x = 8;
  y += 10; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Work in Progress");
  
  x = 8;
  y += 10; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"Push Joystick Left");
  
  x = 8;
  y += 10; 
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,x,y,"to return to main display");
  
      break;
    }
  }
  if (ReefAngel.Joystick.IsLeft())
  {
    ReefAngel.ClearScreen(DefaultBGColor);
    ScreenID--;
  }
  if (ReefAngel.Joystick.IsRight())
  {
    ReefAngel.ClearScreen(DefaultBGColor);
    ScreenID++;
  }
  if (ScreenID<0) ScreenID=NumScreens-1;
  if (ScreenID>=NumScreens) ScreenID=0; 
}


  // PWM Parameters
/*#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 10, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();
*/

void DrawCustomGraph()
{
}
Ignore all the silly stuff I am playing with still, I edited them out to get this working.

When I go to the variables, I don't even see a chart. Any ideas?
http://forum.reefangel.com/status/chart ... &filter=c0
http://forum.reefangel.com/status/chart ... &filter=c1
http://forum.reefangel.com/status/chart ... &filter=c2
http://forum.reefangel.com/status/chart ... &filter=c3
http://forum.reefangel.com/status/chart ... &filter=c4
http://forum.reefangel.com/status/chart ... &filter=c5

Re: Dosing Pump not running on Schedule

Posted: Fri Aug 23, 2013 5:42 am
by lnevo
What errors are you getting and what do you mean by a chart?

Re: Dosing Pump not running on Schedule

Posted: Fri Aug 23, 2013 12:15 pm
by alexwbush
I am not getting any errors. The problem is the chart doesn't even show. So when you click on any of those links... no graph or anything.

Re: Dosing Pump not running on Schedule

Posted: Fri Aug 23, 2013 3:54 pm
by lnevo
The links in the post were specific to the op. are you just clicking them or did you modify the url?

Re: Dosing Pump not running on Schedule

Posted: Fri Aug 23, 2013 6:14 pm
by alexwbush
lnevo wrote:The links in the post were specific to the op. are you just clicking them or did you modify the url?
I modified them for my portal ID "alexwbush"