Timed ports not working....

Do you have a question on how to do something.
Ask in here.
Post Reply
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Timed ports not working....

Post by Naptalene »

Hello :)

I'm trying to setup a CO2 solenoid to turn on between 12:00 and 19:00.
I have an RA Plus.
I used the Wizard via the web plugin and created my basic code using internal memory.
I used the Timed Schedule option to setup the port.
It didn't turn on and off :(
I used the Android App to change the on/off times using StdLights On/Off in the memory tab and had no luck.
I have control over the relay via the the phone app and the Local web interface.

So I figured what the heck..... try code it and see if I can do it - spoiler alert...I have failed :?

Can you guys help me trouble shoot the Timed Schedule and grade my attempt at coding as well :P

I have defined my ports and labelled them like this so I can make sense of my code -
This sits under the #include right at the start.

Code: Select all

#define Return          Port1
#define Osmolater       Port2
#define Heater          Port3
#define RW4             Port4
#define SumpPump        Port5
#define Doser           Port6
#define GasPump         Port7 // I originally had this labelled CO2 but thought it might be the cause of the issue
#define Fans            Port8
And I have Defined labels for the head unit to match..

Code: Select all


 ////// Place additional initialization code below here
    
    ReefAngel.CustomLabels[0]="Return";
    ReefAngel.CustomLabels[1]="ATO";
    ReefAngel.CustomLabels[2]="Heater";
    ReefAngel.CustomLabels[3]="RW4";
    ReefAngel.CustomLabels[4]="SumpPump";
    ReefAngel.CustomLabels[5]="Doser";
    ReefAngel.CustomLabels[6]="GasPump";
    ReefAngel.CustomLabels[7]="Fans";  

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

I setup this at the top as a block (I find it easier to read the code) as attempt 1

Attempt1 ripped from your guys forum replies..

Code: Select all


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

void GasPumpTimer()     //Timer for CO2 Relay until I get the std light timer working 

{    
    if (hour()>=12 && hour()<19)
    {
        ReefAngel.Relay.On (GasPump);
    }

}

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

So then I tried to flip the thinking

Code: Select all

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

void GasPumpTimer()     //Timer for CO2 Relay until I get the std light timer working 

{    
    if (hour()<12 || hour()>=19)
    {
        ReefAngel.Relay.Off (GasPump);
    }

}

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

I also tried the same thing with different format (I put each hour argument in its own brackets)...

Code: Select all


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

void GasPumpTimer()     //Timer for CO2 Relay until I get the std light timer working 

{    
    if ((hour()<12) || (hour()>=19))
    {
        ReefAngel.Relay.Off (GasPump);
    }

}

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

It will toggle the relay on but not off.
If I flip the < and > logic it turns the relay off and that's it. it seems to ignore the "second half".

So I thought..... aha.....I need an "else".
Bring on...

Code: Select all

{ 

    
    if ((hour()<12) || (hour()>=19))
    {
        ReefAngel.Relay.Off (GasPump);
    }
    else 
    {
        ReefAngel.Relay.On(GasPump);
    }
}

But it had the same issue if I use it with the && option or the || option.
I also commented out

Code: Select all

 ReefAngel.Relay.On( GasPump );
to check if that was messing with it.

What am I missing?
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

Is it normal to have 2 entries for #include <InternalEEPROM.h>? It's what the wizard gave me.
The wizard is also trying to give me extra relays even though I haven't selected the Relay Expansion option.

I also tried to move the the GasPumpTimer code into the Void loop() as normal arguments with all the permutations. ie..

Code: Select all


void loop()
{
    if ((hour()<12) || (hour()>=19))
    {
        ReefAngel.Relay.Off (GasPump);
    }
    else 
    {
        ReefAngel.Relay.On(GasPump);
    }
}
 
but I had the same issues.

my complete code...

Code: Select all


/*Planted tank code
Currently on V1.01 06_08_18

SumpSafety - Working -Return Shut-off when float is triggered. Install switches and double check the logic is correct way around
GasPumpTimer - Not working -between 12:00 and 19:00 coded- this is because the Standard seems to not work right now
CO2 control As safety net - curently disabled
*/



#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>

// Labels to make code easier for me
 
#define Return          Port1
#define Osmolater       Port2
#define Heater          Port3
#define RW4             Port4
#define SumpPump        Port5
#define Doser           Port6
#define GasPump         Port7
#define Fans            Port8

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

void SumpSafety()    //Safety kill for sump overflow

{
    if (ReefAngel.HighATO.IsActive())  
    
    {
        ReefAngel.Relay.Off(Return);
    }
    else
    { ReefAngel.Relay.On(Return);
        
    }
}

void GasPumpTimer()     //Timer for CO2 Relay until I get the std light timer working [ref for timing units.......If (hour()==12 && minute() == 30 && second() == 15]

{ 

    
    if ((hour()<12) || (hour()>=19))
    {
        ReefAngel.Relay.Off (GasPump);
    }
    else 
    {
        ReefAngel.Relay.On(GasPump);
    }
}

////// 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.AddSalinityExpansion();  // Salinity Expansion Module
    ReefAngel.SetTemperatureUnit( Celsius );  // set to Celsius Temperature
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port7Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 280 );
    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;
    ReefAngel.DDNS("****");

    // Ports that are always on
    
    ReefAngel.Relay.On( Return );
    ReefAngel.Relay.On( Osmolater );
    ReefAngel.Relay.On( RW4 );
    ReefAngel.Relay.On( GasPump );
    ReefAngel.Relay.On( Doser );
    ReefAngel.Relay.On( SumpPump ); 
    
    ////// Place additional initialization code below here
    
    ReefAngel.CustomLabels[0]="Return";
    ReefAngel.CustomLabels[1]="ATO";
    ReefAngel.CustomLabels[2]="Heater";
    ReefAngel.CustomLabels[3]="RW4";
    ReefAngel.CustomLabels[4]="SumpPump";
    ReefAngel.CustomLabels[5]="Doser";
    ReefAngel.CustomLabels[6]="GasPump";
    ReefAngel.CustomLabels[7]="Fans";  




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

void loop()
{
    ReefAngel.StandardHeater1( Heater );
    //ReefAngel.StandardLights( GasPump ); //Not working at the moment - eek
    ReefAngel.StandardFan1( Fans );
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    //ReefAngel.CO2Control( CO2);   // Toggle CO2 on/off as safety net. Get timers working first. Currently Set as memory. For code use this ->(Relay To Control ,Ph on/High value, PH off/ low)

    ////// Place your custom code below here
    
    SumpSafety();
    GasPumpTimer();
   
    
    ////// Place your custom code above here

    ReefAngel.Portal( "*****" );

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



// RA_STRING1=null
// RA_STRING2=null
// RA_STRING3=null
// RA_LABEL LABEL_ACTINIC=Actinic
// RA_LABEL LABEL_DAYLIGHT=Daylight

Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

Just seen a problem with my first attempt that I ripped....

Code: Select all

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

void GasPumpTimer()     //Timer for CO2 Relay until I get the std light timer working 

{    
    if (hour()>=12 && hour()<19)
    {
        ReefAngel.Relay.On (GasPump);
    }

}

////// Place global variable code above here
that would always be on because I had

Code: Select all

ReefAngel.Relay.On(GasPump)
enabled.......

I said turn it on at that time, otherwise its always on ....correct?
Dammit - why did I see that now.

So in theory would this be the way to do it?

Code: Select all


if (hour()>=12 && hour()<19)
{ 
   ReefAngel.Relay.On(GasPump);
}
else 
{
ReefAngel.Relay.Off(GasPump);
}

and I would need to delete the line

Code: Select all

ReefAngel.Relay.On(GasPump);
in the initialisation code.

Or could I rather do this in the initialization.....

Code: Select all

ReefAngel.Relay.Off(GasPump);
with

Code: Select all

 if (hour()>=12 && hour()<19)
    {
        ReefAngel.Relay.On (GasPump);
    }

so it defaults to off, and turns on when the time arguments are true. Then goes back to off.
that way I know if the unit resets it will default to off unless the times trigger?
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

OK....
StdLights.

The only thing that triggers any change on the relay is by changing the off time.

if the on time is learlier than the off time, the relay is off and it doesnt change if it passes the off time.
If I make the off time earlier than the on time, the relay turns on. It stays in this state even if it goes past the on time.
If I change the off time back later than the on time, then the relay turns off and I'm back at the beginning.

is there something weird with the timer clock?
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

Ok,

Tested a second head unit and the same issue with the standard timer.
also does the weird thing with making the off time earlier than the on time

I'll install the arduino IDE and copy/paste the code into that and upload.
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

same issue on the second reefangel, using the arduino IDE and wizard.

no clue whats up
Believe it or not.... I can ask even stupider questions than this one.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Timed ports not working....

Post by rimai »

Try this:

Code: Select all

ReefAngel.StandardLights(Port1,12,0,19,0);
Roberto.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

Ok cool,
but it just started working on the IDE version.
I added
ReefAngel.Relay.Off(Port1);
to this Arduino wizard code that wasnt working...

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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    ReefAngel.AddSalinityExpansion();  // Salinity Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = 0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

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


    // Ports that are always on

    ////// Place additional initialization code below here
    
ReefAngel.Relay.Off(Port1);
    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.DayLights( Port1 );
    ReefAngel.DCPump.UseMemory = true;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ////// Place your custom code below here
    

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

    // This should always be the last line
    ReefAngel.Portal( "naptalene" );
    ReefAngel.DDNS( "planted" ); // Your DDNS is naptalene-planted.myreefangel.com
    ReefAngel.ShowInterface();
}
and it suddenly worked.
I have just tried it with that line commented out and it still worked.......

I'm just going to reload the code without that little line again...
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

ok, reloaded IDE version working now.

Same controller etc. and re-tried the webplugin version..... not working.
Going to try the same thing with that code quickly so I do the same method....

EDIT - ignore that, wrong code loaded
Believe it or not.... I can ask even stupider questions than this one.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

DAMMMMITTTTTT........
Think I found the problem.....
My RA is mounted on the side of my tank where I cant see it. I rely heavily on the webinterface/phone app.
So while im testing the second head unit its on the table next to me.
The head unit was showing a different time to the phone and web interface......it started working after I told the unit sync time/date with my phone.

The operational unit on the tank has the incorrect time too.
About to re-test on that but that makes a lot of sense.

Why does the phone app/ web interface show different times to the actual unit?
any easy way of adding a check for that on them?
Believe it or not.... I can ask even stupider questions than this one.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Timed ports not working....

Post by rimai »

Yeah, the phone app does not pull the time from the controller :(
Roberto.
Naptalene
Posts: 98
Joined: Tue Nov 05, 2013 12:50 am

Re: Timed ports not working....

Post by Naptalene »

Second unit running now :D

I was pulling my hair out lol. At least that makes sense as to why inverting the times in the memory gave weird results.
I was trying to figure out why the hell I was the only person having this issue lol.

The guys I apprenticed under back in the day are rolling in their graves because I didn't check the obvious things first :P
Believe it or not.... I can ask even stupider questions than this one.
Post Reply