Page 1 of 1

Turning off/on a ports when ATO turns on/off

Posted: Fri Jan 13, 2017 11:59 am
by GugsJr
My top off container is connected to a conical tank and when I turn on my ATO pump it over flows the conical tank.

So here is what I'd like to program.

When the low ATO sensor trips I'd like it to turn off the main pump, then 2 minutes later turn on the ATO pump.

When the high ATO sensor trips turn off the ATO pump then 2 minutes later turn on the main pump.

Thank you

Re: Turning off/on a ports when ATO turns on/off

Posted: Fri Jan 13, 2017 9:31 pm
by rimai
Try this.

Code: Select all

#include <Salinity.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <RA_CustomLabels.h>
#include <RA_CustomSettings.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

unsigned long low_trigger=0;
unsigned long high_trigger=0;

void setup()
{
  ReefAngel.Init();  
  ReefAngel.Use2014Screen();
  ReefAngel.Relay.On(Port8); // Main pump
  ReefAngel.Relay.Off(Port7); // ATO pump
}

void loop()
{
  if (ReefAngel.LowATO.IsActive() && low_trigger==0)
  {
    low_trigger=now();
    ReefAngel.Relay.Off(Port8);
  }
  else
  {
    if (now()-low_trigger>5 && low_trigger!=0)
    {
      low_trigger=0;
      ReefAngel.Relay.On(Port7);
    }
  }

  if (ReefAngel.HighATO.IsActive() && high_trigger==0)
  {
    high_trigger=now();
    ReefAngel.Relay.Off(Port7);
  }
  else
  {
    if (now()-high_trigger>5 && high_trigger!=0)
    {
      high_trigger=0;
      ReefAngel.Relay.On(Port8);
    }
  }
  ReefAngel.ShowInterface();
}
This assumes that both floats are going to trip when the float is away from the wires.
If you need to invert any of them, just add an ! in from of either ReefAngel.LowATO.IsActive() or ReefAngel.HighATO.IsActive().
! means not.

Re: Turning off/on a ports when ATO turns on/off

Posted: Sat Jan 14, 2017 10:03 am
by GugsJr
Thank you, I'll try this and let you know.