Page 1 of 2
Feeding mode and overheat timeout
Posted: Fri May 30, 2014 11:50 pm
by melovictor
Hi all,
Two quick questions:
1. How can I change the feeding mode timeout? It is currently set to 900s(15min) if I am not wrong. But this is a default value. I'd like to change it to 5min but I don't know how.
2. Also I'd like to clear the overheat mode automatically after 1hour(and the temp is lower then overheat temp). Is it even posible?
Can someone help?
Thanks!
Victor
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 7:57 am
by rimai
Do you have the wifi attachment and android app?
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 10:30 am
by melovictor
Nope...
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 10:34 am
by rimai
This is for feeding:
Code: Select all
InternalMemory.FeedingTimer_write(300);
I would highly recommend not to use auto clear of overheat.
You should really be alerted of that condition.
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 10:43 am
by melovictor
Thanks man!
But in case I travel? I'd like to setup it up in a way that overheat mode clears automatically after 1 or 2 hours if temperature is back to normality. Otherwise overheat would keep my lights off until I get back.
Is it posible?
Thanks again!
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 12:10 pm
by lnevo
I think auto clear makes sense after x amount of time if the temp has "stayed" down. If i have some time later i'll give you some code to tey
Re: Feeding mode and overheat timeout
Posted: Sat May 31, 2014 12:20 pm
by melovictor
That works for me too! And no risk involved on that....
Re: Feeding mode and overheat timeout
Posted: Sun Jun 01, 2014 12:31 pm
by melovictor
Does anyone know the code for clearing the overheat mode? thanks, Victor
Sent from my iPad using Tapatalk
Re: Feeding mode and overheat timeout
Posted: Sun Jun 01, 2014 1:29 pm
by rimai
Re: Feeding mode and overheat timeout
Posted: Mon Jun 02, 2014 7:03 am
by melovictor
Thanks a lot. I'll figure out a way to make safe use of it.
Regards,
Victor
Re: Feeding mode and overheat timeout
Posted: Tue Jun 03, 2014 12:18 pm
by melovictor
static time_t lastGoodTemp = now();
if(ReefAngel.Params.Temp[T1_PROBE] < InternalMemory.OverheatTemp_read()) lastGoodTemp=now();
if(now()-lastGoodTemp > 0 && now()-lastGoodTemp < 3600) ReefAngel.OverheatClear();
Does it look right? And safe?
Thanks!
Re: Feeding mode and overheat timeout
Posted: Tue Jun 03, 2014 12:30 pm
by binder
that looks wrong. it looks like it will clear it immediately. or maybe I'm missing the point of the check. it looks like as soon as the temp falls below the overheat temp, the last good time gets set, then the if statement clears the overheat every second for 3600 millis.
also, I would store now() in a variable if you are going to use it multiple times in a conditional check.
Sent from my Nexus 7
Re: Feeding mode and overheat timeout
Posted: Tue Jun 03, 2014 3:37 pm
by lnevo
I would structure it a bit differently.
If the temp is over the overheat temp, set the timer to now();
If the timer is greater than 1 hour && the t1_probe is less than the overheat temp then clear the override.
The way your doing it now definitely has some issues but it's close

Re: Feeding mode and overheat timeout
Posted: Tue Jun 03, 2014 3:37 pm
by lnevo
I would structure it a bit differently.
If the temp is over the overheat temp, set the timer to now();
If the timer is greater than 1 hour && the t1_probe is less than the overheat temp then clear the override.
The way your doing it now definitely has some issues but it's close

Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 9:30 am
by melovictor
Thanks guys!
time_t overheatTimer=now();
void CustomOverheatClear(byte probe)
{
if(ReefAngel.Params.Temp[probe] >= InternalMemory.OverheatTemp_read()) overheatTimer=now();
if((now()-overheatTimer > 3600)&&(bitRead(ReefAngel.AlertFlags, OverheatFlag))) ReefAngel.OverheatClear();
}
loop()
{
//...
CustomOverheatClear(T1_PROBE);
//...
}
How does it look now? Is (bitRead(ReefAngel.AlertFlags, OverheatFlag)) gonna tell me if overheat is triggered?
Cheers,
Victor
Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 9:57 am
by lnevo
Looks good to me. The bitRead may have an easier way...Roberto?
Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 10:41 am
by rimai
That is the easier way
Sent from my SM-G900P using Tapatalk
Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 2:40 pm
by lnevo
We should write a wrapper function to read each flag like we do for internal memory. Users shouldnt be concerned with how you store the flags or have to use bitRead to get it.
Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 2:51 pm
by rimai
I agree.
Can you open an issue on github?
I'll add them to next update.
Re: Feeding mode and overheat timeout
Posted: Wed Jun 04, 2014 3:14 pm
by lnevo
Sure.
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 1:39 am
by melovictor
That's cool. Please post the issue number here so we can follow as it develops

maybe even contribute!
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 8:08 am
by lnevo
Here you go
Add wrapper functions to read flags #147
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 10:48 am
by melovictor
Looks good!
I'd like to contribute with some coding. But I am not familiar with how everything is structured. Where to add those wrapper functions? which lib?
Do you have a list of the all the flags that should be wrapped? Are they all in the same lib?
Sorry if those are noobs questions but I need to warm up here...heheh
See ya!
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 11:09 am
by rimai
Yeah, the bits are declared in the Globals.h file.
What is the easiest way??
Creating a function like ReefAngel.IsOverheat()?
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 11:33 am
by melovictor
I've found the flags....
// Alert Flags bits
#define ATOTimeOutFlag 0
#define OverheatFlag 1
#define BusLockFlag 2
#define LeakFlag 3
// Status Flag Bits
#define LightsOnFlag 0
#define FeedingFlag 1
#define WaterChangeFlag 2
Whar do you think? Do we need wrappers for all of them? Where should I place the wrappers?
E.g.:
isOverheat()
isLightsOn()
isFeedingMode()
isWaterChangeMode()
...
and so on!
What are those Exceed flags for?
#define ATO_Single_Exceed_Flag 800 //733 //747
#define ATO_Exceed_Flag 801 //734 //748
#define Overheat_Exceed_Flag 802 //735 //749
Victor
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 11:41 am
by lnevo
I don't think we need the status flags. There's already pretty common methods for determining those. I think just for the Alert Flags since there isn't really other ways to determine.
I don't think the Exceed flags are really used either. They may be from some legacy. Now there is just the one in the Alert Flag.
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 11:55 am
by melovictor
I got it!
So I'll focus only on the alert flags.
// Alert Flags bits
#define ATOTimeOutFlag 0
#define OverheatFlag 1
#define BusLockFlag 2
#define LeakFlag 3
Something like: isATOTimeOut(), isOverheat(), isBusLock() and isLeakFlag().
I just check for any posible confict with these names. But all clear...they are not being used....
I ask again, where should we be placing these functions? What is the best location for them?
Regards,
Victor
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 12:01 pm
by rimai
They should be declared inside ReefAngel.h and the code would be inside ReefAngel.cpp
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 12:38 pm
by melovictor
Thanks Roberto!
I found an IsLeakDetected() function but it doesn't read from the LeakFlag status. But from what I could understand it already does the job. So I guess we probably don't need a wrapper for LeakFlag. Is that right?
As for the others isATOTimeOut(), isOverheat() and isBusLock() I'll declare and implement the functions and send for your appreciation
Regards,
Victor
Re: Feeding mode and overheat timeout
Posted: Thu Jun 05, 2014 12:38 pm
by melovictor
Thanks Roberto!
I found an IsLeakDetected() function but it doesn't read from the LeakFlag status. But from what I could understand it already does the job. So I guess we probably don't need a wrapper for LeakFlag. Is that right?
As for the others isATOTimeOut(), isOverheat() and isBusLock() I'll declare and implement the functions and send for your appreciation
Regards,
Victor