Feeding mode and overheat timeout

Basic / Standard Reef Angel hardware
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Feeding mode and overheat timeout

Post 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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

Do you have the wifi attachment and android app?
Roberto.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post by melovictor »

Nope...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post 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.
Roberto.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post 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
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post by melovictor »

That works for me too! And no risk involved on that....
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post by melovictor »

Does anyone know the code for clearing the overheat mode? thanks, Victor


Sent from my iPad using Tapatalk
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

Code: Select all

ReefAngel.OverheatClear();
Roberto.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post by melovictor »

Thanks a lot. I'll figure out a way to make safe use of it.
Regards,
Victor
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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!
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Feeding mode and overheat timeout

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post 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 :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post 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 :)
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post by lnevo »

Looks good to me. The bitRead may have an easier way...Roberto?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

That is the easier way :)

Sent from my SM-G900P using Tapatalk
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post 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.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

I agree.
Can you open an issue on github?
I'll add them to next update.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post by lnevo »

Sure.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post by melovictor »

That's cool. Please post the issue number here so we can follow as it develops :-) maybe even contribute!
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post by lnevo »

Here you go :)

Add wrapper functions to read flags #147
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

Yeah, the bits are declared in the Globals.h file.
What is the easiest way??
Creating a function like ReefAngel.IsOverheat()?
Roberto.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Feeding mode and overheat timeout

Post 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.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Feeding mode and overheat timeout

Post by rimai »

They should be declared inside ReefAngel.h and the code would be inside ReefAngel.cpp
Roberto.
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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
melovictor
Posts: 19
Joined: Tue Jan 21, 2014 3:56 am

Re: Feeding mode and overheat timeout

Post 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
Post Reply