How to set time for Feeding Mode
How to set time for Feeding Mode
How do I set feeding mode to run automatically at 5pm and 9pm? Basically I want port8 and port5 to turn off at 5pm and turn back on at 5.15pm and then turn off at 9pm and turn back on at 9.15pm.
Re: How to set time for Feeding Mode
Do you want feeding mode? Or do you just want the port off and back on?
Re: How to set time for Feeding Mode
I want to run feeding mode at the times I specified.lnevo wrote:Do you want feeding mode? Or do you just want the port off and back on?
Re: How to set time for Feeding Mode
This should do it:
Code: Select all
if ( (now()%SECS_PER_HOUR*17==0) || (now()%SECS_PER_HOUR*21==0) ) {
FeedingModeStart();
}
Re: How to set time for Feeding Mode
do I paste that in the custom code section?
and if I wanted 5:30pm I would just do 17==30 ?
thanks
and if I wanted 5:30pm I would just do 17==30 ?
thanks
Re: How to set time for Feeding Mode
Yes, but the function uses seconds and not minutes. so you would need to use 1800 instead of 30
Roberto.
Re: How to set time for Feeding Mode
Whatever time you want has to be in seconds and would be on the right side of the equal sign.
So you could add 30 minutes by doing
(SECS_PER_HOUR*17)+1800 or just calculate the total value...which is 63,000 i believe
Or
(SECS_PER_HOUR/2)*35
Or any other permutation
So you could add 30 minutes by doing
(SECS_PER_HOUR*17)+1800 or just calculate the total value...which is 63,000 i believe
Or
(SECS_PER_HOUR/2)*35
Or any other permutation
Re: How to set time for Feeding Mode
lnevo wrote:This should do it:
Code: Select all
if ( (now()%SECS_PER_HOUR*17==0) || (now()%SECS_PER_HOUR*21==0) ) { FeedingModeStart(); }
When I compiled this I got the error - "FeedingModeStart" was not declared in this scope
I have the code in the custom code area.
Re: How to set time for Feeding Mode
I loaded the code exactly and now it puts me in feeding mode at the start of every new hour. I only want it to run twice per day. I thought the code specified 1700 and 2100
Re: How to set time for Feeding Mode
Try this instead
Added some parens to make sure the math was in correct order.
Code: Select all
if ( (now()%(SECS_PER_HOUR*17)==0) || (now()%(SECS_PER_HOUR*21)==0) ) {
FeedingModeStart();
}
Re: How to set time for Feeding Mode
I loaded the new code and it did not go into feeding mode at 21:00
Re: How to set time for Feeding Mode
Lets eliminate math problems...
Do now()%75600==0 for 9pm and 61200 for 5pm
If it still doesnt work then I'll need to see your whole code because you may have a delay somewhere that would cause that code not to get hit each second...
It may also be why your pump is logging extra seconds if you have something taking too much time in your code.
If thats the case we can change the logic to just do it when the hour and minute are at 5pm and 9pm.
Do now()%75600==0 for 9pm and 61200 for 5pm
If it still doesnt work then I'll need to see your whole code because you may have a delay somewhere that would cause that code not to get hit each second...
It may also be why your pump is logging extra seconds if you have something taking too much time in your code.
If thats the case we can change the logic to just do it when the hour and minute are at 5pm and 9pm.
Re: How to set time for Feeding Mode
Well I reloaded the old code at 945 because I wasn't 100% sure the cable was fully connected to the RA the previous time I tried to upload. Anyway the feeding mode ran at 2200 which I thought meant it was going to run every hour. However it did NOT run at 2300 or 0000. So that's a good thing. I will see how it continues to play out before I try the new code.kirkwood wrote:I loaded the new code and it did not go into feeding mode at 21:00
Re: How to set time for Feeding Mode
I still can't get the feeding mode to run properly. I just loaded in the simplified code that eliminated all the math and the feeding mode did not run at 9pm. Here is my full code.
#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
////// 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 | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port6Bit;
// 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 );
// Ports that are always on
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.MHLights( Port1,16,0,23,0,5 );
ReefAngel.MHLights( Port2,17,0,21,30,10 );
ReefAngel.DosingPumpRepeat( Port3,0,120,292 );
ReefAngel.DosingPumpRepeat( Port4,60,120,340 );
ReefAngel.StandardHeater( Port6,775,805 );
ReefAngel.StandardATO( Port7,900 );
////// Place your custom code below here
//Start Feeding Mode at 17:00 and 21:00
if ( (now()%61200==0) || (now()%75600==0) ) {
ReefAngel.FeedingModeStart();
}
const byte numPumps=3;
byte pump[numPumps] = { Port3, Port4, Port7 };
byte portalMinutes[numPumps] = { 0, 2, 4 };
byte portalSeconds[numPumps] = { 1, 3, 5 };
static time_t pumpTimer[numPumps];
static boolean pumpStatus[numPumps];
static boolean atoDisabled;
for (int i=0;i< numPumps;i++) {
if (ReefAngel.Relay.Status(pump)) {
if (!pumpStatus) {
pumpTimer=now()-pumpTimer; // Pump was off, timer is now a time
pumpStatus=true;
}
} else {
if (pumpStatus) {
pumpTimer=now()-pumpTimer; // Pump was on, timer is now a timer
pumpStatus=false;
// Normalize and assign to CustomVar for reporting on the portal
ReefAngel.CustomVar[portalMinutes]=pumpTimer[i]/60; // Number of Minutes
ReefAngel.CustomVar[portalSeconds[i]]=pumpTimer[i]%60; // Number of Seconds
}
}
}
if (now()%SECS_PER_DAY==SECS_PER_DAY-1) pumpTimer[0]=0; // Clear timer for DPump1
if (now()%SECS_PER_DAY==SECS_PER_DAY-1) pumpTimer[1]=0; // Clear timer for DPump2
if (bitRead(ReefAngel.Relay.RelayMaskOn, 6)==1) { // ATO relay was forced on
atoDisabled=true; // don't want to change the variable names yet.. but you may want to to make it clearer..
}
if (atoDisabled && (bitRead(ReefAngel.Relay.RelayMaskOn, 6)==0)) { // ATO override has been cleared
pumpTimer[2]=0; // Clear timer for ATOPort
atoDisabled=false;
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "kirkwood" );
ReefAngel.ShowInterface();
}
#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
////// 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 | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port6Bit;
// 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 );
// Ports that are always on
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port8 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.MHLights( Port1,16,0,23,0,5 );
ReefAngel.MHLights( Port2,17,0,21,30,10 );
ReefAngel.DosingPumpRepeat( Port3,0,120,292 );
ReefAngel.DosingPumpRepeat( Port4,60,120,340 );
ReefAngel.StandardHeater( Port6,775,805 );
ReefAngel.StandardATO( Port7,900 );
////// Place your custom code below here
//Start Feeding Mode at 17:00 and 21:00
if ( (now()%61200==0) || (now()%75600==0) ) {
ReefAngel.FeedingModeStart();
}
const byte numPumps=3;
byte pump[numPumps] = { Port3, Port4, Port7 };
byte portalMinutes[numPumps] = { 0, 2, 4 };
byte portalSeconds[numPumps] = { 1, 3, 5 };
static time_t pumpTimer[numPumps];
static boolean pumpStatus[numPumps];
static boolean atoDisabled;
for (int i=0;i< numPumps;i++) {
if (ReefAngel.Relay.Status(pump)) {
if (!pumpStatus) {
pumpTimer=now()-pumpTimer; // Pump was off, timer is now a time
pumpStatus=true;
}
} else {
if (pumpStatus) {
pumpTimer=now()-pumpTimer; // Pump was on, timer is now a timer
pumpStatus=false;
// Normalize and assign to CustomVar for reporting on the portal
ReefAngel.CustomVar[portalMinutes]=pumpTimer[i]/60; // Number of Minutes
ReefAngel.CustomVar[portalSeconds[i]]=pumpTimer[i]%60; // Number of Seconds
}
}
}
if (now()%SECS_PER_DAY==SECS_PER_DAY-1) pumpTimer[0]=0; // Clear timer for DPump1
if (now()%SECS_PER_DAY==SECS_PER_DAY-1) pumpTimer[1]=0; // Clear timer for DPump2
if (bitRead(ReefAngel.Relay.RelayMaskOn, 6)==1) { // ATO relay was forced on
atoDisabled=true; // don't want to change the variable names yet.. but you may want to to make it clearer..
}
if (atoDisabled && (bitRead(ReefAngel.Relay.RelayMaskOn, 6)==0)) { // ATO override has been cleared
pumpTimer[2]=0; // Clear timer for ATOPort
atoDisabled=false;
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "kirkwood" );
ReefAngel.ShowInterface();
}
Re: How to set time for Feeding Mode
Well... I guess the math is wrong
It took me a good 5 minutes and a few scratches in my head saying WTF is going on??? LOL
We need to actually do module of 24hrs and check the remainder for the hours you want...
So, here it is:
It took me a good 5 minutes and a few scratches in my head saying WTF is going on??? LOL
We need to actually do module of 24hrs and check the remainder for the hours you want...
So, here it is:
Code: Select all
if ( (now()%86400==61200) || (now()%86400==75600) ) {
Roberto.
Re: How to set time for Feeding Mode
Wow good catch. I'm losing it these days...
Re: How to set time for Feeding Mode
are you sure you ever had it to begin with???lnevo wrote:Wow good catch. I'm losing it these days...
i know that feeling all too well.
Sent from my Nexus 7
Re: How to set time for Feeding Mode
Sweet I will try the new code tomorrow. I've got a trip coming up soon so I'm trying to have everything set up just right before I go. With the RA this will be the first true stress free vacation.
Re: How to set time for Feeding Mode
The new code worked great today. Thanks!
- ewaldsreef
- Posts: 82
- Joined: Tue Oct 08, 2013 8:22 pm
- Location: Salt Lake City, UT
- Contact:
Re: How to set time for Feeding Mode
Found this post on a search. Looks like its an older one but is this code the best way to activate feedmode at a set time each day?
Re: How to set time for Feeding Mode
yes, this is the best way to do that. even though the code is old, it is still valid and the only way to do it.ewaldsreef wrote:Found this post on a search. Looks like its an older one but is this code the best way to activate feedmode at a set time each day?
Sent from my iPad mini
- ewaldsreef
- Posts: 82
- Joined: Tue Oct 08, 2013 8:22 pm
- Location: Salt Lake City, UT
- Contact:
Re: How to set time for Feeding Mode
Glad I found this old post. Tried the code and it works perfectly.
Re: How to set time for Feeding Mode
Awesome!ewaldsreef wrote:Glad I found this old post. Tried the code and it works perfectly.
Sent from my iPad mini