Page 1 of 1

Redundant temp probe

Posted: Thu Jan 22, 2015 1:11 pm
by Smotz
How would I code my overheat functions to check 2 temp probes before acting?

Re: Redundant temp probe

Posted: Thu Jan 22, 2015 4:23 pm
by lnevo
You'd need to make your own overheat function and run it checking both temp probes. What do you have now? Just the overheat ports defined? I can write you up a function tomorrow if you need it

Re: Redundant temp probe

Posted: Thu Jan 22, 2015 5:57 pm
by Smotz
lnevo wrote:You'd need to make your own overheat function and run it checking both temp probes. What do you have now? Just the overheat ports defined? I can write you up a function tomorrow if you need it
Yes, just the overheat - wow. That would be great. Thank you as always.

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 7:24 am
by lnevo
Just want to confirm. Do you want it to overheat when both probes are over or if only one goes over? Right now the code below is for either. If you want to change it switch the || to &&

Code: Select all


void myOverheat() 
{
    static byte Overheatmillis;

    // if overheat probe exceeds the temp
    if ( ReefAngel.Params.Temp[T1_PROBE] <= InternalMemory.OverheatTemp_read() ||
         ReefAngel.Params.Temp[T2_PROBE] <= InternalMemory.OverheatTemp_read() )
         Overheatmillis=millis();
    if (millis()-Overheatmillis>3000) // Only flag overheat if we have overheat for 3 seconds
    {
        ReefAngel.LED.On();
        bitSet(ReefAngel.AlertFlags,OverheatFlag);
        // invert the ports that are activated
        ReefAngel.Relay.RelayMaskOff &= ~ReefAngel.OverheatShutoffPorts;
#ifdef RelayExp
        for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
        {
            ReefAngel.Relay.RelayMaskOffE[i] &= ~ReefAngel.OverheatShutoffPortsE[i];
        }
#endif  // RelayExp
    }
}
[code]

On a side-note. Roberto how does the Overheatmillis get reset so that if the temp goes over for just a blip it doesn't trigger... you are checking to see if 3 seconds has gone by, but if the temp drops back down we aren't resetting Overheatmillis... therefore the 3 seconds is just a delay? Am I reading that properly?

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 11:26 am
by Smotz
If both flip.

Perfect - I am going to use this. Thank you.
lnevo wrote:Just want to confirm. Do you want it to overheat when both probes are over or if only one goes over? Right now the code below is for either. If you want to change it switch the || to &&

Code: Select all


void myOverheat() 
{
    static byte Overheatmillis;

    // if overheat probe exceeds the temp
    if ( ReefAngel.Params.Temp[T1_PROBE] <= InternalMemory.OverheatTemp_read() ||
         ReefAngel.Params.Temp[T2_PROBE] <= InternalMemory.OverheatTemp_read() )
         Overheatmillis=millis();
    if (millis()-Overheatmillis>3000) // Only flag overheat if we have overheat for 3 seconds
    {
        ReefAngel.LED.On();
        bitSet(ReefAngel.AlertFlags,OverheatFlag);
        // invert the ports that are activated
        ReefAngel.Relay.RelayMaskOff &= ~ReefAngel.OverheatShutoffPorts;
#ifdef RelayExp
        for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
        {
            ReefAngel.Relay.RelayMaskOffE[i] &= ~ReefAngel.OverheatShutoffPortsE[i];
        }
#endif  // RelayExp
    }
}
[code]

On a side-note. Roberto how does the Overheatmillis get reset so that if the temp goes over for just a blip it doesn't trigger... you are checking to see if 3 seconds has gone by, but if the temp drops back down we aren't resetting Overheatmillis... therefore the 3 seconds is just a delay? Am I reading that properly?[/quote]

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 11:30 am
by lnevo
Actually... there's an issue with the code above!!!

Just realized what I had asked Roberto and the way it's written is that if either probe is less than the overheat temp it will reset the overheat counter... therefore an update is required to measure both probes...

Forthcoming momentarily...

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 11:32 am
by lnevo
Ok, only change was the || needed to become &&. So now both probes need to be less than the overheat temp to trigger the overheat condition. if either probe goes under it will start the countdown to 3 seconds. If it stays over then the overheat will trigger.

Please test it :)

Code: Select all

void myOverheat() 
{
static byte Overheatmillis;

// if overheat probe exceeds the temp
if ( ReefAngel.Params.Temp[T1_PROBE] <= InternalMemory.OverheatTemp_read() &&
ReefAngel.Params.Temp[T2_PROBE] <= InternalMemory.OverheatTemp_read() )
Overheatmillis=millis();
if (millis()-Overheatmillis>3000) // Only flag overheat if we have overheat for 3 seconds
{
ReefAngel.LED.On();
bitSet(ReefAngel.AlertFlags,OverheatFlag);
// invert the ports that are activated
ReefAngel.Relay.RelayMaskOff &= ~ReefAngel.OverheatShutoffPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOffE[i] &= ~ReefAngel.OverheatShutoffPortsE[i];
}
#endif // RelayExp
}
}

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 11:34 am
by lnevo
Roberto, thinking on this. Is this something we can put in the variable for overheat ports? maybe so we can specify something like this:

ReefAngel.OverheatProbe = T1_PROBE | T2_PROBE;

Could be simple enough to add possibly, though I suspect it would need to change a few things...

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 12:09 pm
by rimai
We would need to create new definitions like this:

Code: Select all

#define T1_PROBE_BIT 1<<0
#define T2_PROBE_BIT 1<<1
#define T3_PROBE_BIT 1<<2
Which then could be used as you mentioned.
Otherwise, T1_PROBE | T2_PROBE would result in the value 3, which is actually T3_PROBE

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 12:33 pm
by lnevo
Ok, let me raise an issue and we can see what happens. :)

Re: Redundant temp probe

Posted: Fri Jan 23, 2015 7:55 pm
by Smotz
lnevo wrote:Ok, let me raise an issue and we can see what happens. :)
Nice - I will hold out to see if it becomes mainstream.

Redundancy seems like a good idea, I think..

Re: Redundant temp probe

Posted: Sat Jan 24, 2015 5:40 am
by lnevo
Well it may take a while...use that code in the meantime and help make sure no issues

Re: Redundant temp probe

Posted: Fri Jun 05, 2015 9:14 pm
by joshlawless
I like this idea!