Single ATO with timer?

Do you have a question on how to do something.
Ask in here.
Post Reply
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Single ATO with timer?

Post by Smotz »

Hi All -

Can anyone advise how to code a single ATO to stay turned on for say 2 minutes then disengage?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Single ATO with timer?

Post 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
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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 ).
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Single ATO with timer?

Post by rimai »

Turn off after 2 minutes even if the water goes past the float, is that correct?
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Single ATO with timer?

Post 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);
} 
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Single ATO with timer?

Post by rimai »

Yes, change the port to whatever you want, but keep Timer[1]. This is an internal timer.
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Single ATO with timer?

Post 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.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Single ATO with timer?

Post by lnevo »

I'll try throw some code together by tomorrow.,
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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. :roll:
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post by Smotz »

lnevo wrote:I'll try throw some code together by tomorrow.,
Much appreciated
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Single ATO with timer?

Post 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;
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Single ATO with timer?

Post 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!
Post Reply