Mike's RSM 500 Code

Share you PDE file with our community
User avatar
Posts: 5330
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Jun 22, 2016 6:13 pm
You aren't turning anything back on when the power comes up. You can either explicitly add it, or move all your on statements from setup() into loop()

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Thu Jun 23, 2016 3:39 am
Hmm ok, I will have to look into it later. Not sure I need my return pump running. I will need to do a test and see how much it uses up battery life.

On another note I woke up this am to find my tank in a power lost state...Temps dropped a few degrees. I also have a ton of power restored emails.

I uploaded my previous code for now, since I have to leave for work.
Image
User avatar
Posts: 5330
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Jun 23, 2016 5:01 am
It sounds like your either having bus lock issues or you have some bad connections based on this and previous issue
User avatar
Posts: 5330
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Thu Jun 23, 2016 5:02 am
It sounds like your either having bus lock issues or you have some bad connections based on this and previous issue

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Thu Jun 23, 2016 9:52 am
OK? What would cause that and how do I fix?
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Mon Aug 22, 2016 12:41 pm
It's been two months since I've updated the code, but I really need to figure out the power restored email thing. I have gotten so many over the last 18hrs (after water change). I will post my updated code tonight (going back to power outage delay timer) to see if the emails stop.
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Mon Aug 22, 2016 2:46 pm
No change, still getting power restored emails every few minutes. Did a full controller reboot for good measure and no change.

Put Lee's check power code back in and did a power failure test. No power failure email. Relays did go off, but then came back on, while still on the ups battery! Now the flowpumps are in an off state (even after a full power reset on the UPS).

I am not sure what's going on here. Help!

Code: Select all
void CheckPower() {
      static time_t powerOutage=false;
      static WiFiAlert powerAlert;

      // Power Outage - turn off everything
      if (!ReefAngel.Relay.IsRelayPresent(EXP1_RELAY) && !powerOutage) // Expansion Relay NOT present
      {
        byte rfPowerOutageSpeed=InternalMemory.read(Mem_B_PowerOutageSpeed);
       
        powerOutage=now();
        if (now()-powerOutage > 300) {
          ReefAngel.Relay.Set(Return, now()%3600<300);
        }
        ReefAngel.Relay.Off(FlowPumps);
        ReefAngel.Relay.Off(Lights);
        ReefAngel.Relay.Off(Skimmer);
        ReefAngel.Relay.Off(FanSump);
        ReefAngel.Relay.Off(HeaterSump);
        ReefAngel.RF.SetMode(Constant,rfPowerOutageSpeed,0);
        if (now()-powerOutage > 10) { // Wait 10 seconds before sending to avoid false alarms
          powerAlert.Send("Power+outage!");
        }
      }

      // Power Restored - Turn things back on
      if (powerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
      {
        powerOutage=0;
        LastStart=now();
        ReefAngel.RF.SetMode(vtMode,vtSpeed,vtDuration);
        powerAlert.Send("Power+restored.",true);
      }
    }
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Tue Oct 04, 2016 1:45 pm
Can anyone help me figure out why the power restore code is emailing me when there isn't any power change occurring?
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Wed Jan 04, 2017 6:33 pm
So I was trying to get a second heater code in place that uses T3 probe, but I am getting this compile error below. I am stuck. Any suggestions?
Code: Select all
sketch_rsms500:64: error: expected ',' or '...' before numeric constant
sketch_rsms500.cpp: In function 'void loop()':
sketch_rsms500:64: error: too few arguments to function 'void WaterchangeHeater(byte, int)'
sketch_rsms500:144: error: at this point in file
sketch_rsms500.cpp: At global scope:
sketch_rsms500:256: error: expected ',' or '...' before numeric constant


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 <WiFiAlert.h>
    #include <ReefAngel.h>

    // Define Custom Memory Locations
    #define Mem_B_SwabbieRepeat     100
    #define Mem_B_SwabbieTime       101
    #define Mem_B_PowerOutageSpeed  102
    #define Mem_I_WCHeaterLowTemp   103
    #define Mem_I_WCHeaterHighTemp  105

    // Define Named Relay Ports
    #define FlowPumps       1
    #define Lights          2
    #define Return          3
    #define VortechL        4
    #define VortechR        5
    #define Skimmer         6
    #define FanSump         7
    #define HeaterSump      8

    #define Reactor         Box1_Port1
    #define Swabbie         Box1_Port2
    #define FugeLight       Box1_Port3
    #define Unused          Box1_Port4
    #define WCMix           Box1_Port5
    #define WCFlow          Box1_Port6
    #define WCHeater        Box1_Port7
    #define Bad             Box1_Port8

    // Place global variable code below here
    // Vortech Variables for PowerOutage
    // byte vtMode, vtSpeed, vtDuration;   
    // Place global variable code above here

    // #################### Setup (controller starting) ####################
    void setup()
    {
      // This must be the first line
      ReefAngel.Init();  //Initialize controller
      ReefAngel.Use2014Screen();  // Let's use 2014 Screen

        // Ports toggled in Feeding Mode
      ReefAngel.FeedingModePorts = 0;
      ReefAngel.FeedingModePortsE[0] = Port8Bit; //Unused port for testing random feeding

      // Ports toggled in Water Change Mode
      ReefAngel.WaterChangePorts = Port1Bit | Port3Bit; // Flowpumps,Return
      ReefAngel.WaterChangePortsE[0] = Port1Bit | Port3Bit; // Reactor,FugeLight

      // Ports toggled when Lights On / Off menu entry selected
      ReefAngel.LightsOnPorts = Port2Bit; //Lights

      // Ports turned off when Overheat temperature exceeded
      ReefAngel.OverheatShutoffPorts = Port2Bit | Port8Bit; //Lights,HeaterSump

      // Use T1 probe as temperature and overheat functions
      ReefAngel.TempProbe = T2_PROBE;
      ReefAngel.OverheatProbe = T1_PROBE;

      // ON by default
      ReefAngel.Relay.On(FlowPumps);
      ReefAngel.Relay.On(Return);
      ReefAngel.Relay.On(VortechL);
      ReefAngel.Relay.On(VortechR);

      // OFF by default
      ReefAngel.Relay.Off(Swabbie);
      ReefAngel.Relay.Off(WCMix);
      ReefAngel.Relay.Off(WCFlow);
      ReefAngel.Relay.Off(WCHeater);
      ReefAngel.Relay.Off(Unused);
      ReefAngel.Relay.Off(Bad);

      // ##### Place additional initialization code below here #####
      // Define labels for LCD screen
      ReefAngel.CustomLabels[0]="Flow Pumps";
      ReefAngel.CustomLabels[1]="Lights";
      ReefAngel.CustomLabels[2]="Return";
      ReefAngel.CustomLabels[3]="Vortech L";
      ReefAngel.CustomLabels[4]="Vortech R";
      ReefAngel.CustomLabels[5]="Skimmer";
      ReefAngel.CustomLabels[6]="Fan";
      ReefAngel.CustomLabels[7]="Heater";

      ReefAngel.CustomLabels[Box1_Port1Label] = "Reactor";
      ReefAngel.CustomLabels[Box1_Port2Label] = "Swabbie";
      ReefAngel.CustomLabels[Box1_Port3Label] = "Fuge Light";
      ReefAngel.CustomLabels[Box1_Port4Label] = "Unused";
      ReefAngel.CustomLabels[Box1_Port5Label] = "WCMix";
      ReefAngel.CustomLabels[Box1_Port6Label] = "WCFlow";
      ReefAngel.CustomLabels[Box1_Port7Label] = "WCHeater";
      ReefAngel.CustomLabels[Box1_Port8Label] = "Bad";

      // 5 second timer for power outage detection
      ReefAngel.Timer[1].SetInterval( 5 );   
   
    }
   
    // #################### Loop ####################
    void loop()
    {
      ReefAngel.Relay.On(Reactor);
      ReefAngel.StandardHeater(HeaterSump);
      ReefAngel.StandardFan(FanSump);
      ReefAngel.StandardLights(Lights);
      ReefAngel.StandardLights(FugeLight,22,0,6,0);
      ReefAngel.Relay.DelayedOn(Skimmer);

      // ##### Place your custom code below here #####

      RunSwabbie();         // Skimmer neck cleaner
      SetRF();              // Set Vortech modes
      CheckPower();         // Monitor for power loss
      CheckSwitches();      // Monitor float switches
      WaterchangeHeater();  // Heater control for Waterchange Heater
     
      // ##### Place your custom code above here #####

      // This should always be the last line
      ReefAngel.Portal("modulok");
      ReefAngel.ShowInterface();
    }

    // #################### Custom Function  ####################
  void CheckPower()
    {
      static boolean powerOutage = false;
      static WiFiAlert powerAlert;
      static boolean delayedPowerOutage = false;

      // Power Outage - Leave Only Vortech Pumps active
      if ( !ReefAngel.Relay.IsRelayPresent( EXP1_RELAY ) ) {
        powerOutage = true;    //Expansion Relay 1 has lost power
      }

      if ( !powerOutage ) {
        ReefAngel.Timer[1].Start();
      }

      if ( ReefAngel.Timer[1].IsTriggered() ) {
        delayedPowerOutage = true;
      }

      if (delayedPowerOutage) {
        ReefAngel.Relay.Off(FlowPumps);
        ReefAngel.Relay.Off(Return);
        ReefAngel.Relay.Off(Skimmer);
        ReefAngel.Relay.Off(Lights);
        ReefAngel.Relay.Off(FanSump);
        ReefAngel.Relay.Off(HeaterSump);
        ReefAngel.RF.SetMode(Constant,70,0);
        powerAlert.Send("Power+lost!");
      }

      // Power Restored - return equipment back to normal power state
      if ( powerOutage && ReefAngel.Relay.IsRelayPresent( EXP1_RELAY ) ) {
        powerOutage = false;
        delayedPowerOutage = false;
        LastStart = now();
        ReefAngel.Relay.On(FlowPumps);
        ReefAngel.Relay.On(Return);
        powerAlert.Send("Power+restored.",true);
      }
    }

    void CheckSwitches() {
      static boolean returnOverride=true;
      static WiFiAlert skimmerAlert, atoAlert;
      skimmerAlert.SetDelay(3600);
      atoAlert.SetDelay(3600);

      if (ReefAngel.DisplayedMenu==FEEDING_MODE || ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
        returnOverride=true;

      // HighATO=off, Skimmer shuts off
      if (!ReefAngel.HighATO.IsActive()) {
        skimmerAlert.Send("Skimmate+container+is+full!+Skimmer+has+been+shutoff.");
        ReefAngel.Relay.Override(Skimmer,0);
      }

      // If Return pump is off, kill power to Skimmer
      if (!ReefAngel.Relay.Status(Return)) {
        ReefAngel.Relay.Override(Skimmer,0);
      }

      // Alert if ATO timeout flag
      if (bitRead(ReefAngel.AlertFlags,ATOTimeOutFlag))
        atoAlert.Send("ATO+timeout!+ATO+disabled.");
    }

    void SetRF() {
      // Vortech MP40 | Constant | Lagoon | ReefCrest | ShortWave 1=10ms | LongWave 1=1s | NutrientTransport 1=10ms | TidalSwell
      if ( ReefAngel.DisplayedMenu != FEEDING_MODE || ReefAngel.DisplayedMenu != WATERCHANGE_MODE ) {
        if ( hour() >= 16 && hour() <= 20 ) {
          ReefAngel.RF.UseMemory = false;
          ReefAngel.RF.SetMode( LongWave, 70, 30 );
        }
        else if ( hour() >= 20 || hour() < 7 ) {
          ReefAngel.RF.UseMemory = false;
          ReefAngel.RF.SetMode( ReefCrest, 40, 0 );
        }
        else {
          ReefAngel.RF.UseMemory = true;
        }
      }
    }

    void RunSwabbie() {
      int repeat=InternalMemory.read(Mem_B_SwabbieRepeat)*60;
      int runtime=InternalMemory.read(Mem_B_SwabbieTime)*60;
      static time_t t;

      // Manual mode
      if (ReefAngel.Relay.isMaskOn(Swabbie)) {
        ReefAngel.Relay.Auto(Swabbie);
        t=now();
      }

      if (now()-t < runtime) {
        ReefAngel.Relay.On(Swabbie);
      }
      else {
        ReefAngel.DosingPumpRepeat(Swabbie,0,repeat,runtime);   
      }
    }

   void WaterchangeHeater(byte WCHeaterRelay, int Mem_I_WCHeaterLowTemp, int Mem_I_WCHeaterHighTemp)
    {
      if (ReefAngel.Params.Temp[T3_PROBE] == 0) return;  // Don't turn the heater on if the temp is reading 0
      if (ReefAngel.Params.Temp[T3_PROBE] <= Mem_I_WCHeaterLowTemp && ReefAngel.Params.Temp[T3_PROBE] > 0) ReefAngel.Relay.On(WCHeater); // If sensor temperature <= LowTemp - turn on heater
      if (ReefAngel.Params.Temp[T3_PROBE] >= Mem_I_WCHeaterHighTemp) ReefAngel.Relay.Off(WCHeater); // If sensor temperature >= HighTemp - turn off heater
    }
    // #################### Custom Function End ####################
Image
Previous

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 2 guests