Simple if/then statements not working
Posted: Mon Apr 13, 2020 7:19 pm
I just added my Ca Reactor and was adding code to shut it down if tank pH (not Expansion pH) gets below 7.75. Even though my pH is well above that, the ports turn-off immediately once code is loaded and even after a second reboot. I verified it was these statements by remming them out. What am I missing?
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port1 ); ///Turns off Carbon Doser if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port6 ); //Turns off Ca Reactor Ca Pump if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box2_Port8 ); //Turns off Ca Reactor Fill Pump if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port1 ); ///Turns off Carbon Doser if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port6 ); //Turns off Ca Reactor Ca Pump if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box2_Port8 ); //Turns off Ca Reactor Fill Pump if tank pH <= 7.75.
Code: Select all
#include <ReefAngel_Features.h>
#include <Salinity.h>
#include <Globals.h>
#include <RA_TS.h>
#include <RA_TouchLCD.h>
#include <RA_TFT.h>
#include <RA_TS.h>
#include <Font.h>
#include <RA_Wifi.h>
#include <RA_Wiznet5100.h>
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetDHCP.h>
#include <PubSubClient.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_ATO.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 <RA_CustomLabels.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <PAR.h>
#include <DCPump.h>
#include <ReefAngel.h>
#include <SoftwareSerial.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.Star();
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
ReefAngel.AddMultiChannelWaterLevelExpansion(); // Multi-Channel Water Level Expanion Module
ReefAngel.AddPHExpansion(); // pH Expansion Module
ReefAngel.AddRANet(); // RANet Add-On Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = Port7Bit | Port8Bit; //UV and UV Pump-off.
ReefAngel.FeedingModePortsE[1] = Port7Bit; //Skimmer-off.
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[1] = Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[2] = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port6Bit | Port7Bit | Port8Bit;
ReefAngel.OverheatShutoffPortsE[1] = Port1Bit | Port3Bit | Port5Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[1] = Port1Bit; // Powermodule Fixture On.
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T2_PROBE;
ReefAngel.OverheatProbe = T2_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_read(); // trying this code to see if it pulls internal memory overheat temp.
// Ports that are always on
ReefAngel.Relay.On( Box1_Port1 ); // Carbon Doser (CaR CO2 Doser) always on.
ReefAngel.Relay.On( Box1_Port3 ); // Gyres always on.
ReefAngel.Relay.On( Box1_Port6 ); // Calcium Reactor Recirculation Pump (CaR Recirc Pump) always on.
ReefAngel.Relay.On( Box1_Port8 ); // UV Pump always on.
ReefAngel.Relay.On( Box2_Port1 ); // Powermodule Lights/Fans always on.
ReefAngel.Relay.On( Box2_Port4 ); // Return Pump always on.
ReefAngel.Relay.On( Box2_Port8 ); // Calcium Reactor Fill Pump (CaR Fill Pump) always on.
////// Place additional initialization code below here
InternalMemory.FeedingTimer_write(7200); // sets feeding mode to 2 hours (only used for coral feeding)... shuts down UV bulb, UV pump, and skimmer.
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.StandardLights( Box2_Port3 ); //Using Internal Memory Standard Lights to run Refugium Light.
ReefAngel.StandardHeater2( Box1_Port2 );
ReefAngel.StandardHeater2( Box2_Port5 );
ReefAngel.StandardFan2( Box2_Port6 ); //Sump Fans
ReefAngel.Relay.DelayedOn( Box2_Port7 ); //Skimmer
ReefAngel.WaterLevelATO( 1,Box3_Port1); //ATO pump-DC relay box-new program.
//ReefAngel.PWM.DaylightPWMSlope(); - not using PWM for main LEDs
//ReefAngel.PWM.ActinicPWMSlope(); - not using PWM for main LEDs
ReefAngel.StandardHeater( Box1_Port7,788,796 ); //Manages UV bulb on/off based on tank temp.
ReefAngel.DosingPumpRepeat1( Box3_Port2 ); // Pump dosing kalk-DC Relay Box.
ReefAngel.DosingPumpRepeat( Box1_Port4,0,60,2700 ); // Stirrer on/off.
boolean buzzer=false;
// if ( ReefAngel.isATOTimeOut() ) buzzer=true;
if ( ReefAngel.isOverheat() ) buzzer=true;
if ( buzzer ) ReefAngel.BuzzerOn(2); else ReefAngel.BuzzerOff();
if ( ReefAngel.Params.PH > 844 ) ReefAngel.Relay.Off( Box3_Port2 ); //Turns off Kalk Stirrer dosing if tank pH > 8.44.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port1 ); ///Turns off Carbon Doser if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box1_Port6 ); //Turns off Ca Reactor Ca Pump if tank pH <= 7.75.
if ( ReefAngel.Params.PH <= 775 ) ReefAngel.Relay.Off( Box2_Port8 ); //Turns off Ca Reactor Fill Pump if tank pH <= 7.75.
////// Place your custom code below here
////// Place your custom code above here
ReefAngel.Network.Cloud();
// This should always be the last line
ReefAngel.ShowTouchInterface();
}
// RA_STRING1=U2FsdGVkX1+BrIhUnNJiKHbFL6wohK41+33EQ2nHfFo=
// RA_STRING2=U2FsdGVkX1+EmuJjuPrMWBEHac9zWSjiW8ZytHk/q+M=
// RA_STRING3=Chloe's House-2.4
// RA_LABEL LABEL_ACTINIC=Actinic
// RA_LABEL LABEL_DAYLIGHT=Daylight
// RA_LABEL LABEL_PORT11=Main LEDs
// RA_LABEL LABEL_PORT12=Heater 2
// RA_LABEL LABEL_PORT13=Gyre Pumps
// RA_LABEL LABEL_PORT14=Kalk Stirrer
// RA_LABEL LABEL_PORT15=Salt Mix Tank
// RA_LABEL LABEL_PORT16=Co2 Control
// RA_LABEL LABEL_PORT17=Unused
// RA_LABEL LABEL_PORT18=Unused
// RA_LABEL LABEL_PORT21=Main T5s
// RA_LABEL LABEL_PORT22=Light Fans
// RA_LABEL LABEL_PORT23=Refugium LED
// RA_LABEL LABEL_PORT24=Return Pump
// RA_LABEL LABEL_PORT25=Heater 1
// RA_LABEL LABEL_PORT26=Sump Fans
// RA_LABEL LABEL_PORT27=Skimmer
// RA_LABEL LABEL_PORT28=ATO Pump