Page 1 of 1
Single ATO with timer?
Posted: Wed May 01, 2013 12:36 pm
by Smotz
Hi All -
Can anyone advise how to code a single ATO to stay turned on for say 2 minutes then disengage?
Re: Single ATO with timer?
Posted: Wed May 01, 2013 12:41 pm
by rimai
Huh?
If it turns off, when would it turn back on?
Are you talking about timeout?
Sent from my Galaxy S3 using Tapatalk 2
Re: Single ATO with timer?
Posted: Wed May 01, 2013 4:45 pm
by Smotz
rimai wrote:Huh?
If it turns off, when would it turn back on?
Are you talking about timeout?
Sent from my Galaxy S3 using Tapatalk 2
Sorry, guess I didn't explain it well.
I would like the ato to be engaged when the single float switch activates and then simply turn off after X amount of time ( 2 minutes ).
Re: Single ATO with timer?
Posted: Wed May 01, 2013 5:29 pm
by rimai
Turn off after 2 minutes even if the water goes past the float, is that correct?
Re: Single ATO with timer?
Posted: Wed May 01, 2013 5:41 pm
by Smotz
rimai wrote:Turn off after 2 minutes even if the water goes past the float, is that correct?
Yes. With a single, it will go past the float. After a bit I will be able to determine exactly how much time is needed to get the refill where I want it.
Re: Single ATO with timer?
Posted: Wed May 01, 2013 5:50 pm
by rimai
Try this:
On setup():
Code: Select all
ReefAngel.Timer[1].SetInterval(120);
Code: Select all
if (ReefAngel.LowATO.IsActive())
{
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(Port1);
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off(Port1);
}
Re: Single ATO with timer?
Posted: Wed May 01, 2013 6:02 pm
by Smotz
rimai wrote:Try this:
On setup():
Code: Select all
ReefAngel.Timer[1].SetInterval(120);
Code: Select all
if (ReefAngel.LowATO.IsActive())
{
ReefAngel.Timer[1].Start();
ReefAngel.Relay.On(Port1);
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off(Port1);
}
Thanks Roberto - so I understand:
I would change "Port1" to whatever port my ATO pump is on - correct?
The setInterval(120) is 120 seconds - correct?
I can change "Timer[1]" to whatever I want to call the function?
Re: Single ATO with timer?
Posted: Wed May 01, 2013 7:12 pm
by rimai
Yes, change the port to whatever you want, but keep Timer[1]. This is an internal timer.
Re: Single ATO with timer?
Posted: Thu May 02, 2013 4:17 pm
by Smotz
rimai wrote:Yes, change the port to whatever you want, but keep Timer[1]. This is an internal timer.
Roberto - I found a flaw in my logic:
This 'single ATO with timer' will work with the exception of if the water runs out in the reservoir. Then the float would immediately reactivate for the duration of the timer, then reactivate again, and again..
Can you think of anything to prevent this?
Single ATO with timer?
Posted: Thu May 02, 2013 4:46 pm
by lnevo
I would add a check for what time the last run was and if it was right after the runtime of your ato then set the relay mask off for the device and maybe set a portal variable that you can trigger a txt message. This way you can reset the mask once you see whats wrong and it will keep your ato pump from burning out.
Single ATO with timer?
Posted: Thu May 02, 2013 4:59 pm
by lnevo
I'll try throw some code together by tomorrow.,
Re: Single ATO with timer?
Posted: Thu May 02, 2013 5:08 pm
by Smotz
lnevo wrote:I would add a check for what time the last run was and if it was right after the runtime of your ato then set the relay mask off for the device and maybe set a portal variable that you can trigger a txt message. This way you can reset the mask once you see whats wrong and it will keep your ato pump from burning out.
yea, thats what I would do too.

Re: Single ATO with timer?
Posted: Thu May 02, 2013 5:09 pm
by Smotz
lnevo wrote:I'll try throw some code together by tomorrow.,
Much appreciated
Re: Single ATO with timer?
Posted: Fri May 03, 2013 12:38 pm
by lnevo
Ok, trickier than I thought it would be, but just need to wrap my head around it... sorry it took so long.
It should be clear how the logic works, but let me know if any questions.
If someone wants to copy this, keep in mind the mask code needs to be adjusted if your ATO is on a relay expansion box.
Code: Select all
//
// Define these for your preference
//
byte floatThreshold=30; // How soon is too soon?
byte ATOPort=Port1; // Made this a variable so we can change it in one spot
int runtime=240; // Replaces the Timer[1].SetInterval
// startTime replaces Timer[1] and endTime added to track last run
static time_t startTime, endTime;
static boolean atoRunning;
if (ReefAngel.LowATO.IsActive()) // Float switch is active.
{
startTime=now(); // Time to start
if (startTime()-endTime() < floatThreshold) // Has enough time passed since the last run?
{
bitClear(ReefAngel.Relay.RelayMaskOff,ATOPort-1); // Set off mask to disable the relay
}
}
if (now()-startTime < runTime) // Are we within the runTime
{
ReefAngel.Relay.On(ATOPort);
atoRunning=true;
}
else // runTime is over
{
ReefAngel.Relay.Off(ATOPort);
if (atoRunning) {
endTime=now();
atoRunning=false;
}
}
// Assign custom variable to value of the off mask
// Default is 1 for off mask so setup the alert if value is < 1
ReefAngel.CustomVars[0]=bitRead(ReefAngel.Relay.RelayMaskOff,ATOPort-1);
// Dummy variable to keep portal feature activated (may not be necessary...)
ReefAngel.CustomVars[7]=255;
Re: Single ATO with timer?
Posted: Fri May 03, 2013 1:53 pm
by Smotz
lnevo wrote:Ok, trickier than I thought it would be, but just need to wrap my head around it... sorry it took so long.
It should be clear how the logic works, but let me know if any questions.
If someone wants to copy this, keep in mind the mask code needs to be adjusted if your ATO is on a relay expansion box.
Code: Select all
//
// Define these for your preference
//
byte floatThreshold=30; // How soon is too soon?
byte ATOPort=Port1; // Made this a variable so we can change it in one spot
int runtime=240; // Replaces the Timer[1].SetInterval
// startTime replaces Timer[1] and endTime added to track last run
static time_t startTime, endTime;
static boolean atoRunning;
if (ReefAngel.LowATO.IsActive()) // Float switch is active.
{
startTime=now(); // Time to start
if (startTime()-endTime() < floatThreshold) // Has enough time passed since the last run?
{
bitClear(ReefAngel.Relay.RelayMaskOff,ATOPort-1); // Set off mask to disable the relay
}
}
if (now()-startTime < runTime) // Are we within the runTime
{
ReefAngel.Relay.On(ATOPort);
atoRunning=true;
}
else // runTime is over
{
ReefAngel.Relay.Off(ATOPort);
if (atoRunning) {
endTime=now();
atoRunning=false;
}
}
// Assign custom variable to value of the off mask
// Default is 1 for off mask so setup the alert if value is < 1
ReefAngel.CustomVars[0]=bitRead(ReefAngel.Relay.RelayMaskOff,ATOPort-1);
// Dummy variable to keep portal feature activated (may not be necessary...)
ReefAngel.CustomVars[7]=255;
Nice - I will give this a try - thank you so much!