ATO Based on Salinity
ATO Based on Salinity
Hello, I'd like to set up my ATO top off to select ATO pumps based on current Salinity readings. My RO ATO is Box1_Port5 and the Saltwater ATO is on Box1_Port6. How do I code the ATO process to select the RO port be default, and the SW port when salinity is below 33PPT? Also, I'm using the multi channel water level expansion and would like to top off based on the reading of expansion 1, start at 86% and stop at 90%. Can I use the internetal memory settings for the high and low values? All my values are currently stored in internal memory. Thanks in advance!
ATO Based on Salinity
Yes you can use the internal memory just use a variable for the port and an if statement to set that variable depending on the salinity
Re: ATO Based on Salinity
I can't seem to get this one right, please see my code below. I'm getting an error on the WaterLevelATO function. How is that properly referenced?
if (ReefAngel.Params.Salinity>35)
{
ReefAngel.WaterLevelATO ( Box1_Port5 );
}
else
{
ReefAngel.WaterLevelATO ( Box1_Port6 );
}
if (ReefAngel.Params.Salinity>35)
{
ReefAngel.WaterLevelATO ( Box1_Port5 );
}
else
{
ReefAngel.WaterLevelATO ( Box1_Port6 );
}
Re: ATO Based on Salinity
It's something else in your code. The above code is fine.
Re: ATO Based on Salinity
thanks. I think I figured it out, my change below checked out ok. Look good?
if (ReefAngel.Params.Salinity>35)
{
ReefAngel.WaterLevelATO (1, Box1_Port5 );
}
else
{
ReefAngel.WaterLevelATO ( 1, Box1_Port6 );
}
if (ReefAngel.Params.Salinity>35)
{
ReefAngel.WaterLevelATO (1, Box1_Port5 );
}
else
{
ReefAngel.WaterLevelATO ( 1, Box1_Port6 );
}
Re: ATO Based on Salinity
I'm still having trouble with this one. See code below. regardless of salinity value, port 8 is always used for the top off.
#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 <Humidity.h>
#include <DCPump.h>
#include <PAR.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit | Port6Bit | Port7Bit;
ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit | Port5Bit | Port6Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port4Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.MoonLights( Port3 );
ReefAngel.StandardHeater( Port4 );
ReefAngel.Relay.DelayedOn( Port6 );
if (ReefAngel.Params.Salinity > 350 )
{
ReefAngel.WaterLevelATO(1, Port7 );
}
else
{
ReefAngel.WaterLevelATO(1, Port8 );
}
ReefAngel.DosingPumpRepeat1( Box1_Port1 );
ReefAngel.DosingPumpRepeat2( Box1_Port2 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ritz" );
ReefAngel.DDNS( "MyTank" ); // Your DDNS is ritz-MyTank.myreefangel.com
ReefAngel.ShowInterface();
}
#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 <Humidity.h>
#include <DCPump.h>
#include <PAR.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
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port5Bit | Port6Bit | Port7Bit;
ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit | Port5Bit | Port6Bit | Port7Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port2Bit | Port4Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port1 );
ReefAngel.DayLights( Port2 );
ReefAngel.MoonLights( Port3 );
ReefAngel.StandardHeater( Port4 );
ReefAngel.Relay.DelayedOn( Port6 );
if (ReefAngel.Params.Salinity > 350 )
{
ReefAngel.WaterLevelATO(1, Port7 );
}
else
{
ReefAngel.WaterLevelATO(1, Port8 );
}
ReefAngel.DosingPumpRepeat1( Box1_Port1 );
ReefAngel.DosingPumpRepeat2( Box1_Port2 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ritz" );
ReefAngel.DDNS( "MyTank" ); // Your DDNS is ritz-MyTank.myreefangel.com
ReefAngel.ShowInterface();
}
Re: ATO Based on Salinity
Anybody??
Re: ATO Based on Salinity
Add a Serial.println(ReefAngel.Params.Salinity); before your if statement and see if the salinity value is what you expect. You'll have to use Serial Monitor in the GUI to see the result. Don't leave that enabled btw, just for testing
Re: ATO Based on Salinity
I tested my output via serial and confirmed output as expected. Any idea why it always defaults to port 8 regardless of salinity value?
Re: ATO Based on Salinity
Try adding this before your if statement:
Code: Select all
ReefAngel.Relay.Off( Box1_Port5 );
ReefAngel.Relay.Off( Box1_Port6 );
Roberto.
Re: ATO Based on Salinity
Thanks will give that a try.....
Re: ATO Based on Salinity
He's got two different codes. In one he says he fixed it and in the second he says its broken but the second reverts his changes.....
Re: ATO Based on Salinity
apologies, I've made some other changes along the way, here is a fresh copy of my code. I knew what Roberto meant, so I adjusted the ports accordingly. The ATO process doesn't run at all when I set those two ports to off, but the process does flag a timeout.
I'm actually having a number of issues with my code now. First, the heater is on at all times regardless of temperature. I tried updating the memory values for the heater settings and that doesn't seem to have helped - memory values are set to on at 77.0 and off at 77.4. Second, my power control module does not respond. I set the jumpers to make it box 2 or 3 and neither one worked. I can see the module in the app, but turning ports on or off has no actual effect. Lastly, I'm also having an issue where my second water level channel is always lower than channel 1. My sump is set up so that channel 1 is always equal to or less than the level of channel number 2. But as the level in channel 1 actually drops, the reported value for channel 2 drops, even if that water level has not actually dropped. help!!
I'm actually having a number of issues with my code now. First, the heater is on at all times regardless of temperature. I tried updating the memory values for the heater settings and that doesn't seem to have helped - memory values are set to on at 77.0 and off at 77.4. Second, my power control module does not respond. I set the jumpers to make it box 2 or 3 and neither one worked. I can see the module in the app, but turning ports on or off has no actual effect. Lastly, I'm also having an issue where my second water level channel is always lower than channel 1. My sump is set up so that channel 1 is always equal to or less than the level of channel number 2. But as the level in channel 1 actually drops, the reported value for channel 2 drops, even if that water level has not actually dropped. help!!
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 <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
////// Place global variable code below here
// Define Relay Ports by Name, ports 1-8 on battery backup
#define Sump_Pump Port1
#define Food_Pump Port2
#define Heater Port3
#define RW15 Port4
#define NA1 Port5
#define NA2 Port6
#define NA3 Port7
#define NA4 Port8
#define Actinic Box1_Port1
#define Moon Box1_Port2
#define MHL Box1_Port3
#define MHR Box1_Port4
#define Swabbie Box1_Port5
#define Skimmer Box1_Port6
#define ATO_RO Box1_Port7
#define ATO_SW Box1_Port8
#define Calc Box2_Port1
#define Alk Box2_Port2
#define Food1 Box2_Port3
#define Food2 Box2_Port4
#define Food3 Box2_Port5
#define Dose1 Box2_Port6
#define Dose2 Box2_Port7
#define Dose3 Box2_Port8
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit;
ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.FeedingModePortsE[1] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[1] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit | Port4Bit;
ReefAngel.LightsOnPortsE[1] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[1] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=( NutrientTransport,25,10 );
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port4 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Port3 );
ReefAngel.ActinicLights( Box1_Port1 );
ReefAngel.MoonLights( Box1_Port2 );
ReefAngel.DayLights( Box1_Port3 );
ReefAngel.DelayedStartLights( Box1_Port4 );
ReefAngel.Relay.DelayedOn( Box1_Port6 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
if (ReefAngel.Params.Salinity > 350 )
{
ReefAngel.WaterLevelATO(1, Box1_Port7 );
}
else
{
ReefAngel.WaterLevelATO(1, Box1_Port8 );
}
if (ReefAngel.LowATO.IsActive()) // low water cut off
{
ReefAngel.Relay.On( Port1 | Port2 );
// alert=false;
}
else
{
ReefAngel.Relay.Off( Port1 | Port2 );
// alert=true;
}
// if (ReefAngel.HighATO.IsActive()) // High water skimmer shut off
// {
// ReefAngel.Relay.On(Box1_Port6);
// // alert=false;
// }
// else
// {
// ReefAngel.Relay.Off(Box1_Port6);
// // alert=true;
// }
if (hour()>=21 || hour()<=9) // if hour is >=9pm or hour is <9am
{
ReefAngel.DCPump.SetMode( ReefCrest,20,10 ); // Set dc pump mode to ReefCrest at 20% power for night time
}
else
{
ReefAngel.DCPump.SetMode( ShortPulse,60,69 ); // set dc pump to shortpulae 60% for daytime
}
// if (hour()=5 || hour()=11 || hour()=17 || hour()=23 )
// {
// ReefAngel.Relay.On( Box1_Port5 );
// }
// else
// {
// ReefAngel.Relay.Off( Box1_Port5 );
// }
// switch(hour()){
// case 5:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 11:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 17:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 23:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// default:
// ReefAngel.Relay.Off( Box1_Port5);
// }
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ritz" );
ReefAngel.DDNS( "MyTank" ); // Your DDNS is ritz-MyTank.myreefangel.com
ReefAngel.ShowInterface();
}
Re: ATO Based on Salinity
Let's try this way then:
Run the i2cscanner to see if the id is setup correctly for the power module.
It should be 0x38 for Box1, 0x39 for Box2
Code: Select all
if (ReefAngel.Params.Salinity > 350 )
{
ReefAngel.WaterLevelATO(1, Box1_Port7 );
ReefAngel.Relay.Off(Box1_Port8 );
}
else
{
ReefAngel.WaterLevelATO(1, Box1_Port8 );
ReefAngel.Relay.Off(Box1_Port7 );
}
It should be 0x38 for Box1, 0x39 for Box2
Roberto.
Re: ATO Based on Salinity
Very odd - my RO ATO, Box1_Port6, came on at 4:15 AM this morning and ran endlessly and emptied the entire RO container into my tank. The port is set to auto but it's still turned on, and the sump is 20% above the top off limit. The heater issue is also causing me a major headache. Any idea on these two items?
Re: ATO Based on Salinity
Can you guys confirm my dip switch set up? I want the two AC 8 port relays to be ports 1-16 and the dc relay ports 17-24? Should the expansion relay be set to ID 1 or 2? DC relay ID 2 or 3?
Re: ATO Based on Salinity
My low water cut off doesn't work either..... am I missing something major here? Nothing seems to be working right! lol..... help plz!!
Re: ATO Based on Salinity
Main relay box doesn't have an ID.
The first relay expansion box should be ID1 and the power module ID2.
The sure way to find out if you have set them correctly is to use the i2c scanner.
Like I posted above, box1 should be 0x38 and box2 should be 0x39.
The first relay expansion box should be ID1 and the power module ID2.
The sure way to find out if you have set them correctly is to use the i2c scanner.
Like I posted above, box1 should be 0x38 and box2 should be 0x39.
Roberto.
Re: ATO Based on Salinity
This is wrong:
Mathematically, Port1 | Port2 = Port3.
That's why your heater is not working and the lower cut off too. Both are being messed up by the code above.
I would suggest start your code with the basic and add custom code one at a time and verifying if that is working correctly. That way you now for sure what you added is indeed working.
Code: Select all
if (ReefAngel.LowATO.IsActive()) // low water cut off
{
ReefAngel.Relay.On( Port1 | Port2 );
// alert=false;
}
else
{
ReefAngel.Relay.Off( Port1 | Port2 );
// alert=true;
}
That's why your heater is not working and the lower cut off too. Both are being messed up by the code above.
I would suggest start your code with the basic and add custom code one at a time and verifying if that is working correctly. That way you now for sure what you added is indeed working.
Roberto.
Re: ATO Based on Salinity
OK, looks like ATO by salinity is working now. I also changed the low water cutoff statement to use the defined port names instead of the actual ports, which seems to have resolved the heater issue. However, the low water cutoff does not work. I'm also still having the issue where channel 2 always read < channel 1 regardless of actual water level. updated code below.
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 <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
////// Place global variable code below here
// Ports 1-8 on battery backup
#define Sump_Pump Port1
#define Food_Pump Port2
#define Heater Port3
#define RW15 Port4
#define NA1 Port5
#define NA2 Port6
#define NA3 Port7
#define NA4 Port8
#define Actinic Box1_Port1
#define Moon Box1_Port2
#define MHL Box1_Port3
#define MHR Box1_Port4
#define Swabbie Box1_Port5
#define Skimmer Box1_Port6
#define ATO_RO Box1_Port7
#define ATO_SW Box1_Port8
#define Calc Box2_Port1
#define Alk Box2_Port2
#define Food1 Box2_Port3
#define Food2 Box2_Port4
#define Food3 Box2_Port5
#define Dose1 Box2_Port6
#define Dose2 Box2_Port7
#define Dose3 Box2_Port8
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit;
ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.FeedingModePortsE[1] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[1] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit | Port4Bit;
ReefAngel.LightsOnPortsE[1] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[1] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=( NutrientTransport,25,10 );
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port4 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Heater );
ReefAngel.ActinicLights( Box1_Port1 );
ReefAngel.MoonLights( Box1_Port2 );
ReefAngel.DayLights( Box1_Port3 );
ReefAngel.DelayedStartLights( Box1_Port4 );
ReefAngel.Relay.DelayedOn( Box1_Port6 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
if (ReefAngel.Params.Salinity > 351 )
{
ReefAngel.WaterLevelATO(1, Box1_Port7 );
ReefAngel.Relay.Off(Box1_Port8 );
}
else
{
ReefAngel.WaterLevelATO(1, Box1_Port8 );
ReefAngel.Relay.Off(Box1_Port7 );
}
if (ReefAngel.LowATO.IsActive()) // low water cut off
{
ReefAngel.Relay.On( Sump_Pump | Food_Pump | Skimmer );
// alert=false;
}
else
{
ReefAngel.Relay.Off( Sump_Pump | Food_Pump | Skimmer );
// alert=true;
}
//if (ReefAngel.HighATO.IsActive()) // High water skimmer shut off
// {
// ReefAngel.Relay.On(Box1_Port6);
// // alert=false;
// }
// else
// {
// ReefAngel.Relay.Off(Box1_Port6);
// // alert=true;
// }
// if (hour()>=21 || hour()<=9) // if hour is >=9pm or hour is <9am
// {
// ReefAngel.DCPump.SetMode( ReefCrest,20,10 ); // Set dc pump mode to ReefCrest at 20% power for night time
// }
// else
// {
// ReefAngel.DCPump.SetMode( ShortPulse,60,69 ); // set dc pump to shortpulae 60% for daytime
// }
//
// switch(hour()){
// case 5:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 11:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 17:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 23:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// default:
// ReefAngel.Relay.Off( Box1_Port5);
// }
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ritz" );
ReefAngel.DDNS( "MyTank" ); // Your DDNS is ritz-MyTank.myreefangel.com
ReefAngel.ShowInterface();
}
Re: ATO Based on Salinity
Your low cutoff is not working because you can't turn off multiple ports like that as Roberto told you earlier. You need to turn each port on or off explicitly. There is a way to do it but thats not it and it's more complicated than you need.
The difference between what your doing and what you have seen in other code like WaterChangePorts is that those use Port1Bit instead of Port1. But those are calculated along with ReefAngelRelayData which you should only touch through the functions.
The difference between what your doing and what you have seen in other code like WaterChangePorts is that those use Port1Bit instead of Port1. But those are calculated along with ReefAngelRelayData which you should only touch through the functions.
Re: ATO Based on Salinity
Ah, think I understand now. I made some updates, see below. Will let you know how it goes.
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 <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
////// Place global variable code below here
// Ports 1-8 on battery backup
#define Sump_Pump Port1
#define Food_Pump Port2
#define Heater Port3
#define RW15 Port4
#define RW8 Port5
#define NA2 Port6
#define NA3 Port7
#define NA4 Port8
#define Actinic Box1_Port1
#define Moon Box1_Port2
#define MHL Box1_Port3
#define MHR Box1_Port4
#define Swabbie Box1_Port5
#define Skimmer Box1_Port6
#define ATO_RO Box1_Port7
#define ATO_SW Box1_Port8
#define Calc Box2_Port1
#define Alk Box2_Port2
#define Food1 Box2_Port3
#define Food2 Box2_Port4
#define Food3 Box2_Port5
#define Dose1 Box2_Port6
#define Dose2 Box2_Port7
#define Dose3 Box2_Port8
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddSalinityExpansion(); // Salinity Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit;
ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.FeedingModePortsE[1] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[1] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = Port1Bit | Port3Bit | Port4Bit;
ReefAngel.LightsOnPortsE[1] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = Port3Bit | Port4Bit | Port5Bit | Port6Bit;
ReefAngel.OverheatShutoffPortsE[1] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=( NutrientTransport,40,10 );
ReefAngel.DCPump.WaterChangeSpeed=0;
// Ports that are always on
ReefAngel.Relay.On( Port1 );
ReefAngel.Relay.On( Port2 );
ReefAngel.Relay.On( Port4 );
ReefAngel.Relay.On( Port5 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardHeater( Heater );
ReefAngel.ActinicLights( Box1_Port1 );
ReefAngel.MoonLights( Box1_Port2 );
ReefAngel.DayLights( Box1_Port3 );
ReefAngel.DelayedStartLights( Box1_Port4 );
ReefAngel.Relay.DelayedOn( Box1_Port6 );
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = Sync;
////// Place your custom code below here
if (ReefAngel.Params.Salinity > 351 )
{
ReefAngel.WaterLevelATO(1, Box1_Port7 );
ReefAngel.Relay.Off(Box1_Port8 );
}
else
{
ReefAngel.WaterLevelATO(1, Box1_Port8 );
ReefAngel.Relay.Off(Box1_Port7 );
}
if (ReefAngel.LowATO.IsActive()) // low water cut off
{
ReefAngel.Relay.On( Sump_Pump );
ReefAngel.Relay.On( Food_Pump );
ReefAngel.Relay.On( Skimmer );
// alert=false;
}
else
{
ReefAngel.Relay.Off( Sump_Pump );
ReefAngel.Relay.Off( Food_Pump );
ReefAngel.Relay.Off( Skimmer );
// alert=true;
}
//if (ReefAngel.HighATO.IsActive()) // High water skimmer shut off
// {
// ReefAngel.Relay.On(Box1_Port6);
// // alert=false;
// }
// else
// {
// ReefAngel.Relay.Off(Box1_Port6);
// // alert=true;
// }
// if (hour()>=21 || hour()<=9) // if hour is >=9pm or hour is <9am
// {
// ReefAngel.DCPump.SetMode( ReefCrest,20,10 ); // Set dc pump mode to ReefCrest at 20% power for night time
// }
// else
// {
// ReefAngel.DCPump.SetMode( ShortPulse,60,69 ); // set dc pump to shortpulae 60% for daytime
// }
//
// switch(hour()){
// case 5:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 11:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 17:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// case 23:
// ReefAngel.Relay.On( Box1_Port5, 30 );
// default:
// ReefAngel.Relay.Off( Box1_Port5);
// }
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "ritz" );
ReefAngel.DDNS( "MyTank" ); // Your DDNS is ritz-MyTank.myreefangel.com
ReefAngel.ShowInterface();
}