Modified ATO to monitor reservoir
Posted: Mon May 13, 2013 2:43 am
I am new to the Reef Angel but I currently have a JBJ Auto Top Off that has a mode where one float switch goes in the sump and the other in the ATO reservoir to turn off the pump if the water level is too low. I created a custom ATO function to perform this same function (based off of StandardATO) that assumes both float sensors are in the "wires up" position. I believe this should work (please let me know if I missed something):
in ReefAngel.h:
void CustomATO(byte ATORelay, int ATOTimeout);
in ReefAngel.cpp:
in ReefAngel.h:
void CustomATO(byte ATORelay, int ATOTimeout);
in ReefAngel.cpp:
Code: Select all
/* This function activiates the ATO pump to refill (ATOLow Active) if the reservoir
is not empty (ATO high inactive). It also limits the time the ATO pump can run to the
ATOTimeout value (s).
*/
void ReefAngelClass::CustomATO(byte ATORelay, int ATOTimeout)
{
// Input: Relay port and timeout value (max number of seconds that ATO pump is allowed to run)
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
/*
Is the low switch active (meaning we need to top off) and are we not currently topping off
Then we set the timer to be now and start the topping pump. Before enabling the top-off pump,
check if the reservoir has water.
*/
if ( !HighATO.IsActive() )
{
LED.Off();
if ( LowATO.IsActive() && ( !LowATO.IsTopping()) )
{
LowATO.Timer = millis();
LowATO.StartTopping();
Relay.On(ATORelay);
}
// Low switch is deactivated so turn off the pump
else if ( (!LowATO.IsActive()) && (LowATO.IsTopping()) )
{
LowATO.StopTopping(); // stop the low ato timer
Relay.Off(ATORelay);
}
}
else LED.On(); // Turn on the LED if the water level in the reservoir is low
/*
If the current time minus the start time of the ATO pump is greater than the specified timeout value
AND the ATO pump is currently running:
We turn on the status LED and shut off the ATO pump
This prevents the ATO pump from contniously running.
*/
if ( (millis()-LowATO.Timer > TempTimeout) && LowATO.IsTopping() )
{
LED.On();
bitSet(Flags,ATOTimeOutFlag);
#ifdef ENABLE_EXCEED_FLAGS
if (InternalMemory.read(ATO_Exceed_Flag)==0)
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
Relay.Off(ATORelay);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}