Redundant temp probe
Posted: Thu Jan 22, 2015 1:11 pm
How would I code my overheat functions to check 2 temp probes before acting?
Community discussion about Reef Angel Controllers and reefing related subjects
https://forum.reefangel.com/
Yes, just the overheat - wow. That would be great. Thank you as always.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
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?
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]
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: Select all
#define T1_PROBE_BIT 1<<0
#define T2_PROBE_BIT 1<<1
#define T3_PROBE_BIT 1<<2
Nice - I will hold out to see if it becomes mainstream.lnevo wrote:Ok, let me raise an issue and we can see what happens.