Detecting Expansion Relays
Detecting Expansion Relays
Is it possible to determine if a relay box is missing from the RA code? I had a power failure and I would like to put my main RA box on a UPS but not put my Expansion box on one. That way the essential things could keep running but not the lights. But then I thought it would be awesome if I could make some decisions in my code based on the presence (or absence) of the expansion box. I figured that it was likely that the I2C would know that the box wasn't there so I thought I would ask.
Don
Don
Re: Detecting Expansion Relays
Yes, there is a way to detect relay expansion presence, but I have very little to give you at the moment.
I've never thought of this scenario
It's pretty cool idea though
The only thing I have to give you is the I2C scanner code.
I've never thought of this scenario
It's pretty cool idea though
The only thing I have to give you is the I2C scanner code.
- Attachments
-
- I2CScanner.ino
- (1.9 KiB) Downloaded 437 times
Roberto.
Re: Detecting Expansion Relays
Hi,
With the file you sent me this turned out to be pretty easy.
I have modified the Relay classes (.cpp and .h) and included them here. I put in a define to enable this feature so that it wouldn't take any additional memory unless SaveRelaysPresent is defined in the features file.
When it is enabled, a new function exists: boolean RelayClass::IsRelayPresent(byte module). A module argument of 0xff indicates the main relays (kind of useless, they can't ever be gone I guess). An argument of 0-7 querys the status of a particular expansion relay box.
Here is how I used it in my sketch:
This turns off non-essential things connected to the main relay box if the expansion is missing. This allows the UPS running the main box to continue to run as long as possible during a power failure. I have tested it and it works great.
I have attached the new relay.cpp and relay.h. If you think they are OK can you add this to the development libraries.
Don
With the file you sent me this turned out to be pretty easy.
I have modified the Relay classes (.cpp and .h) and included them here. I put in a define to enable this feature so that it wouldn't take any additional memory unless SaveRelaysPresent is defined in the features file.
When it is enabled, a new function exists: boolean RelayClass::IsRelayPresent(byte module). A module argument of 0xff indicates the main relays (kind of useless, they can't ever be gone I guess). An argument of 0-7 querys the status of a particular expansion relay box.
Here is how I used it in my sketch:
Code: Select all
powerOut = !ReefAngel.Relay.IsRelayPresent(0);
// turn off power hogs if the power is out
if (powerOut)
{
ReefAngel.Relay.Off (SKIMMER);
ReefAngel.Relay.Off (SKUPPER);
ReefAngel.Relay.Off (REFUGIUM);
ReefAngel.Relay.Off (REACTOR);
}
This turns off non-essential things connected to the main relay box if the expansion is missing. This allows the UPS running the main box to continue to run as long as possible during a power failure. I have tested it and it works great.
I have attached the new relay.cpp and relay.h. If you think they are OK can you add this to the development libraries.
Don
- Attachments
-
- Relay.zip
- Relay.cpp and Relay.h with new IsRelayPresent function
- (2.24 KiB) Downloaded 432 times
Re: Detecting Expansion Relays
Wow!!!
That is so cool!!!
Thanks for sharing
I'll get it merged into the libraries.
That is so cool!!!
Thanks for sharing
I'll get it merged into the libraries.
Roberto.
Re: Detecting Expansion Relays
Another thing that can be done to further simplify things is to add in some define's for the relay boxes. This will make it easier to use the function. Instead of doing this:You could to this:
Then we would add to the Globals.h file, something like this:
Doing this would simply clean up the code and make it read a little easier for people at no cost of code size.
If Roberto doesn't add this to the Globals.h file, I will once I merge his branch.
Nice job on the coding and adding in a feature that will be handy.
Code: Select all
ReefAngel.Relay.IsRelayPresent(0);
Code: Select all
ReefAngel.Relay.IsRelayPresent(MAIN_RELAY); // useless like you said, but just an example
// or this
ReefAngel.Relay.IsRelayPresent(EXP1_RELAY);
Code: Select all
#define MAIN_RELAY 0xff
#define EXP1_RELAY 0
#define EXP2_RELAY 1
#define EXP3_RELAY 2
#define EXP4_RELAY 3
#define EXP5_RELAY 4
#define EXP6_RELAY 5
#define EXP7_RELAY 6
#define EXP8_RELAY 7
If Roberto doesn't add this to the Globals.h file, I will once I merge his branch.
Nice job on the coding and adding in a feature that will be handy.
Re: Detecting Expansion Relays
Good idea. That makes it a lot cleaner.
Don
Don
Re: Detecting Expansion Relays
I noticed this was added into the libraries but am not exactly sure how to use it. I have my main relay hooked into a ups, and the expansion is not. This was my best guess-binder wrote:Another thing that can be done to further simplify things is to add in some define's for the relay boxes. This will make it easier to use the function. Instead of doing this:You could to this:Code: Select all
ReefAngel.Relay.IsRelayPresent(0);
Then we would add to the Globals.h file, something like this:Code: Select all
ReefAngel.Relay.IsRelayPresent(MAIN_RELAY); // useless like you said, but just an example // or this ReefAngel.Relay.IsRelayPresent(EXP1_RELAY);
Doing this would simply clean up the code and make it read a little easier for people at no cost of code size.Code: Select all
#define MAIN_RELAY 0xff #define EXP1_RELAY 0 #define EXP2_RELAY 1 #define EXP3_RELAY 2 #define EXP4_RELAY 3 #define EXP5_RELAY 4 #define EXP6_RELAY 5 #define EXP7_RELAY 6 #define EXP8_RELAY 7
If Roberto doesn't add this to the Globals.h file, I will once I merge his branch.
Nice job on the coding and adding in a feature that will be handy.
Code: Select all
if !ReefAngel.Relay.IsRelayPresent(EXP1_RELAY 0); //! meaning opposite/off?
{
ReefAngel.Relay.Off (Port 1);
ReefAngel.Relay.Off (Heater);
ReefAngel.Relay.Off (Lights);
ReefAngel.Relay.Off (ATO);
}
Re: Detecting Expansion Relays
Yes, ! means not.
Code: Select all
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
ReefAngel.Relay.Off (Port1);
}
Roberto.
Re: Detecting Expansion Relays
Great thanks Roberto, here's to saving another ATO port!
Re: Detecting Expansion Relays
Is there a portal alert setting for if EXP1_RELAY is not present (as in lost power)? I looked through the list and didn't see anything obvious.
Re: Detecting Expansion Relays
You can use custom variables to accomplish that.
Then create a trigger if C0=0.
Code: Select all
ReefAngel.CustomVar[0]=ReefAngel.Relay.IsRelayPresent(EXP1_RELAY);
ReefAngel.CustomVar[7]=1;
Roberto.
Re: Detecting Expansion Relays
Sounds good, thanks roberto.
Re: Detecting Expansion Relays
Is there a way to set a small delay before it turns off ports?
Example: Wait for power outage 2 minutes before shutting off return and skimmer pumps.
Also, when I restore power to the non-ups relay port 2 on the main relay isn't coming back.
Example: Wait for power outage 2 minutes before shutting off return and skimmer pumps.
Also, when I restore power to the non-ups relay port 2 on the main relay isn't coming back.
Re: Detecting Expansion Relays
Code: Select all
#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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
///// Power Out Shutdown all but 2 flow pumps
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port4);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Re: Detecting Expansion Relays
The Relay.On(Port2) needs to be moved to inside loop to have them come back on.
Try this:
Try this:
Code: Select all
#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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
////// Place additional initialization code below here
ReefAngel.Timer[1].SetInterval(120);
////// Place additional initialization code above here
}
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
///// Power Out Shutdown all but 2 flow pumps
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) ReefAngel.Timer[1].Start();
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port4);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Roberto.
Detecting Expansion Relays
Wow, awesome thread. Don't know how I ever missed this one. I'm planning on finally hooking up my expansion relay this weekend and was planning on this very thing, but was going to do it with physical ports. Now I can just code the ports I need to shut off during a power outage!
Re: Detecting Expansion Relays
Yeah, its so useful. I haven't even hooked my RA up to my tank yet and I love it so much.
Can any of the other controllers do this?
Can any of the other controllers do this?
Re: Detecting Expansion Relays
Moving the ports always on into the loop worked when the exp relay power was restored. (The wizard put it outside of the loop)
Without using the time part I did a little testing. Ports 1-6 come back on when power is restored, but ports4+5 (return+skimmer) do not obey their ReefAngel.Relay.DelayedOn in the loop. Can they still follow the same delay when power is restored?
When using the timer function (for testing I put 10 seconds instead of 120), the IsRelayPresent doesn't seem to be working anymore.
Without using the time part I did a little testing. Ports 1-6 come back on when power is restored, but ports4+5 (return+skimmer) do not obey their ReefAngel.Relay.DelayedOn in the loop. Can they still follow the same delay when power is restored?
When using the timer function (for testing I put 10 seconds instead of 120), the IsRelayPresent doesn't seem to be working anymore.
Re: Detecting Expansion Relays
Do you keep your RA all through the entire power outage?
The DelayedOn ports only delay on reboot, water change or feeding mode exit.
So, to make them work on power restore, we need to assign LastStart=now(); when power is restored.
I also see what the problem is with the code posted above...
Try this:
The DelayedOn ports only delay on reboot, water change or feeding mode exit.
So, to make them work on power restore, we need to assign LastStart=now(); when power is restored.
I also see what the problem is with the code posted above...
Try this:
Code: Select all
#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
boolean PowerOutage=false;
////// 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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
////// Place additional initialization code below here
ReefAngel.Timer[1].SetInterval(120);
////// Place additional initialization code above here
}
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
///// Power Out Shutdown all but 2 flow pumps
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) PowerOutage=true;
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
ReefAngel.Timer[1].Start();
LastStart=now();
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port4);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Roberto.
Re: Detecting Expansion Relays
I'd like to keep the RA and main relay on for as long as the batteries will stay up. If that's what you are asking.rimai wrote:Do you keep your RA all through the entire power outage?
I tried the code and the timer function is still not working. 2nd relay is not triggering powerout scenario.
Shouldn't it be if (PowerOutage && !ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) ? with the exclamation point? I did try it and it didn't matter, still not shutting down ports like it should.
Re: Detecting Expansion Relays
The ! sign means NOT
http://arduino.cc/en/Reference/Boolean
Try this:
http://arduino.cc/en/Reference/Boolean
Try this:
Code: Select all
#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
boolean PowerOutage=false;
////// 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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
////// Place additional initialization code below here
ReefAngel.Timer[1].SetInterval(120);
////// Place additional initialization code above here
}
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
///// Power Out Shutdown all but 2 flow pumps
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
if (!PowerOutage)
{
PowerOutage=true;
ReefAngel.Timer[1].Start();
}
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) LastStart=now();
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port2);
ReefAngel.Relay.Off (Port4);
ReefAngel.Relay.Off (Port5);
ReefAngel.Relay.Off (Port6);
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Roberto.
Re: Detecting Expansion Relays
Nope...still nothing happening when pulling the cord to 2nd relay box. It doesn't like the timer addition, gotta be something with that part.
This works, but there is no timer.
This works, but there is no timer.
Code: Select all
// Power Outage - Shutdown all but 1 flow pump
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
//if (!PowerOutage)
//{
// PowerOutage=true;
// ReefAngel.Timer[1].Start();
//}
//if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) LastStart=now();
//if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
Re: Detecting Expansion Relays
After messing with this for awhile, I think I am ok not using the timer function. Without it there is a 3-4 sec delay before ports shutdown. And for quick outages that just make the lights blink I think 3-4 secs is enough.
The only thing I'd like to get working is LastStart=now(); Not sure where to place it.
The only thing I'd like to get working is LastStart=now(); Not sure where to place it.
Code: Select all
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) //Exp1 Relay NOT present
{
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
Re: Detecting Expansion Relays
Cool.
Try this then:
Try this then:
Code: Select all
#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
boolean PowerOutage=false;
////// 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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) //Exp1 Relay NOT present
{
PowerOutage=true;
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
PowerOutage=false;
LastStart=now();
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Roberto.
Re: Detecting Expansion Relays
Delayed ports still coming on with always on ports.
Re: Detecting Expansion Relays
I found out what the problem is...
The order of events is important in this case.
We need to assign a new value to LastStart before it is compared by DelayedOn(), or it will just the old value...
The order of events is important in this case.
We need to assign a new value to LastStart before it is compared by DelayedOn(), or it will just the old value...
Code: Select all
#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
boolean PowerOutage=false;
////// 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 = Port1Bit | Port3Bit | Port4Bit | Port5Bit;
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | 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( 830 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port3 );
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
PowerOutage=false;
LastStart=now();
}
ReefAngel.Relay.DelayedOn( Port4,3 );
ReefAngel.Relay.DelayedOn( Port5,6 );
// ReefAngel.StandardHeater( Port6,770,776 );
// on below 76.6 and off after 77.0
ReefAngel.StandardHeater( Port6,766,770 );
StandardHeater2( Box1_Port6,776,780 );
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 );
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 );
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 );
ReefAngel.StandardLights( Box1_Port4,19,0,22,0 );
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 );
// ReefAngel.StandardHeater( Box1_Port6,770,780 );
// ReefAngel.PWM.SetDaylight( MoonPhase() );
// ReefAngel.PWM.SetActinic( MoonPhase() );
// Moonlights schedule
if (hour()>=22 || hour()<=10) // Turn Moonlights on/off
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
////// Place your custom code below here
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) //Exp1 Relay NOT present
{
PowerOutage=true;
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
// heater 2 using temp sensor 2
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 62, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();
// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 93, TempRelay );
pingSerial();
// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 107, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 5 );
}
Roberto.
Re: Detecting Expansion Relays
Excellent! Delayed ports now being delayed when power is restored.
I don't know why, but now the delay after the exp1 relay loses power is just 2 seconds instead of the 3-4 sec I had the other day. I think it would be best to add a 10 second delay.
Can we revisit adding a timer delay before turning off the main relay ports?
Edit: It's close to working...After the timer expires the ports shutoff (including delayed ports) but click right back on.
Entire code
I don't know why, but now the delay after the exp1 relay loses power is just 2 seconds instead of the 3-4 sec I had the other day. I think it would be best to add a 10 second delay.
Can we revisit adding a timer delay before turning off the main relay ports?
Edit: It's close to working...After the timer expires the ports shutoff (including delayed ports) but click right back on.
Code: Select all
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) PowerOutage=true; //Exp1 Relay NOT present
if (!PowerOutage)
{
ReefAngel.Timer[1].Start();
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
Code: Select all
#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 ---------------------------------
boolean PowerOutage=false;
// Globals for Params on Custom Main
byte x,y;
char text[10];
// Custom Menu
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Turn Lights On";
prog_char menu1_label[] PROGMEM = "Turn Lights Off";
prog_char menu2_label[] PROGMEM = "Start Feeding";
prog_char menu3_label[] PROGMEM = "Start Water Change";
prog_char menu4_label[] PROGMEM = "Clear Overheat";
prog_char menu5_label[] PROGMEM = "Calibrate pH";
prog_char menu6_label[] PROGMEM = "Display Version";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label };
void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = ReefAngel.LightsOnPortsE[i];
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");ReefAngel.FeedingModeStart();
}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");ReefAngel.WaterChangeModeStart();
}
void MenuEntry5()
{
ReefAngel.DisplayMenuEntry("Item 5");ReefAngel.OverheatClear();
}
void MenuEntry6()
{
ReefAngel.DisplayMenuEntry("Item 6");ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayMenuEntry("Item 7");ReefAngel.DisplayVersion();
}
// End Custom Menu Globals
//--------------------------------- Place global variable code above here ---------------------------------
//--------------------------------- Begin Setup ---------------------------------
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Initialize the menu
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port4Bit | Port5Bit; //Flow1&3,Return,Skimmer
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit; //FrontT5,Heater
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit; //Front+BackT5,Heater
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit; //Center+Front+BackT5,RSMLED
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit; //heater
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | Port6Bit; //Front+BackT5,FugeLight,Heater
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 830 );
//--------------------------------- Place additional initialization code below here ---------------------------------
ReefAngel.Timer[1].SetInterval(5);
//--------------------------------- Place additional initialization code above here ---------------------------------
}
//--------------------------------- End Setup ---------------------------------
//--------------------------------- Begin Loop ---------------------------------
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 ); //Flow1
ReefAngel.Relay.On( Port2 ); //Flow2
ReefAngel.Relay.On( Port3 ); //Flow3
// Ports that are delayed on Power Cycle & Feeding & Water Change
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
PowerOutage=false;
LastStart=now();
}
ReefAngel.Relay.DelayedOn( Port4,1 ); //Return -set to 1 min for testing CHANGE TO 2MINS
ReefAngel.Relay.DelayedOn( Port5,1 ); //Skimmer -set to 1 min for testing CHANGE TO 4MINS
// Heaters
ReefAngel.StandardHeater( Port6,776,780 ); //DispHeater
StandardHeater2( Box1_Port6,776,780 ); //SumpHeater
// T5 Light Schedule
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 ); //CenterT5 10a-8p
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 ); //FrontT5 11a-6p
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 ); //BackT5 12p-17p
// RSMLED Moonlight Schedule
if (hour()<11) ReefAngel.StandardLights( Box1_Port4,8,0,11,0 ); //RSMLED Morning 8a-11a
else ReefAngel.StandardLights( Box1_Port4,19,0,22,0 ); //RSMLED Evening 7p-10p
// Fuge Light Schedule
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 ); //FugeLight 12a-8a
// PWM Dimmable Moonlights Schedule
if (hour()>=22 || hour()<8) // Turn Dimmable Moonlights on 10PM/ off 8AM
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
//--------------------------------- Place your custom code below here ---------------------------------
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) PowerOutage=true; //Exp1 Relay NOT present
if (!PowerOutage)
{
ReefAngel.Timer[1].Start();
}
if (ReefAngel.Timer[1].IsTriggered())
{
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
// Skimmer off when Return pump is off.
if (bitRead(ReefAngel.Relay.RelayMaskOff,3)==0)//Return
{
bitClear(ReefAngel.Relay.RelayMaskOff,4); //Skimmer
}
//////////// Place your custom code above here ////////////
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
//--------------------------------- End Loop ---------------------------------
// Sump Heater Use Sump Temp Probe
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
//--------------------------------- Begin Custom Main ---------------------------------
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
// Display T1 Probe Value
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawHugeNumbers(COLOR_CRIMSON, 255, 5, 14, text);
pingSerial();
// Display pH Text
ReefAngel.LCD.DrawText(COLOR_INDIGO,255,80,14,"pH");
// Display pH Value
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 95, 14, text, Num8x16);
pingSerial();
// Display T3 Probe Text
ReefAngel.LCD.DrawText(COLOR_ROYALBLUE,255,80,24,"Rm");
// Display T3 Probe Value
ConvertNumToString(text, ReefAngel.Params.Temp[T3_PROBE], 10);
ReefAngel.LCD.DrawLargeText(COLOR_ROYALBLUE, 255, 95, 24, text, Num8x16);
pingSerial();
//Moon Phase
//ReefAngel.LCD.DrawText(COLOR_NAVY,255,4,78, "MoonPhase:");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,4,88,MoonPhaseLabel());
//Dimmable Moon LEDs
ReefAngel.LCD.DrawText(COLOR_NAVY,255,4,98, "MoonLEDs:");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,60,98, ReefAngel.PWM.GetActinicValue());
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,75,98, "%");
// Display Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 13, 107, TempRelay );
pingSerial();
// Display Expansion Relay Box 1
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 13, 119, TempRelay );
pingSerial();
}
//--------------------------------- End Custom Main ---------------------------------
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 35 );
}
Re: Detecting Expansion Relays
Try this:
Code: Select all
#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 ---------------------------------
boolean PowerOutage=false;
boolean DelayedPowerOutage=false;
// Globals for Params on Custom Main
byte x,y;
char text[10];
// Custom Menu
#include <avr/pgmspace.h>
prog_char menu0_label[] PROGMEM = "Turn Lights On";
prog_char menu1_label[] PROGMEM = "Turn Lights Off";
prog_char menu2_label[] PROGMEM = "Start Feeding";
prog_char menu3_label[] PROGMEM = "Start Water Change";
prog_char menu4_label[] PROGMEM = "Clear Overheat";
prog_char menu5_label[] PROGMEM = "Calibrate pH";
prog_char menu6_label[] PROGMEM = "Display Version";
PROGMEM const char *menu_items[] = {
menu0_label, menu1_label, menu2_label, menu3_label, menu4_label, menu5_label, menu6_label };
void MenuEntry1()
{
ReefAngel.DisplayMenuEntry("Item 1");ReefAngel.Relay.RelayMaskOn = ReefAngel.LightsOnPorts;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = ReefAngel.LightsOnPortsE[i];
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry2()
{
ReefAngel.DisplayMenuEntry("Item 2");ReefAngel.Relay.RelayMaskOn = 0;
#ifdef RelayExp
for ( byte i = 0; i < MAX_RELAY_EXPANSION_MODULES; i++ )
{
ReefAngel.Relay.RelayMaskOnE[i] = 0;
}
#endif // RelayExp
ReefAngel.Relay.Write();
}
void MenuEntry3()
{
ReefAngel.DisplayMenuEntry("Item 3");ReefAngel.FeedingModeStart();
}
void MenuEntry4()
{
ReefAngel.DisplayMenuEntry("Item 4");ReefAngel.WaterChangeModeStart();
}
void MenuEntry5()
{
ReefAngel.DisplayMenuEntry("Item 5");ReefAngel.OverheatClear();
}
void MenuEntry6()
{
ReefAngel.DisplayMenuEntry("Item 6");ReefAngel.SetupCalibratePH();
ReefAngel.DisplayedMenu = ALT_SCREEN_MODE;
}
void MenuEntry7()
{
ReefAngel.DisplayMenuEntry("Item 7");ReefAngel.DisplayVersion();
}
// End Custom Menu Globals
//--------------------------------- Place global variable code above here ---------------------------------
//--------------------------------- Begin Setup ---------------------------------
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Initialize the menu
ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items));
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port3Bit | Port4Bit | Port5Bit; //Flow1&3,Return,Skimmer
ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit; //FrontT5,Heater
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit; //Front+BackT5,Heater
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit; //Center+Front+BackT5,RSMLED
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port6Bit; //heater
ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | Port6Bit; //Front+BackT5,FugeLight,Heater
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 830 );
//--------------------------------- Place additional initialization code below here ---------------------------------
ReefAngel.Timer[1].SetInterval(5);
//--------------------------------- Place additional initialization code above here ---------------------------------
}
//--------------------------------- End Setup ---------------------------------
//--------------------------------- Begin Loop ---------------------------------
void loop()
{
// Ports that are always on
ReefAngel.Relay.On( Port1 ); //Flow1
ReefAngel.Relay.On( Port2 ); //Flow2
ReefAngel.Relay.On( Port3 ); //Flow3
// Ports that are delayed on Power Cycle & Feeding & Water Change
if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
{
PowerOutage=false;
DelayedPowerOutage=false;
LastStart=now();
}
ReefAngel.Relay.DelayedOn( Port4,1 ); //Return -set to 1 min for testing CHANGE TO 2MINS
ReefAngel.Relay.DelayedOn( Port5,1 ); //Skimmer -set to 1 min for testing CHANGE TO 4MINS
// Heaters
ReefAngel.StandardHeater( Port6,776,780 ); //DispHeater
StandardHeater2( Box1_Port6,776,780 ); //SumpHeater
// T5 Light Schedule
ReefAngel.StandardLights( Box1_Port1,10,0,20,0 ); //CenterT5 10a-8p
ReefAngel.StandardLights( Box1_Port2,11,0,18,0 ); //FrontT5 11a-6p
ReefAngel.StandardLights( Box1_Port3,12,0,19,0 ); //BackT5 12p-17p
// RSMLED Moonlight Schedule
if (hour()<11) ReefAngel.StandardLights( Box1_Port4,8,0,11,0 ); //RSMLED Morning 8a-11a
else ReefAngel.StandardLights( Box1_Port4,19,0,22,0 ); //RSMLED Evening 7p-10p
// Fuge Light Schedule
ReefAngel.StandardLights( Box1_Port5,0,0,8,0 ); //FugeLight 12a-8a
// PWM Dimmable Moonlights Schedule
if (hour()>=22 || hour()<8) // Turn Dimmable Moonlights on 10PM/ off 8AM
{
ReefAngel.PWM.SetActinic(MoonPhase());
ReefAngel.PWM.SetDaylight(MoonPhase());
}
else
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
//--------------------------------- Place your custom code below here ---------------------------------
// Power Outage - Only Flow2 port on
if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY)) PowerOutage=true; //Exp1 Relay NOT present
if (!PowerOutage)
{
ReefAngel.Timer[1].Start();
}
if (ReefAngel.Timer[1].IsTriggered())
{
DelayedPowerOutage=true;
}
if (DelayedPowerOutage)
{
ReefAngel.Relay.Off (Port1); //Flow1
ReefAngel.Relay.Off (Port3); //Flow3
ReefAngel.Relay.Off (Port4); //Return
ReefAngel.Relay.Off (Port5); //Skimmer
ReefAngel.Relay.Off (Port6); //Heater
}
// Skimmer off when Return pump is off.
if (bitRead(ReefAngel.Relay.RelayMaskOff,3)==0)//Return
{
bitClear(ReefAngel.Relay.RelayMaskOff,4); //Skimmer
}
//////////// Place your custom code above here ////////////
// This should always be the last line
ReefAngel.Portal( "modulok" );
ReefAngel.ShowInterface();
}
//--------------------------------- End Loop ---------------------------------
// Sump Heater Use Sump Temp Probe
void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
}
//--------------------------------- Begin Custom Main ---------------------------------
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 2);
ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
pingSerial();
// Display T1 Probe Value
ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
ReefAngel.LCD.DrawHugeNumbers(COLOR_CRIMSON, 255, 5, 14, text);
pingSerial();
// Display pH Text
ReefAngel.LCD.DrawText(COLOR_INDIGO,255,80,14,"pH");
// Display pH Value
ConvertNumToString(text, ReefAngel.Params.PH, 100);
ReefAngel.LCD.DrawLargeText(COLOR_INDIGO, 255, 95, 14, text, Num8x16);
pingSerial();
// Display T3 Probe Text
ReefAngel.LCD.DrawText(COLOR_ROYALBLUE,255,80,24,"Rm");
// Display T3 Probe Value
ConvertNumToString(text, ReefAngel.Params.Temp[T3_PROBE], 10);
ReefAngel.LCD.DrawLargeText(COLOR_ROYALBLUE, 255, 95, 24, text, Num8x16);
pingSerial();
//Moon Phase
//ReefAngel.LCD.DrawText(COLOR_NAVY,255,4,78, "MoonPhase:");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,4,88,MoonPhaseLabel());
//Dimmable Moon LEDs
ReefAngel.LCD.DrawText(COLOR_NAVY,255,4,98, "MoonLEDs:");
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,60,98, ReefAngel.PWM.GetActinicValue());
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,75,98, "%");
// Display Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 13, 107, TempRelay );
pingSerial();
// Display Expansion Relay Box 1
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 13, 119, TempRelay );
pingSerial();
}
//--------------------------------- End Custom Main ---------------------------------
void DrawCustomGraph()
{
ReefAngel.LCD.DrawGraph( 5, 35 );
}
Roberto.
Re: Detecting Expansion Relays
ok, the delay seems to be triggering now...but when the exp1 relay's power is restored the ports that were shut off do not come back on.