Page 1 of 1
Can you help to code..
Posted: Mon Aug 06, 2012 5:25 pm
by kimacom
Hi,
I just got the RA+, wifi and tried many things
I know this is great controller, btw i need to know how to code first..

not easy..
my qestion is
If port #5 "always on" and it off by accidentally or on purpose,
is it possible to turn on automatically after cetain time out? like turn on after 5min or 1hr
thanks ahead
Tim
Re: Can you help to code..
Posted: Mon Aug 06, 2012 5:44 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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>
unsigned long LastPort5On=now();
void setup()
{
ReefAngel.Init();
ReefAngel.Relay.On(Port5);
}
void loop()
{
if (ReefAngel.Relay.Status(Port5)) LastPort5On=now();
if (now()-LastPort5On > 10)
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.RelayMaskOff|=Port5Bit;
}
ReefAngel.ShowInterface();
}
It's set for 10 seconds, but you can change to whatever number of seconds you would like.
Re: Can you help to code..
Posted: Tue Aug 07, 2012 8:03 am
by kimacom
Great, so is this ok port#5,6 turn on after 5min, 4hr?
#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 <ReefAngel.h>
////// Place global variable code below here
unsigned long LastPort5On=now();
unsigned long LastPort6On=now();
////// 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 = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port6Bit | Port8Bit;
// 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;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 860 );
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
ReefAngel.Relay.On(Port5);
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardATO( Port1,60 );
ReefAngel.StandardLights( Port2,9,0,11,0 );
ReefAngel.StandardHeater( Port3,775,785 );
ReefAngel.StandardFan( Port4,785,805 );
ReefAngel.Wavemaker( Port5,0 );
ReefAngel.Relay.Set( Port7, !ReefAngel.Relay.Status( Port8 ) );
ReefAngel.PWM.SetDaylight( PWMParabola(11,0,19,0,12,40,12) );
ReefAngel.PWM.SetActinic( PWMParabola(9,0,23,0,12,40,12) );
////// Place your custom code below here
if (ReefAngel.Relay.Status(Port5)) LastPort5On=now();
if (now()-LastPort5On > 300)
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.RelayMaskOff|=Port5Bit;
}
if (ReefAngel.Relay.Status(Port6)) LastPort6On=now();
if (now()-LastPort6On > 14400)
{
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.RelayMaskOff|=Port6Bit;
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "kimacom" );
ReefAngel.ShowInterface();
}
if wrong, please correct me,
and one more question, there is port #7 (opposite #8 ) could be delayed on start after #8 off?
thanks again
Tim
Re: Can you help to code..
Posted: Tue Aug 07, 2012 8:26 am
by rimai
You were just missing on last closing bracket on your last if statement.
Other than that, it looks good to me

Good job!!
You could use same concept for Port 7.
Declare a new variable up top
Then keep checking for status of port 8 and do something if the delay expires.
Try this:
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 <ReefAngel.h>
////// Place global variable code below here
unsigned long LastPort5On=now();
unsigned long LastPort6On=now();
unsigned long LastPort8On=now();
////// 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 = Port5Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port6Bit | Port8Bit;
// 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;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 860 );
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
ReefAngel.Relay.On(Port5);
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardATO( Port1,60 );
ReefAngel.StandardLights( Port2,9,0,11,0 );
ReefAngel.StandardHeater( Port3,775,785 );
ReefAngel.StandardFan( Port4,785,805 );
ReefAngel.Wavemaker( Port5,0 );
ReefAngel.Relay.Set( Port7, !ReefAngel.Relay.Status( Port8 ) );
ReefAngel.PWM.SetDaylight( PWMParabola(11,0,19,0,12,40,12) );
ReefAngel.PWM.SetActinic( PWMParabola(9,0,23,0,12,40,12) );
////// Place your custom code below here
if (ReefAngel.Relay.Status(Port5)) LastPort5On=now();
if (now()-LastPort5On > 300)
{
ReefAngel.Relay.On(Port5);
ReefAngel.Relay.RelayMaskOff|=Port5Bit;
}
if (ReefAngel.Relay.Status(Port6)) LastPort6On=now();
if (now()-LastPort6On > 14400)
{
ReefAngel.Relay.On(Port6);
ReefAngel.Relay.RelayMaskOff|=Port6Bit;
}
ReefAngel.Relay.Off(Port7);
if (ReefAngel.Relay.Status(Port8)) LastPort8On=now();
if (now()-LastPort8On > 3)
{
ReefAngel.Relay.On(Port7);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "kimacom" );
ReefAngel.ShowInterface();
}
Re: Can you help to code..
Posted: Tue Aug 07, 2012 9:16 am
by kimacom
Great.
so, port#7 will be turn on 3sec after port#8 off, right?
and can i give the time out port#7 for during like 10min?
or it will turn off automatically after port #8 turn on
because i use port #7 as water change pump(sump water out) so,
should i turn on port #8 first(means water change mode off) or just give exact time out for port#7(which means not opposite port #8)
i am confusing...
Thank you Sir!
Have a nice day.
Re: Can you help to code..
Posted: Tue Aug 07, 2012 5:15 pm
by binder
just to chime in, this type of changes could prevent water change and feeding change modes. this just means that if the ports get turned off by those modes that they will get turned back on by your code overrides.
Re: Can you help to code..
Posted: Wed Aug 08, 2012 3:21 pm
by kimacom
Yes, you are right.
So, I just remove the main pump port to manual switch, so i can turn it on and off with water change pump as well.
thanks