Water change pumps turning off during water change
Posted: Fri Aug 09, 2013 12:27 pm
I've been having a problem with both of my water pumps turning off during a water change. The empty pump starts, then after a few seconds the relay shuts off. I have to turn the pump on manually so that it finshes pumping to the right level. Once it hits that level, the fill pump turns on, like it should, but then does the same thing as the empty pump. It has been doing this on the last few water changes but before that it used to work with no problems. Anyone have an idea what could be causing 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 <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>
// Define Relay Ports by Name
#define KalkDoser 1
#define WCEmpty 2
#define Autotopoff 3
#define Refugium 4
#define KalkStirrer 5
#define WCFill 6
#define Heater 7
#define Return 8
#define RODIValve Box1_Port1
#define Skimmer Box1_Port2
#define GACReactor Box1_Port3
#define GFOReactor Box1_Port4
#define Unused Box1_Port5
#define Unused Box1_Port6
#define Unused Box1_Port7
#define Unused Box1_Port8
////// Place global variable code below here
byte wpMode;
int WCstatus;
////// Place global variable code above here
void setup()
{
// This must be the first line
InternalMemory.LCDID_write(0);
ReefAngel.Init(); //Initialize controller
ReefAngel.AddDateTimeMenu();
ReefAngel.AddStandardMenu(); // Add Standard Menu
ReefAngel.PHMin=546;//PH7.0
ReefAngel.PHMax=734;//PH10.0
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port3Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port3Bit | Port4Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port4Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// 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 );
ReefAngel.Timer[1].SetInterval(180);
// Ports that are always on
ReefAngel.Relay.On( Return );
ReefAngel.Relay.On( Skimmer );
ReefAngel.Relay.On( GACReactor );
ReefAngel.Relay.On( GFOReactor );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
////// Place your custom code below here
CheckPower(); // Monitor for power outages
ReefAngel.PWM.SetChannel( 0, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.PWM.SetChannel( 3, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.PWM.SetChannel( 4, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.PWM.SetChannel( 5, PWMSlope(9,30,21,30,17,100,60,0) );
ReefAngel.WaterLevelATO(Port3,180,54,56);
if (ReefAngel.LowATO.IsActive()) ReefAngel.Relay.On(RODIValve);
if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(RODIValve);
ReefAngel.DosingPumpRepeat( Port1,0,45,6 );
if (ReefAngel.Params.PH>=850) ReefAngel.Relay.Off(KalkDoser);
ReefAngel.StandardLights( Port4,20,0,8,0 );
ReefAngel.Relay.Set(Port5,now()%7200<900);
ReefAngel.StandardHeater( Port7,780,785 );
if (hour()>=6 && hour()<8)
{
ReefAngel.PWM.SetDaylight( TidalSwellMode(70,true) ); // Tidal Swell at 70% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(70,false) ); // Tidal Swell at 70% on anti-sync mode
wpMode=0;
}
else if (hour()>=8 && hour()<9)
{
ReefAngel.PWM.SetDaylight( ReefCrestMode(65,20,true) ); // ReefCrest at 65% +/- 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(65,20,false) ); // ReefCrest at 65% +/- 20 on anti-sync mode
wpMode=1;
}
else if (hour()>=9 && hour()<13)
{
ReefAngel.PWM.SetDaylight( ElseMode(60,30,true )); // ElseMode on sync mode, 60 +/- 30%
ReefAngel.PWM.SetActinic( ElseMode(60,30,false )); // ElseMode on anti-sync mode, 60 +/- 30%
wpMode=3;
}
else if (hour()>=13 && hour()<16)
{
ReefAngel.PWM.SetDaylight( NutrientTransportMode(75,90,2000,true) ); // Nutrient Transport on sync mode
ReefAngel.PWM.SetActinic( NutrientTransportMode(75,90,2000,false) ); // Nutrient Transport on anti-sync mode
wpMode=2;
}
else if (hour()>=16 && hour()<20)
{
ReefAngel.PWM.SetDaylight( ElseMode(60,30,true )); // ElseMode on sync mode, 60 +/- 30%
ReefAngel.PWM.SetActinic( ElseMode(60,30,false )); // ElseMode on anti-sync mode, 60 +/- 30%
wpMode=3;
}
else if (hour()>=20 && hour()<21)
{
ReefAngel.PWM.SetDaylight( ReefCrestMode(65,20,true) ); // ReefCrest at 65% +/- 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(65,20,false) ); // ReefCrest at 65% +/- 20 on anti-sync mode
wpMode=1;
}
else if (hour()>=21 && hour()<23)
{
ReefAngel.PWM.SetDaylight( TidalSwellMode(70,true) ); // Tidal Swell at 70% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(70,false) ); // Tidal Swell at 70% on anti-sync mode
wpMode=0;
}
else
{
ReefAngel.PWM.SetDaylight( SineMode(40,55,30,true) ); // Sine at 40% 55% with for 30s on sync mode
ReefAngel.PWM.SetActinic( SineMode(40,55,30,false) ); // Sine at 40% 55% with for 30s on anti sync mode
wpMode=4;
}
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
{
if (WCstatus==-1)
{
ReefAngel.Timer[1].Start();
WCstatus=0;
}
if ( ReefAngel.Timer[1].IsTriggered() )
{
ReefAngel.Relay.On(WCEmpty);
WCstatus=1;
}
if (ReefAngel.WaterLevel.GetLevel()<=30 && WCstatus>0 && WCstatus<10) WCstatus++;
if (ReefAngel.WaterLevel.GetLevel()<=30 && WCstatus==10)
{
WCstatus=11;
ReefAngel.Relay.Off(WCEmpty);
ReefAngel.Relay.On(WCFill);
}
if (ReefAngel.WaterLevel.GetLevel()<=79 && WCstatus>10 && WCstatus<20) WCstatus++;
if (ReefAngel.WaterLevel.GetLevel()>79 && WCstatus==20)
{
ReefAngel.Relay.Off(WCFill);
ButtonPress++;
}
}
else
{
WCstatus=-1;
ReefAngel.Relay.Off(WCEmpty);
ReefAngel.Relay.Off(WCFill);
}
ReefAngel.Portal("Drs1210");
ReefAngel.ShowInterface(); // Display everything on the LCD screen
}
void CheckPower() {
static boolean powerOutage=false;
// Power Outage - turn off everything
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) // Expansion Relay NOT present
{
powerOutage=true;
ReefAngel.Relay.Off(KalkDoser);
ReefAngel.Relay.Off(WCEmpty);
ReefAngel.Relay.Off(Refugium);
ReefAngel.Relay.Off(KalkStirrer);
ReefAngel.Relay.Off(WCFill);
ReefAngel.Relay.Off(Heater);
ReefAngel.Relay.Off(RODIValve);
ReefAngel.Relay.Off(Skimmer);
ReefAngel.Relay.Off(GACReactor);
ReefAngel.Relay.Off(GFOReactor);
}
// Power Restored - Turn things back on
if (powerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
LastStart=now();
powerOutage=false;
ReefAngel.Relay.On(Return);
ReefAngel.Relay.On(Skimmer);
ReefAngel.Relay.On(GACReactor);
ReefAngel.Relay.On(GFOReactor);
}
}
void DrawCustomMain()
{
byte x = 6;
byte y = 2;
byte t;
char text[7];
ReefAngel.LCD.DrawDate(6, 3);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
ReefAngel.LCD.DrawText(COLOR_BLACK,255,56,83, "Res");
ReefAngel.LCD.DrawText(COLOR_GREEN,255, 45, 83, "H");
ReefAngel.LCD.DrawText(COLOR_GREEN,255, 45, 91, "I");
ReefAngel.LCD.DrawText(COLOR_RED,255, 77, 83, "L");
ReefAngel.LCD.DrawText(COLOR_RED,255, 77, 91, "O");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 75, "--------------------");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 98, "--------------------");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 78, "|");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 86, "|");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 95, "|");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 78, "|");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 86, "|");
ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 95, "|");
ReefAngel.LCD.DrawText(0,255,10,30,"Tank");
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
pingSerial();
ReefAngel.LCD.DrawText(0,255,100,30,"pH");
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 91, 40, text, Num8x8);
pingSerial();
ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
ConvertNumToString(text, ReefAngel.Params.Salinity, 100);
ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
pingSerial();
ReefAngel.LCD.DrawText(0,255,8,68,"WC");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T3_PROBE], COLOR_CHOCOLATE, 25, 68, 10);
pingSerial();
ReefAngel.LCD.DrawText(0,255,66,68,"Room");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.Params.Temp[T2_PROBE], COLOR_MEDIUMORCHID, 94, 68, 10);
pingSerial();
ReefAngel.LCD.DrawText(0,255,15,83,"WL");
ConvertNumToString(text, ReefAngel.WaterLevel.GetLevel(),1);
ReefAngel.LCD.DrawLargeText(COLOR_BLUE, 255, 10, 91, text, Num8x8);
ReefAngel.LCD.DrawText(0,255,26,91," %");
pingSerial();
// WP40 Mode
ReefAngel.LCD.DrawText(0,255,18,12,"Jebao WP40 Mode:");
ReefAngel.LCD.Clear(COLOR_WHITE, 1, 21, 132, 21);
if (wpMode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255, 23, 21,"Tidal Swell");
else if (wpMode == 1) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255, 25, 21,"Reef Crest");
else if (wpMode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255, 8, 21,"Nutrient Trnsp.");
else if (wpMode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255, 30, 21,"Else Mode");
else if (wpMode == 4) ReefAngel.LCD.DrawLargeText(COLOR_RED,255, 30, 21,"Sine Mode");
ReefAngel.LCD.DrawText(0,255,96,83,"WP40");
ConvertNumToString(text, ReefAngel.PWM.GetActinicValue(),1);
ReefAngel.LCD.DrawLargeText(COLOR_OLIVE, 255, 99, 91, text, Num8x8);
ReefAngel.LCD.DrawText(0,255,115,91," %");
pingSerial();
// Main Relay box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(14, 106, TempRelay);
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 14, 118, TempRelay );
pingSerial();
if (ReefAngel.HighATO.IsActive())
ReefAngel.LCD.FillCircle(57,94,3,COLOR_RED);
else
ReefAngel.LCD.FillCircle(57,94,3,COLOR_GREEN);
if (ReefAngel.LowATO.IsActive())
ReefAngel.LCD.FillCircle(70,94,3,COLOR_RED);
else
ReefAngel.LCD.FillCircle(70,94,3,COLOR_GREEN);
}
void DrawCustomGraph()
{
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}