DC return pumps

Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Hey Lee, Did you ever get a chance to look into this?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: DC return pumps

Post by lnevo »

No :( I haven't even been here on the boards. Been so backed up at work with end of year. I do owe you a solution... will try by this weekend. Feel free to harass me on FB too :)
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Thanks! Appreciate you helping me on this.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: DC return pumps

Post by lnevo »

Ok, I think this should be good to get started. I've reviewed it a few times in my head. Let me know what you think.

Code: Select all

  static unsigned long levelHigh;
  static unsigned long pumpOff;
  static boolean pumpBool;
  
  if (ReefAngel.WaterLevel.GetLevel(3) < 50) levelHigh=now();
  if (now()-levelHigh > 20*SECS_PER_MINUTE && !pumpBool) {
    pumpBool=true;  
    pumpOff=now();
  }

  if (now()-pumpOff() < 5*SECS_PER_MINUTE) {
    ReefAngel.Relay.Off(Port1);
  } else { 
    ReefAngel.Relay.On(Port1);
    pumpBool=false;
  }
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

It appears to be what I was wanting. I will upload this later and let you know for sure.
Image
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Thanks Lee!
Image
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

I added this to my code but it did not compile. The first error was I had to change MINUTES to MIN. Now I get a few more.
Image
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Here is my 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 <Tide.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 <PAR.h>
#include <ReefAngel.h>



#define Level         79
#define MinPWM        45
#define OperatingPWM  68
long nummillis=5000;

byte PWMValue=0;
unsigned long lastmillis=millis();
boolean override=false;

static unsigned long levelHigh;
static unsigned long pumpOff;
static boolean pumpBool;

////// 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.Use2014Screen();  // Let's use 2014 Screen
  ReefAngel.DDNS("Damien"); 
  ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port5Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port3Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 800 );
  InternalMemory.WaterLevelMax_write(1800);        


  // Feeeding and Water Change mode speed


  // Ports that are always on
  ReefAngel.Relay.On( Port1 );
  ReefAngel.Relay.On( Port6 );

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


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

void loop()
{
  ReefAngel.StandardHeater( Port3,780,785 );
  ReefAngel.WaterLevelATO(4,Port4,240,28,31); 
  ReefAngel.Relay.Set(Port8, (now()%(6*SECS_PER_HOUR))<(30*SECS_PER_MIN));

  ////// Place your custom code below here

  PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)<Level-4)
  {
    override=true;
    lastmillis=millis();
    PWMValue+=2;
  }
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+2)
  {
    override=true;
    lastmillis=millis();
    PWMValue-=4;
  }
  if (millis()-lastmillis>nummillis && override)
  {
    override=false;
  }
  if (!override) PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+10) PWMValue=MinPWM;
  PWMValue=constrain(PWMValue,MinPWM,100);
  ReefAngel.PWM.SetActinic(PWMValue);
  
  if (ReefAngel.WaterLevel.GetLevel(3) < 50) levelHigh=now();
  if (now()-levelHigh > 20*SECS_PER_MIN && !pumpBool) {
    pumpBool=true;  
    pumpOff=now();
  }

  if (now()-pumpOff() < 5*SECS_PER_MIN) {
    ReefAngel.Relay.Off(Port1);
  } else { 
    ReefAngel.Relay.On(Port1);
    pumpBool=false;
  }


  if (ReefAngel.WaterLevel.GetLevel(1)<5) //Disable the port until overriden manually
    ReefAngel.Relay.Override(Port8,0);    //Saltwater Reservoir
  if (ReefAngel.WaterLevel.GetLevel(1)>80)   // Set port back to auto
    ReefAngel.Relay.Override(Port8,2); 

  if (ReefAngel.WaterLevel.GetLevel(2)>89) //Overflow
    ReefAngel.Relay.Off(Port1);
  else
    ReefAngel.Relay.On(Port1);

  if (ReefAngel.WaterLevel.GetLevel(3)>87) //ATO Reservoir
    ReefAngel.Relay.Off(Port5);
  if (ReefAngel.WaterLevel.GetLevel(3)<1)
    ReefAngel.Relay.On(Port5);


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

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










Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: DC return pumps

Post by lnevo »

Sorry, change pumpOff() to pumpOff.

Code: Select all

Sketch uses 60,092 bytes (23%) of program storage space. Maximum is 253,952 bytes.
Global variables use 2,978 bytes (36%) of dynamic memory, leaving 5,214 bytes for local variables. Maximum is 8,192 bytes.
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

So I finally installed the code you did for me today. I submersed the stand pipe for my sump level so it would activate. It shows that the sump level is at 82 and it was suppose to turn the return off when it was 50 or higher. I waited past the 16 minutes but nothing happened. Not sure what is going on. Here is my latest 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 <Tide.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 <PAR.h>
#include <ReefAngel.h>



#define Level         76
#define MinPWM        45
#define OperatingPWM  68
long nummillis=5000;

byte PWMValue=0;
unsigned long lastmillis=millis();
boolean override=false;

static unsigned long levelHigh;
static unsigned long pumpOff;
static boolean pumpBool;

////// 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.Use2014Screen();  // Let's use 2014 Screen
  ReefAngel.DDNS("Damien"); 
  ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port5Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port3Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 800 );
  InternalMemory.WaterLevelMax_write(1800);        


  // Feeeding and Water Change mode speed


  // Ports that are always on
  ReefAngel.Relay.On( Port1 );
  ReefAngel.Relay.On( Port6 );

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


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

void loop()
{
  ReefAngel.StandardHeater( Port3,780,785 );
  ReefAngel.WaterLevelATO(4,Port4,240,28,31); 
  ReefAngel.Relay.Set(Port8, (now()%(6*SECS_PER_HOUR))<(30*SECS_PER_MIN));

  ////// Place your custom code below here

  PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)<Level-4)
  {
    override=true;
    lastmillis=millis();
    PWMValue+=2;
  }
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+2)
  {
    override=true;
    lastmillis=millis();
    PWMValue-=4;
  }
  if (millis()-lastmillis>nummillis && override)
  {
    override=false;
  }
  if (!override) PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+10) PWMValue=MinPWM;
  PWMValue=constrain(PWMValue,MinPWM,100);
  ReefAngel.PWM.SetActinic(PWMValue);
  
  if (ReefAngel.WaterLevel.GetLevel(4) < 50) levelHigh=now();
  if (now()-levelHigh > 16*SECS_PER_MIN && !pumpBool) {
    pumpBool=true;  
    pumpOff=now();
  }

  if (now()-pumpOff < 15*SECS_PER_MIN) {
    ReefAngel.Relay.Off(Port1);
  } else { 
    ReefAngel.Relay.On(Port1);
    pumpBool=false;
  }


  if (ReefAngel.WaterLevel.GetLevel(1)<5) //Disable the port until overriden manually
    ReefAngel.Relay.Override(Port8,0);    //Saltwater Reservoir
  if (ReefAngel.WaterLevel.GetLevel(1)>80)   // Set port back to auto
    ReefAngel.Relay.Override(Port8,2); 

  if (ReefAngel.WaterLevel.GetLevel(2)>89) //Overflow
    ReefAngel.Relay.Off(Port1);
  else
    ReefAngel.Relay.On(Port1);

  if (ReefAngel.WaterLevel.GetLevel(3)>87) //ATO Reservoir
    ReefAngel.Relay.Off(Port5);
  if (ReefAngel.WaterLevel.GetLevel(3)<1)
    ReefAngel.Relay.On(Port5);


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

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










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

Re: DC return pumps

Post by rimai »

There are something not correct in your code.
You are using channel 2 for the pump control:

Code: Select all

  PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)<Level-4)
  {
    override=true;
    lastmillis=millis();
    PWMValue+=2;
  }
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+2)
  {
    override=true;
    lastmillis=millis();
    PWMValue-=4;
  }
And then the same channel for overfow control:

Code: Select all

  if (ReefAngel.WaterLevel.GetLevel(2)>89) //Overflow
    ReefAngel.Relay.Off(Port1);
  else
    ReefAngel.Relay.On(Port1);
So effectively, your first code does nothing.
The second code supersedes and then you will only get port1 off when level is greater than 89.
Roberto.
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

OK, I see now. That code shuts the return off if my overflow is greater than 89 so it won't overflow if my drain is plugged. What can I do if I want to keep that and still toggle port one when my sump level is too high for too long? Do I need to use a float switch in the sump instead of using the standpipe or is there something that can be changed in the code to allow me to use both codes simultaneously?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: DC return pumps

Post by rimai »

If the sump level is at 82 and your code is set to 89, it will never turn off.
Change 89 to something smaller.
Roberto.
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

I guess I'm still confused. The sump level was only at 82 because I submerged the standpipe to test the code. It's supposed to turn off the return when the level is 50 or higher for at least 16 minutes. Normal levels for the sump are around 30. The 89 is the max level of my overflow so it shuts off the return to keep it from overflowing the tank if there is blockage. Channel 2 is for my overflow and channel 4 is my sump.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: DC return pumps

Post by rimai »

Your code doesn't even use channel 4.
Roberto.
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Code: Select all

  if (ReefAngel.WaterLevel.GetLevel(4) < 50) levelHigh=now();
  if (now()-levelHigh > 16*SECS_PER_MIN && !pumpBool) {
    pumpBool=true;  
    pumpOff=now();
  }
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: DC return pumps

Post by rimai »

Sorry, I was looking at the code you posted before.
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 <Tide.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 <PAR.h>
#include <ReefAngel.h>



#define Level         76
#define MinPWM        45
#define OperatingPWM  68
long nummillis=5000;

byte PWMValue=0;
unsigned long lastmillis=millis();
boolean override=false;

static unsigned long levelHigh;
static unsigned long pumpOff;
static boolean pumpBool;

////// 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.Use2014Screen();  // Let's use 2014 Screen
  ReefAngel.DDNS("Damien"); 
  ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
  // Ports toggled in Feeding Mode
  ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
  // Ports toggled when Lights On / Off menu entry selected
  ReefAngel.LightsOnPorts = Port5Bit;
  // Ports turned off when Overheat temperature exceeded
  ReefAngel.OverheatShutoffPorts = Port3Bit;
  // Use T1 probe as temperature and overheat functions
  ReefAngel.TempProbe = T1_PROBE;
  ReefAngel.OverheatProbe = T1_PROBE;
  // Set the Overheat temperature setting
  InternalMemory.OverheatTemp_write( 800 );
  InternalMemory.WaterLevelMax_write(1800);        


  // Feeeding and Water Change mode speed


  // Ports that are always on
  ReefAngel.Relay.On( Port1 );
  ReefAngel.Relay.On( Port6 );

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


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

void loop()
{
  ReefAngel.StandardHeater( Port3,780,785 );
  ReefAngel.WaterLevelATO(4,Port4,240,28,31); 
  ReefAngel.Relay.Set(Port8, (now()%(6*SECS_PER_HOUR))<(30*SECS_PER_MIN));

  ////// Place your custom code below here

  PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)<Level-4)
  {
    override=true;
    lastmillis=millis();
    PWMValue+=2;
  }
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+2)
  {
    override=true;
    lastmillis=millis();
    PWMValue-=4;
  }
  if (millis()-lastmillis>nummillis && override)
  {
    override=false;
  }
  if (!override) PWMValue=OperatingPWM;
  if (ReefAngel.WaterLevel.GetLevel(2)>Level+10) PWMValue=MinPWM;
  PWMValue=constrain(PWMValue,MinPWM,100);
  ReefAngel.PWM.SetActinic(PWMValue);
  
  if (ReefAngel.WaterLevel.GetLevel(4) < 50) levelHigh=now();
  if (now()-levelHigh > 16*SECS_PER_MIN && !pumpBool) {
    pumpBool=true;  
    pumpOff=now();
  }

  if (now()-pumpOff < 15*SECS_PER_MIN) {
    ReefAngel.Relay.Off(Port1);
  } else { 
    if (ReefAngel.WaterLevel.GetLevel(2)>89) //Overflow
      ReefAngel.Relay.Off(Port1);
    else
      ReefAngel.Relay.On(Port1);
    pumpBool=false;
  }


  if (ReefAngel.WaterLevel.GetLevel(1)<5) //Disable the port until overriden manually
    ReefAngel.Relay.Override(Port8,0);    //Saltwater Reservoir
  if (ReefAngel.WaterLevel.GetLevel(1)>80)   // Set port back to auto
    ReefAngel.Relay.Override(Port8,2); 


  if (ReefAngel.WaterLevel.GetLevel(3)>87) //ATO Reservoir
    ReefAngel.Relay.Off(Port5);
  if (ReefAngel.WaterLevel.GetLevel(3)<1)
    ReefAngel.Relay.On(Port5);


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

  // This should always be the last line
  ReefAngel.Portal( "Ismaclst" );
  ReefAngel.ShowInterface();
}
Roberto.
Ismaclst
Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm

Re: DC return pumps

Post by Ismaclst »

Thanks, Roberto. It works but just need to change 15 minutes to 15 seconds. How do you code this?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: DC return pumps

Post by rimai »

16*SECS_PER_MIN is equal to 16 * 60 seconds, which means 16 minutes.
If you want 16 seconds, just remove the SECS_PER_MIN, which will be just 16 seconds.
Roberto.
Post Reply