Unfortunately, I can't get even the relay to turn on or off as expected. Posted below is my (much simplified, in view of other trouble) code, which includes the line ReefAngel.WaterLevelATO(Box1_Port4,35,40,600);
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
int ChannelMaxPct [8] = { 30,30,33,23,13,16,10,0};
////// Place global variable code above here
void setup()
{
ReefAngel.Init();
ReefAngel.AddStandardMenu();
ReefAngel.Use2014Screen();
ReefAngel.AddSalinityExpansion();
ReefAngel.AddORPExpansion();
ReefAngel.AddWaterLevelExpansion();
ReefAngel.Add16ChPWM();
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = Port5Bit | Port6Bit;
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = Port4Bit;
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
ReefAngel.OverheatShutoffPortsE[0] = Port7Bit;
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
ReefAngel.DCPump.FeedingSpeed = 0;
ReefAngel.DCPump.WaterChangeSpeed = 0;
ReefAngel.Relay.On( Port5 );
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port7 );
ReefAngel.Relay.On( Box1_Port1 );
ReefAngel.Relay.On( Box1_Port2 );
ReefAngel.Relay.On( Box1_Port5 );
ReefAngel.Relay.On( Box1_Port6 );
ReefAngel.CustomVar[0] = 0;
ReefAngel.CustomVar[1] = 0;
ReefAngel.CustomVar[2] = 0;
ReefAngel.CustomVar[3] = 0;
ReefAngel.CustomVar[4] = 0;
ReefAngel.CustomVar[5] = 0;
ReefAngel.CustomVar[6] = 0;
ReefAngel.CustomVar[7] = 0;
}
void loop()
{
if ( ReefAngel.Params.Temp[T1_PROBE] < 775 ) ReefAngel.Relay.On( Port1 );
if ( ReefAngel.Params.Temp[T1_PROBE] > 780 ) ReefAngel.Relay.Off( Port1 );
if ( ReefAngel.Params.Temp[T2_PROBE] < 775 ) ReefAngel.Relay.On( Port2 );
if ( ReefAngel.Params.Temp[T2_PROBE] > 780 ) ReefAngel.Relay.Off( Port2 );
if ( ReefAngel.Params.Temp[T3_PROBE] < 775 ) ReefAngel.Relay.On( Box1_Port7 );
if ( ReefAngel.Params.Temp[T3_PROBE] > 780 ) ReefAngel.Relay.Off( Box1_Port7 );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.Threshold = 75;
ReefAngel.DCPump.SetMode( Sine, 100, 240 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
for (int i=0; i<8; i++)
{
if ( ReefAngel.CustomVar[i]==0 )
{
ReefAngel.PWM.Set16ChannelRaw( i, PWMParabolaHighRes(9,00,20,00,0,ChannelMaxPct[i],0));
}
else
{
ReefAngel.PWM.Set16ChannelRaw( i, ReefAngel.CustomVar[i]*16 );
}
}
ReefAngel.Relay.DelayedOn( Port3 );
if (ReefAngel.WaterLevel.GetLevel() > 50) ReefAngel.Relay.Off(Port3);
if (ReefAngel.DisplayedMenu==FEEDING_MODE) ReefAngel.Relay.Off(Port3);
if (!ReefAngel.HighATO.IsActive()) ReefAngel.Relay.Override(Port3,0);
ReefAngel.WaterLevelATO(Box1_Port4,35,40,600); // On at 35% and Off at 40% with 600 second (10 minute) timeout.
ReefAngel.DosingPumpRepeat( Port4, 0, 240, 30); // neck wipe for skimmer
if ( ReefAngel.Params.ORP>450 || ReefAngel.Params.ORP==0 ) ReefAngel.Relay.Off( Port8 );
if ( ReefAngel.Params.ORP<400 && ReefAngel.Params.ORP>0 ) ReefAngel.Relay.On( Port8 );
ReefAngel.Portal( "joshlawless" );
ReefAngel.DDNS( "reef" );
ReefAngel.ShowInterface();
}
A restart will kick it on for about 10 seconds (the relay, although unfortunately not always the pump), but then the red status light shows up on the controller, and the ATO pump (relay) turns back off.
I eventually discovered that this meant the ATO timeout flag was being set, and I could clear the flag through the controller joystick menu. The first time I clear the flag, the pump (relay) turns on again for about 10 seconds, before triggering the timeout again. Each subsequent timeout can't be cleared (entering the menu and clicking the joystick to clear the ATO timeout briefly clicks the red light off and the relay on, but instantly returns the red light and turns off the relay).
From within the controller, there appears to be a place to set an ATO timeout value. This doesn't correspond to the value as I coded directly into the INO, but I've set it up to 255 here (as high as it will go) with no improvement. From the portal, I can confirm that the internal memory version of the high and low levels, and the timeout value (although these shouldn't be used in view of specifying them in the code) are also 35 / 40 / 600.
Can anyone explain what I've done wrong? Or do I still have a hardware problem, even after replacing the expansion hub (maybe the head unit)?