ATO high/low as failsafe

Basic / Standard Reef Angel hardware
Post Reply
jcjrogers
Posts: 66
Joined: Fri May 05, 2017 11:27 am

ATO high/low as failsafe

Post by jcjrogers »

I want to use my float switches as a fail safe for my Water Level Expansion that will run my ATO. It looks like a simple If/Then Statement should do it, but "Is on" and "Is off" are grayed out, and I don't know what other option to use.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO high/low as failsafe

Post by rimai »

I think you are past the point of using the wizard a long time ago :)
You should just edit your code to accommodate what you need now.
I think the best way is to use the waterlevelato function for the ATO and force it to off if there is a float trigger.
Something like this:

Code: Select all

ReefAngel.WaterLevelATO(Port1);
if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port1);
Roberto.
jcjrogers
Posts: 66
Joined: Fri May 05, 2017 11:27 am

Re: ATO high/low as failsafe

Post by jcjrogers »

rimai wrote:I think you are past the point of using the wizard a long time ago :)
You should just edit your code to accommodate what you need now.
I think the best way is to use the waterlevelato function for the ATO and force it to off if there is a float trigger.
Something like this:

Code: Select all

ReefAngel.WaterLevelATO(Port1);
if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port1);
Ok, just getting back to this. Regarding the Wizard, I just use it to generate specific lines of code now, and then copy/paste into my saved sketch. I'm doing all of this on the bench, hoping to get it right before installation (planned for today or tomorrow). I can't test the high ATO as I'm using the Multi-channel Water Expansion module for my main ATO, and it hasn't been attached or calibrated.

On the low ATO side, I'm trying to shut-off my main pump as I want this failsafe to protect the pump and warn me that the water level has gotten too low. I've tried to code turning-off the main pump, but the main pump is just always off. Here is what I added:

Code: Select all

if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6);   /// Failsafe to turn-off ATO pump if water level too high.
if (!ReefAngel.LowATO.IsActive()) ReefAngel.Relay.Off(Port4);   /// Failsafe to turn-off Main pump if water level too low.
This is my entire code:

Code: Select all

#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 <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddStandardMenu();  // Add Standard Menu
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port7Bit;
    ReefAngel.FeedingModePortsE[0] = Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port5Bit | Port7Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    ReefAngel.LightsOnPortsE[0] = Port1Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 840 );

    // Ports that are always on
    //*ReefAngel.Relay.On( Port1 ); - place holder for Webwizard.  Using ActinicLights code for Port 1
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port3 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Box1_Port5 );
   
    ////// Place additional initialization code below here
   

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardLights( Port2 );
    ReefAngel.StandardHeater1( Box1_Port2 );
    ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port2 ) );
    ReefAngel.StandardHeater1( Port5 );
    ReefAngel.WaterLevelATO( 1,Port6 );
    ReefAngel.Relay.DelayedOn( Port7 );
    ReefAngel.StandardFan1( Port8 );
    if ( ReefAngel.Params.PH > 840 ) ReefAngel.Relay.Off( Port6 );
    

    ////// Place your custom code below here
    ReefAngel.WaterLevelATO( 2,Box1_Port4,5,95,14400 ); // hard codes ATO reservoir settings since only one available in Uapp.
    MyOwnStandardLights(Port1,-InternalMemory.ActinicOffset_read());  // Calls my new offset to allow negative offset.
    if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6);  /// Failsafe to turn-off ATO pump if water level too high.
    if (!ReefAngel.LowATO.IsActive()) ReefAngel.Relay.Off(Port4);  /// Failsafe to turn-off Main pump if water level too low.
    ////// Place your custom code above here

    ReefAngel.CloudPortal();
    // This should always be the last line
    ReefAngel.ShowInterface();
}

/// Code below makes neg. offset for T5's.
    void MyOwnStandardLights(byte Relay, int MinuteOffset)   
{
   int onTime=NumMins(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read())-MinuteOffset;
   int offTime=NumMins(InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read())+MinuteOffset;
   ReefAngel.StandardLights(Relay,
         onTime/60,
         onTime%60,
         offTime/60,
         offTime%60
   );
}

// RA_STRING1=U2FsdGVkX1/MRai+5HT5Qq9ZfbEK1mzFXKwT07B7oyM=
// RA_STRING2=U2FsdGVkX1+PuVSO4WlfFCjqa//mhJqdV9c4vId+V1I=
// RA_STRING3=Chloe's House-2.4 
Basically, I can't make the low ATO work. It acts as if the switch is always active so the main pump's port is always off. Also a question, since both my high and low ATO are only turning off ports, do I need to do anything with delays?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO high/low as failsafe

Post by rimai »

The ! sign means not.
When the float is not floating, it is active and when it is floating, it is not active.
So, you should remove the ! sign when using it as low ciut off switch.
Roberto.
jcjrogers
Posts: 66
Joined: Fri May 05, 2017 11:27 am

Re: ATO high/low as failsafe

Post by jcjrogers »

Update: with the code below, clearing ATO doesn't reinstate Port 4 (main pump). Rebooting does reinstate Port 4, but moving the float to an inactive position doesn't reinstate (probably a good thing as when the main pump turns off, the sump level will rise, making inactive pretty quickly. It seems rebooting to reinstate is a little cryptic, but I'm not sure there is better logic. I don't really want the main pump to go back and forth on/off as water leaves and then returns to sump. Thoughts?

Code: Select all

#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 <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>

////// Place global variable code below here


////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddStandardMenu();  // Add Standard Menu
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen
    ReefAngel.AddWaterLevelExpansion();  // Water Level Expansion Module
    ReefAngel.AddMultiChannelWaterLevelExpansion();  // Multi-Channel Water Level Expanion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port7Bit;
    ReefAngel.FeedingModePortsE[0] = Port3Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    ReefAngel.WaterChangePortsE[0] = Port3Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port5Bit | Port7Bit;
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    ReefAngel.LightsOnPortsE[0] = Port1Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 840 );

    // Ports that are always on
    //*ReefAngel.Relay.On( Port1 ); - place holder for Webwizard.  Using ActinicLights code for Port 1
    ReefAngel.Relay.On( Box1_Port1 );
    ReefAngel.Relay.On( Box1_Port3 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Box1_Port5 );
   
    ////// Place additional initialization code below here
   

    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.StandardLights( Port2 );
    ReefAngel.StandardHeater1( Box1_Port2 );
    ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port2 ) );
    ReefAngel.StandardHeater1( Port5 );
    ReefAngel.WaterLevelATO( 1,Port6 );
    if ( ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Off(Port6);
    ReefAngel.Relay.DelayedOn( Port7 );
    ReefAngel.StandardFan1( Port8 );
    if ( ReefAngel.Params.PH > 840 ) ReefAngel.Relay.Off( Port6 );
    if ( ReefAngel.LowATO.IsActive()) ReefAngel.Relay.Off(Port4);

    ////// Place your custom code below here
    ReefAngel.WaterLevelATO( 2,Box1_Port4,5,95,14400 ); // hard codes ATO reservoir settings since only one available in Uapp.
    MyOwnStandardLights(Port1,-InternalMemory.ActinicOffset_read());  // Calls my new offset to allow negative offset.
    
    
    ////// Place your custom code above here

    ReefAngel.CloudPortal();
    // This should always be the last line
    ReefAngel.ShowInterface();
}

    void MyOwnStandardLights(byte Relay, int MinuteOffset)
{
   int onTime=NumMins(InternalMemory.StdLightsOnHour_read(),InternalMemory.StdLightsOnMinute_read())-MinuteOffset;
   int offTime=NumMins(InternalMemory.StdLightsOffHour_read(),InternalMemory.StdLightsOffMinute_read())+MinuteOffset;
   ReefAngel.StandardLights(Relay,
         onTime/60,
         onTime%60,
         offTime/60,
         offTime%60
   );
}

// RA_STRING1=U2FsdGVkX1/MRai+5HT5Qq9ZfbEK1mzFXKwT07B7oyM=
// RA_STRING2=U2FsdGVkX1+PuVSO4WlfFCjqa//mhJqdV9c4vId+V1I=
// RA_STRING3=Chloe's House-2.4
jcjrogers
Posts: 66
Joined: Fri May 05, 2017 11:27 am

Re: ATO high/low as failsafe

Post by jcjrogers »

rimai wrote:The ! sign means not.
When the float is not floating, it is active and when it is floating, it is not active.
So, you should remove the ! sign when using it as low ciut off switch.
I accidentally posted the first code that didn't work. The new code didn't work either, until I reset the controller. See response above.
jcjrogers
Posts: 66
Joined: Fri May 05, 2017 11:27 am

Re: ATO high/low as failsafe

Post by jcjrogers »

I guess "Clear ATO" is resetting ports identified as "ATO" as opposed to doing something with the ATO code. Since my main pump is an always on relay (not a water level/ATO), the only way to reset is to reset the controller... makes sense.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: ATO high/low as failsafe

Post by Naptalene »

I had the same problem with a similar setup

I just had to add an else statement and it's working now.
Mine is

Code: Select all

If (ReefAngel.ATOHigh.isActive)
{ 
   ReefAngel.Relay.Off(your return pump port here);
}

else (ReefAngel.Relay.On(your return pump port here);

You can put in the ! To flip the logic..... or just
Flip the floats switches lol.

Weird thing is my old code from years ago didn't need that else.
Believe it or not.... I can ask even stupider questions than this one.
Post Reply