How do i code Standard ATO high switch

Do you have a question on how to do something.
Ask in here.
Post Reply
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

How do i code Standard ATO high switch

Post by acabano »

please help, i would like to use the standard ATO setup but i want to keep the high switch wires up.
from reading the forum, the way standard ATO work is.
ATO high switch is triggered(open loop) and ATO low switch is triggered(closed loop) ATO port is enabled.
then fills up the sump when the ATO low switch is triggered(open loop) and ATO high switch is triggered(close loop) ATO port is disabled(stop the pump)

below if possible to program the code in opposite with the ATO high switch.
-------------------------------------------------------------------------------------
ATO high switch is triggered(closed loop) and ATO low switch is triggered(closed loop) ATO port is enabled.
then fills up the sump when the ATO low switch is triggered(open loop) and ATO high switch is triggered(open loop) ATO port is disabled(stop the pump)

Thanks.
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do i code Standard ATO high switch

Post by binder »

Doing this would require modifying the code in the libraries are that is not recommended. You can modify them but if you do, it makes upgrading the libraries much harder.

What you could do is use the SingleATOHigh and SingleATOLow functions and inside your PDE file you create your own version of the StandardATO function and handle it the way you want to handle it.

curt
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Hi Curt, would i be able to use RAgen for this setup?
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do i code Standard ATO high switch

Post by binder »

acabano wrote:Hi Curt, would i be able to use RAgen for this setup?
You could use RAGen to get the SingleATO code in the PDE but as for the additional logic, you would have to program it manually. It wouldn't be terribly tough to do. I know some others have done something similar.

Somewhere on here somebody has used the SingleATO functions as a low switch being for the normal operation and then the high switch is the failsafe for if the low switch were to fail.

For what you want to do, you would need to look at the way the single and standard ato functions are coded to get a better idea on how to do it manually.

curt
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do i code Standard ATO high switch

Post by rimai »

Before you go hacking on libraries, try this:

Code: Select all

  if (ReefAngel.HighATO.IsActive() && ReefAngel.LowATO.IsActive()) ReefAngel.Relay.On(Port1);
  if (!ReefAngel.HighATO.IsActive() && !ReefAngel.LowATO.IsActive()) ReefAngel.Relay.Off(Port1);
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do i code Standard ATO high switch

Post by rimai »

Don't use StandardATO or SingleATO functions though. Just the above code.
Roberto.
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Great! thanks guy's, i will throw this into my pde loop...
Image
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: How do i code Standard ATO high switch

Post by binder »

acabano wrote:Great! thanks guy's, i will throw this into my pde loop...
Yep that's what you should do.

curt
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Thanks again Guy's, for all your hard work and me just pasting all the code :D
I'm happy with my setup now.

Note: if you use this code please comment out the ReefAngel.StandardATO(); function as Roberto mention.


Thanks,
Image
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Hi Guy, I just realize that a timer function would help for added safety, is this possible with the code above?

Thanks.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do i code Standard ATO high switch

Post by rimai »

If we put a timer, how would you clear the flag if the timer ever exceeds?
Do you use the Client?
Roberto.
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Hi Roberto, sorry for the confusion, i meant ATO time out function :)
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do i code Standard ATO high switch

Post by rimai »

Yes, I understood your question.
We can easily mask the relay off and it will disable that port and ATO won't function no matter what.
But, you still need a way to clear the mask. Do you use the Client or have a wifi attachment?
Roberto.
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

i have a wifi attachment..
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: How do i code Standard ATO high switch

Post by rimai »

Try this code:

Code: Select all

#include <ReefAngel_Features.h>
#include <ReefAngel_Globals.h>
#include <ReefAngel_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <ReefAngel_EEPROM.h>
#include <ReefAngel_NokiaLCD.h>
#include <ReefAngel_ATO.h>
#include <ReefAngel_Joystick.h>
#include <ReefAngel_LED.h>
#include <ReefAngel_TempSensor.h>
#include <ReefAngel_Relay.h>
#include <ReefAngel_PWM.h>
#include <ReefAngel_Timer.h>
#include <ReefAngel_Memory.h>
#include <ReefAngel.h>

void setup()
{
  ReefAngel.Init();  
  ReefAngel.Timer[1].SetInterval(2);
}

void loop()
{
  ReefAngel.ShowInterface();
  if (ReefAngel.HighATO.IsActive() && ReefAngel.LowATO.IsActive())
  {
    ReefAngel.Relay.On(Port1);
    ReefAngel.Timer[1].Start();
  }
  if (!ReefAngel.HighATO.IsActive() && !ReefAngel.LowATO.IsActive())
  {
    ReefAngel.Relay.Off(Port1);
    ReefAngel.Timer[1].ForceTrigger();
  }
  if (bitRead(ReefAngel.Relay.RelayData,Port1-1) && ReefAngel.Timer[1].IsTriggered())
  {
    bitClear(ReefAngel.Relay.RelayMaskOff,Port1-1);
  }
}
To clear the timeout, simply use the Client or browse to the wifi attachment and turn the port 1 back to "Auto" instead of "Off"
Roberto.
acabano
Posts: 49
Joined: Thu Jul 21, 2011 6:09 pm

Re: How do i code Standard ATO high switch

Post by acabano »

Thanks, Roberto.... i will add this to my pde, after i fix my wifi issue...
Image
Post Reply