Multiple on/off times

Do you have a question on how to do something.
Ask in here.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

Actually, if you look closely, it's the other way around...
The scheduling is 1st and the override is 2nd.
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Thanks Roberto.
Again I'll try it when I get home from work tonight.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

rimai wrote:Actually, if you look closely, it's the other way around...
The scheduling is 1st and the override is 2nd.
How do you mean, Roberto?

--Colin
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

I meant that your code comes in 2nd and not the 1st as he was thinking.
Roberto.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Oh, OK. :)

And thanks for the original framework for that code. :mrgreen:

--Colin
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

cosmith71 wrote:ReefAngel.Relay.Status returns a 0 for off and a 1 for on (boolean, true/false) so you can't just add 120 there.

Try this:

This goes near the top right above ////// Place global variable code above here

Code: Select all

unsigned long ATOUpdate=0;
Remove this:

Code: Select all

if (ReefAngel.Relay.Status(Port5))
    ReefAngel.Relay.Off(Port6);
  else
    ReefAngel.WaterLevelATO(Port6,720,29,31);
And try this instead:

Code: Select all

if (ReefAngel.Relay.Status(Port5) && ATOUpdate==0) // Check to see if port 5 is on and update time is empty
  { ATOUpdate = now();                             // If so, set the update time to now
    ReefAngel.Relay.Off (Port6); }                 // and turn off the ATO pump
if (now() - ATOUpdate >= 120 && ATOUpdate != 0)    // If it's been 120 sec, and the update time is NOT empty
  { ATOUpdate = 0;                                 // Empty out the update time
    ReefAngel.WaterLevelATO(Port6,720,29.31); }    // and turn the ATO sensor back on
--Colin
I added what you asked at the top and replaced the other code with what you gave me and I'm getting the following error...
Steves_Custom_Wave_Sketch.cpp: In function 'void loop()':
Steves_Custom_Wave_Sketch:78: error: no matching function for call to 'ReefAngelClass::WaterLevelATO(int, int, double)'
C:\Users\Steve\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:322: note: candidates are: void ReefAngelClass::WaterLevelATO(byte, int, byte, byte)
C:\Users\Steve\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:353: note: void ReefAngelClass::WaterLevelATO(byte)
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

cosmith71 wrote:ReefAngel.Relay.Status returns a 0 for off and a 1 for on (boolean, true/false) so you can't just add 120 there.

Try this:

This goes near the top right above ////// Place global variable code above here

Code: Select all

unsigned long ATOUpdate=0;
Remove this:

Code: Select all

if (ReefAngel.Relay.Status(Port5))
    ReefAngel.Relay.Off(Port6);
  else
    ReefAngel.WaterLevelATO(Port6,720,29,31);
And try this instead:

Code: Select all

if (ReefAngel.Relay.Status(Port5) && ATOUpdate==0) // Check to see if port 5 is on and update time is empty
  { ATOUpdate = now();                             // If so, set the update time to now
    ReefAngel.Relay.Off (Port6); }                 // and turn off the ATO pump
if (now() - ATOUpdate >= 120 && ATOUpdate != 0)    // If it's been 120 sec, and the update time is NOT empty
  { ATOUpdate = 0;                                 // Empty out the update time
    ReefAngel.WaterLevelATO(Port6,720,29.31); }    // and turn the ATO sensor back on
--Colin
I added what you asked at the top and replaced the other code with what you gave me and I'm getting the following error...
Steves_Custom_Wave_Sketch.cpp: In function 'void loop()':
Steves_Custom_Wave_Sketch:78: error: no matching function for call to 'ReefAngelClass::WaterLevelATO(int, int, double)'
C:\Users\Steve\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:322: note: candidates are: void ReefAngelClass::WaterLevelATO(byte, int, byte, byte)
C:\Users\Steve\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:353: note: void ReefAngelClass::WaterLevelATO(byte)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

I think you typed wrong....
ReefAngel.WaterLevelATO(Port6,720,29.31);
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

rimai wrote:I think you typed wrong....
ReefAngel.WaterLevelATO(Port6,720,29.31);
That was it. I wasn't even looking there because the error seemed to be referring to something different.

The 7pm cycle is coming up so I'll see what happens.

I got to start figuring this stuff out. I hate asking for help like this.

Thanks Colin and Roberto.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

If you look at the error code, it gives exactly where the problem is:
Steves_Custom_Wave_Sketch:78: error: no matching function for call to 'ReefAngelClass::WaterLevelATO(int, int, double)'
That is the line in your code that is causing the error.
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

OK. I will try harder next time.
I was in a bit of a rush to get that uploaded before the 7pm cycle, so I can see how it works, because the next one is at 1am and I won't be awake to watch that one.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Oops. Sorry! :oops:
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

cosmith71 wrote:Oops. Sorry! :oops:
Not your fault Colin.
Your original code had ReefAngel.WaterLevelATO(Port6,60,75,79);

I changed it to be the settings for my WaterLevlATO which is
ReefAngel.WaterLevelATO(Port6,720,29,31);

I must have typed it wrong while I was doing other stuff at work.

Thanks for the code thought it seems to be working perfectly.

Just finished the 7pm cycle and the ATO did not kick in when the water exchange stopped at 7:20 and the level in the sump was still at 28% because all the water had not returned to the sump yet.

Final step is going to be rewiring the controller that came with the NatuReef De-nitrification chamber so the dosing pump can be plugged into the RA relay.

It won't be hard I looked at it over the weekend, but didn't want to do it until I knew all the other parts were working properly.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Glad it's working for you!
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Yeah. Me too.
Thanks for the help.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Colin;

Something isn't working with delay for the Water Level.
My water level has been at 26% all morning and the ATO has not turned on to bring the level up.
It's supposed to turn on at 29% and off at 31%

Something in the delay we set up yesterday is not turning the sensor back on.

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

unsigned long ATOUpdate=0;
////// Place global variable code above here

And

void loop()
{
ReefAngel.StandardLights( Port1,12,0,22,0 );
ReefAngel.StandardLights( Port2,13,0,21,0 );
ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port1 ) );
ReefAngel.StandardLights( Port7,13,0,21,0 );
ReefAngel.Relay.Set(Port5,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
ReefAngel.Relay.Set(Port8,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
if (ReefAngel.Relay.Status(Port5) && ATOUpdate==0) // Check to see if port 5 is on and update time is empty
{ ATOUpdate = now(); // If so, set the update time to now
ReefAngel.Relay.Off (Port6); } // and turn off the ATO pump
if (now() - ATOUpdate >= 120 && ATOUpdate != 0) // If it's been 120 sec, and the update time is NOT empty
{ ATOUpdate = 0; // Empty out the update time
ReefAngel.WaterLevelATO(Port6,720,29,31); } // and turn the ATO sensor back on

ReefAngel.PWM.SetActinic(MyCustomWave(50));
if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(0);
if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);
if (hour()<12 || hour()>=22) ReefAngel.PWM.SetActinic(30);
////// Place your custom code below here

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 <ReefAngel.h>

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

unsigned long ATOUpdate=0;
////// Place global variable code above here


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port4Bit | Port6Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
    // Use T2 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 825 );
    //Set Standard Menu
    ReefAngel.AddStandardMenu();


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

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

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

void loop()
{
    ReefAngel.StandardLights( Port1,12,0,22,0 );
    ReefAngel.StandardLights( Port2,13,0,21,0 );
    ReefAngel.Relay.Set( Port3, !ReefAngel.Relay.Status( Port1 ) );
    ReefAngel.StandardLights( Port7,13,0,21,0 );
    ReefAngel.Relay.Set(Port5,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
    ReefAngel.Relay.Set(Port8,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset
if (ReefAngel.Relay.Status(Port5) && ATOUpdate==0) // Check to see if port 5 is on and update time is empty
  { ATOUpdate = now();                             // If so, set the update time to now
    ReefAngel.Relay.Off (Port6); }                 // and turn off the ATO pump
if (now() - ATOUpdate >= 120 && ATOUpdate != 0)    // If it's been 120 sec, and the update time is NOT empty
  { ATOUpdate = 0;                                 // Empty out the update time
    ReefAngel.WaterLevelATO(Port6,720,29,31); }    // and turn the ATO sensor back on
    ReefAngel.PWM.SetActinic(MyCustomWave(50));
    if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(0);
    if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);
    if (hour()<12 || hour()>=22) ReefAngel.PWM.SetActinic(30);
    ////// Place your custom code below here
    

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

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // Water Level
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,66, "WL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}
byte MyCustomWave(byte maxspeed)
{
  static byte randomspeed=0;
  if (now()%11<5)
  {
    return randomspeed;
  }
  else if (now()%11>=5 && now()%11<10)
  {
    return maxspeed;
  }
  else
  {
    randomspeed=random(35,maxspeed);
    return 0;
  }
}
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

Are you sure it is not an ATO timeout?
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

I'm not 100% sure, because I'm not at home to look at the head unit.
I only have access to the Portal & the Reef Angel Client, would it show me a time out on either of those?

I don't think it is because if I look at the relay activity Port6 has not activated since Thursday May 28th at 7:24 am and when I came home from work yesterday it was at the 32% level.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Sacohen wrote:I'm not 100% sure, because I'm not at home to look at the head unit.
I only have access to the Portal & the Reef Angel Client, would it show me a time out on either of those?

I don't think it is because if I look at the relay activity Port6 has not activated since Thursday May 28th at 7:24 am and when I came home from work yesterday it was at the 32% level.
We should add ato timout and overheat flags to the r99 output..
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple on/off times

Post by rimai »

Yeah, I even created a new variable to hold the status all flags :)
ReefAngel.Flags
It currently holds these flags as declared in Globals.h
// Flags bits
#define ATOTimeOutFlag 0
#define OverheatFlag 1
#define BusLockFlag 2
#define LightsOnFlag 3
I just need to put them in /r99 and SendPortal functions.
Roberto.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Doesn't it say something on the head unit if it was in a timeout?
I was using the head unit most of the night yesterday and didn't notice and warnings, the screen looked normal to me.
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

You would have a red light on the head unit. Do you have the Android app? You can clear it remotely.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

The status light would be red?
If that's the case then there is not an ATO time out. I did not see that yesterday.

No I don't have the Android app. I'm not that far into the 21st century yet.
I still have an old Samsung Gravity 3.
My next phone will probably be an Andriod or IPhone when my contract runs out in a couple of weeks.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

Ok. I got home and checked and the Status light was not on, just to be sure I went into the menu and cleared the ATO timeout and it still has not started topping off the water.

The water level is at 25% and I know no water went in today because I happened to mark the level it was on the storage tank when I left this morning and it is still at that level.

So something in the new code is not resetting the ATO to start.
I don't know enough to figure it out yet.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

The problem is here...

This is the block of code where your ato is being called.. But it is only called one cycle when the ato update is reset.

// If it's been 120 sec, and the update time is NOT empty
if (now() - ATOUpdate >= 120 && ATOUpdate != 0)
{
ATOUpdate = 0; // Empty out the update time
ReefAngel.WaterLevelATO(Port6,720,29,31); // and turn the ATO sensor back on
}

I rearranged it a bit to be more readable for me,
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

This is broken too as its only going to cancel your ato port only for one cycle of loop

// Check to see if port 5 is on and update time is empty
if (ReefAngel.Relay.Status(Port5) && ATOUpdate==0)
{
ATOUpdate = now(); // If so, set the update time to now
ReefAngel.Relay.Off (Port6); // and turn off the ATO pump
}


Give me a few minutes to code up a solution...
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Multiple on/off times

Post by lnevo »

Ok try this

Code: Select all

    ReefAngel.WaterLevelATO(Port6,720,29,31);   // Enable ATO the ATO
    if (ReefAngel.Relay.Status(Port5))          // Check to see if port 5 is on and update time is empty
    { 
        ATOUpdate = now();                           // If so, set the update time to now
    } 
    
    if (now() - ATOUpdate < 120)                // If it hasnt been 120 seconds turn off the port
    { 
        ReefAngel.Relay.Off (Port6);            // and turn off the ATO pump
    }
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Yes, somehow the WaterLevelATO is never being called on to begin with. Deleted somehow?

--Colin
User avatar
cosmith71
Posts: 1432
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Multiple on/off times

Post by cosmith71 »

Oh, and sorry Steve. Massive fail on my part. :(

--Colin
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Multiple on/off times

Post by Sacohen »

No problem man.
At least you tried, more than I can do right now.
If it got deleted it may have been my fault. :)
Post Reply