Minimum ATO Run Time

Do you have a question on how to do something.
Ask in here.
Post Reply
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Minimum ATO Run Time

Post by ReEfnWrX »

Hey guys,

so I am running a single ATO switch setup and what I have found is that sometimes the switch will bounce trigger on/off/on/off etc.. This does not happen every single time.

I was hoping to implement a minimum amount of time the Controller has to wait between cycling the ATO Relay port on.

Example it turns on then turns off... no matter what the switch does, the controller has to wait lets say, one hour before listening to the switch and turning the ATO Relay on.

Here is my current 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 <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.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit | Port8Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 825 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );

    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.StandardHeater( Port1,777,780 );
    ReefAngel.StandardLights( Port2,21,30,12,0 );
    ReefAngel.StandardLights( Port3,12,0,21,30 );
    ReefAngel.MHLights( Port4,14,0,20,30,5 );
    ReefAngel.SingleATO( true,Port7,4542,0 );
    ReefAngel.StandardLights( Port8,12,0,21,45 );
    ////// Place your custom code below here
    
if (hour()>=11 && hour()<20)   // 11am - 8pm
{
    ReefAngel.PWM.SetDaylight( ElseMode(65,20,true) ); // ReefCrest at 65% +/- 20% on sync mode
}
else if (hour()>=20 && hour()<23)    // 8pm - 11pm
{
    ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,90,500,true) ); // Nutrient Transport 30%minspeed - 90%maxspeed - 500ms 
}    
else if (hour()>=23 || hour()<11)    // 11pm - 11am
{
    ReefAngel.PWM.SetDaylight( ElseMode(40,15,true) ); // ReefCrest at 40% +/- 15% on sync mode
}

    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "ReEfnWrX" );
    ReefAngel.ShowInterface();
}

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 3000);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Minimum ATO Run Time

Post by lnevo »

Theres a few solutions out there to do the very thing...

Roberto...it may be time to add a time arg to the singleato function, i think it gets asked enough times.
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: Minimum ATO Run Time

Post by ReEfnWrX »

I searched but did not find anything
Image
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Minimum ATO Run Time

Post by rimai »

Curt was the one who created the function and I'm pretty sure that it already has it.
The last argument is the timer in hours.
I need to double check when I get back.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Minimum ATO Run Time

Post by lnevo »

I think its hours too...i think that forces it to run every x hours but not 100%.
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: Minimum ATO Run Time

Post by ReEfnWrX »

I do not want to force it to run every X hours. I just want to control that when it is triggered, it will stay on for at least a few minutes...

Pretty much just stop it from bouncing between off and on 5 times in a second..
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Minimum ATO Run Time

Post by lnevo »

If you said one hour it would do just that...basically it would run 24x a day and the low point would replace the low switch and the single you are using would act like the high. Its the same thing really but maybe it should be an int and be in minutes...so you can say dont run if you just ran within 10 minutes ago.
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: Minimum ATO Run Time

Post by ReEfnWrX »

exactly, i want to tell it not to run if it ran X time ago... But what is the code for that? I cannot find any posts with it
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Minimum ATO Run Time

Post by binder »

The SingleATO function does just that. It allows you to set an interval so that the function only triggers 1 time during that interval so you don't bounce back and forth like you have experienced. Here's the comment for the function:

Code: Select all

/*
        If the switch is active, the float is opposite of the 2 wires,
                Check if we are not currently topping, if we are not check if we can run
                If we have an hour interval, check if we can run
                If we can run, activate the pump because we need water
        Otherwise the switch is not active, we need to see if we are currently topping
                If we are topping, then we need to stop the pump because we are topped off
         */
So a sample usage would be this:

Code: Select all

ReefAngel.SingleATO(true, 1, 60, 1);
This statement would be to:
  • Use the LOW switch
  • Activate Port 1
  • Use a 60 second timeout where if it runs for more than 60 seconds, the timeout will kick up an error
  • Can only top off 1 time no more than 1 hour apart. This means that no matter when the ATO triggers, once it runs it cannot run again for at least 1 hour. This is based off of the last time it ran, so this can fluctuate throughout the day.
Here's the link to the ATO reference thread: http://forum.reefangel.com/viewtopic.php?f=7&t=240

Hope this helps clarify things.
ReEfnWrX
Posts: 232
Joined: Tue Nov 05, 2013 8:40 am
Location: Houston TX

Re: Minimum ATO Run Time

Post by ReEfnWrX »

Yeah I have read through that link but it doesn't explain the ATO Functions in comparison to the code.

Ah I see, since the Wizard only gives the option to modify timeout and not the minimal interval between on's. so in my code the last function is 0 which if I am correct, that is the function I need to change.

Thanks for clarifying
Image
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Minimum ATO Run Time

Post by binder »

ReEfnWrX wrote:Yeah I have read through that link but it doesn't explain the ATO Functions in comparison to the code.

Ah I see, since the Wizard only gives the option to modify timeout and not the minimal interval between on's. so in my code the last function is 0 which if I am correct, that is the function I need to change.

Thanks for clarifying
Yeah, I don't think the Wizard allows you to change the minimum interval. Placing 0 in it makes it run whenever it activates.
You need to change the parameter 0 in the function to be the hour interval that you wish. That should take care of things for you.

And I will look at the ATO guide and see if I can add that part in clarifying the hour interval.
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Minimum ATO Run Time

Post by binder »

I just updated the ATO guide to include this code sample and some further explanations.
Post Reply