Dosing Pump not running on Schedule

Do you have a question on how to do something.
Ask in here.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

Nevermind I know what the problem was. We need to make sure that the clearing and backing up only happens once. Right now it's happening a few times for the second before midnight which is not what we want because it's lost after the first run. Anyway, here's a fix.

Code: Select all

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 Port3
pumpTimer[1]=0; // Clear timer for Port4
clearTimer=false;
}
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

Got an error on this line of code:

if (now()%SECS_PER_DAY==SECS_PER_DAY-1 && clearTimer=true) {

1value required as left operand of assignment
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

Sorry put () around the first test :)

if ( (now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer=true) {
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

lnevo wrote:Sorry put () around the first test :)

if ( (now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer=true) {
It still gives the same error.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Dosing Pump not running on Schedule

Post by rimai »

It need to be like this:
if ( (now()%SECS_PER_DAY==SECS_PER_DAY-1) && clearTimer==true) {
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

Thanks :)
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

I loaded the new code this afternoon so I will report back tomorrow
Image
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

kirkwood wrote:I loaded the new code this afternoon so I will report back tomorrow
Success!
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

Whew :)
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

Everything has been working well but this morning I noticed something that didn't make sense. Custom Fields 4 and 5 are my ATO minutes and ATO seconds, respectively. This morning field 4 was 62 and field 5 was 62. That makes me wonder if field 5 is programmed to pull the field 4 value at 11:59pm each night like my ALK and CAL. It doesn't really matter to me either way because the ATO seconds value is of little consequence.

I had a final idea on tracking dosing values - right now we are tracking in field 0&2 the dosing minutes for the day that resets at the end of each day, field 1&3 that updates each night at 11:59pm with the value of fields 0&2. And then maybe we do fields that will keep a running total of minutes that carrys over from day to day so that I can track when my dosing reservoir is close to empty. Basically after field 1 updates with the total dose for the day, another field would add that number to its existing total and that would continue each day until I reset it in the same way I would reset the ATO via the masking function.

So basically in the end I would do Fields 0,3 for daily running tally of minutes, fields 1,4 that pulls field 0,3 value at 11:59pm each day, fields 2,5 that adds the value of field 1,4 to the existing value of field 2,5 each day, and field 6 would be my ATO minutes. Fields 2,5,6 would all need to be able to be reset via the masking functionality we've been using for the ATO.

I don't need this right now, as my code is working nicely right now and i'm about to put it to the test by heading out of town for a bit, so I don't want to load any new code that I will need to tinker with...
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post 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 :)
kirkwood
Posts: 173
Joined: Mon Apr 29, 2013 6:50 am

Re: Dosing Pump not running on Schedule

Post by kirkwood »

lnevo wrote:but i'm working on something in my head that may help :)
I'm listening..... ;-)
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post 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.... :)
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Dosing Pump not running on Schedule

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

What errors are you getting and what do you mean by a chart?
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Dosing Pump not running on Schedule

Post 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.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Dosing Pump not running on Schedule

Post by lnevo »

The links in the post were specific to the op. are you just clicking them or did you modify the url?
alexwbush
Posts: 327
Joined: Tue Mar 22, 2011 12:45 am
Location: San Diego, CA

Re: Dosing Pump not running on Schedule

Post 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"
Post Reply