IO Expansion Module - Check Reservoirs
Posted: Thu May 10, 2012 9:03 pm
Curt helped me write a custom ATO function that will mimic the standard ATO but on three ports - there are three reservoirs, each with its own topoff pump in it:
The above works great. But, the kicker is that I want to have my IO expansion module not allow a topoff pump to run if there is no water in that pump's reservoir. I have been unable to find any code examples that do anything similar to what I want to achieve. Can anyone point me in the right direction? The tutorial for the IO Expansion is pretty sparse. (Extra credit points to anyone who can also suggest a method of firing off an email when a reservoir runs dry.)
Code: Select all
void MyCustomATO(int ATOTimeout)
{
unsigned long TempTimeout = ATOTimeout;
TempTimeout *= 1000;
if ( ReefAngel.LowATO.IsActive() && ( !ReefAngel.LowATO.IsTopping()) )
{
ReefAngel.LowATO.Timer = millis();
ReefAngel.LowATO.StartTopping();
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.On(Box1_Port5);
}
if ( ReefAngel.HighATO.IsActive() )
{
ReefAngel.LowATO.StopTopping(); // stop the low ato timer
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
}
if ( (millis()-ReefAngel.LowATO.Timer > TempTimeout) && ReefAngel.LowATO.IsTopping() )
{
ReefAngel.LED.On();
#ifdef ENABLE_EXCEED_FLAGS
InternalMemory.write(ATO_Exceed_Flag, 1);
#endif // ENABLE_EXCEED_FLAGS
ReefAngel.Relay.Off(Port5);
ReefAngel.Relay.Off(Port6);
ReefAngel.Relay.Off(Box1_Port5);
#ifdef ENABLE_ATO_LOGGING
// bump the counter if a timeout occurs
AtoEventCount++;
if ( AtoEventCount >= MAX_ATO_LOG_EVENTS ) { AtoEventCount = 0; }
#endif // ENABLE_ATO_LOGGING
}
}