Mike's RSM 500 Code

Share you PDE file with our community

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Sun Sep 08, 2013 1:53 pm
I have two Vortech MP40s on the way, as well as the RF Expansion and Expansion Hub. I should have everything by Tuesday.

Here are my ideas:
  • Enable Center lights on for 10mins after RA feed mode
  • MP40: Change modes throughout the day, night mode when lights are off, feed mode
  • I would like to put both MP40s on the main relay (flow1-3, return, skimmer, MP40, MP40)
  • Change Power Failure mode so that a single MP40 goes to low power mode (Main Relay Box is connected to UPS)


I was thinking to update the light schedule. I have 3 separate fixtures, and was thinking of giving each a 15 minute break every few hours. Would it work just by giving separate ReefAngel.StandardLights for a single fixture, leaving 15 min gaps when necessary?

Thanks

Here is my current code.
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 Custom Main ---------------------------------
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(5, 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.Clear(DefaultBGColor,5,88,95,95);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,5,88,MoonPhaseLabel());
//Dimmable Moon LEDs
ReefAngel.LCD.DrawText(COLOR_NAVY,255,5,98, "MoonLEDs:");
ReefAngel.LCD.Clear(DefaultBGColor,59,98,75,106);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,59,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( 2, 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( 2, 119, TempRelay );
    pingSerial();

}

void DrawCustomGraph()
{}
//--------------------------------- End Custom Main ---------------------------------
//--------------------------------- 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 | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port7Bit; //Flow1-3,Return,Skimmer,CoolingFan
    ReefAngel.FeedingModePortsE[0] = Port2Bit | Port6Bit; //FrontT5,SumpHeater
   
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit; // Flow1-3,Return,Skimmer,DispHeater,CoolingFan
    ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port6Bit; //Front+BackT5,SumpHeater
   
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit; //Center+Front+BackT5
   
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port6Bit; //DispHeater
    ReefAngel.OverheatShutoffPortsE[0] = Port2Bit | Port3Bit | Port5Bit | Port6Bit; //Front+BackT5,FugeLight,SumpHeater
   
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
   
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 820 );
   
    //--------------------------------- 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
    ReefAngel.Relay.On( Port4 ); //Return
   
    //Delay Start
    ReefAngel.Relay.DelayedOn( Port5,5 ); //Skimmer

    /*Feed Mode Delay on Pump
    static boolean feeding=true;
    static unsigned long feedingstarted = 0;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE)
    {
      if (!feeding)
      {
      feeding=true;
      feedingstarted = now();
      }
    } else {
      feeding=false;
    }
   
    int pumpdelay=InternalMemory.FeedingTimer_read()-240; // 4 minute delay
    if (now()-feedingstarted<=pumpdelay) {
      ReefAngel.Relay.Off( Port1 ); //Flow1
      ReefAngel.Relay.Off( Port2 ); //Flow2
      ReefAngel.Relay.Off( 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();
    }
         
    // Heaters
    ReefAngel.StandardHeater( Port6,770,774 ); //DispHeater
    ReefAngel.StandardHeater( Box1_Port6,768,772 ); //SumpHeater
   
    // Cooling Fan
    ReefAngel.StandardFan( Port7,812,814 ); //Cooling Fan
   
    // T5 Light Schedule
    ReefAngel.StandardLights( Box1_Port1,9,0,20,0 ); //CenterT5 9a-8p
    ReefAngel.StandardLights( Box1_Port2,10,0,18,0 ); //FrontT5 10a-6p
    ReefAngel.StandardLights( Box1_Port3,10,30,18,45 ); //BackT5 1030a-645p
   
    // RSMLED Moonlight Schedule
    if (hour()>=6 && hour()<=8) ReefAngel.StandardLights( Box1_Port4,6,0,8,59 ); //RSMLED Morning 6a-9a
    else if(hour()>=20 && hour()<=23) ReefAngel.StandardLights( Box1_Port4,20,0,23,45 ); //RSMLED Evening 8p-1145p
    else if(hour()>=23 || hour()<=4) if (MoonPhase()>=90) ReefAngel.StandardLights( Box1_Port4,23,46,4,0 ); //RSMLED on for Full Moon 1146p-4a
   
    // Fuge Light Schedule
    //ReefAngel.StandardLights( Box1_Port5,0,0,8,0 ); //FugeLight 12a-8a
   
    // PWM Dimmable Moonlights Schedule
    if (hour()>=21 || hour()<4) // Turn Dimmable Moonlights on 9p & off 4a
    {
      ReefAngel.PWM.SetActinic(MoonPhase());
      ReefAngel.PWM.SetDaylight(MoonPhase());
    }
    else
    {
      ReefAngel.PWM.SetActinic(0);
      ReefAngel.PWM.SetDaylight(0);
    }
   
    //--------------------------------- Place your custom code below here ---------------------------------
    // Turn on Fuge light during water change mode
    //if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) ReefAngel.Relay.On(Box1_Port5);
   
    // 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 (Port2); //Flow2
    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 ---------------------------------
Last edited by modulok on Fri Sep 13, 2013 6:54 pm, edited 1 time in total.
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Sun Sep 08, 2013 7:10 pm
Here is what I am thinking for the light schedule. Giving each fixture a 15min break every 2hrs. Any reason why it would be bad for the lights/fixture?

Code: Select all
    // Center T5 Light Schedule [ 9:15am - 6:00pm ]
    ReefAngel.StandardLights( CenterT5,9,15,11,15 ); //0915-1115
    ReefAngel.StandardLights( CenterT5,11,30,13,30 ); //1130-1330
    ReefAngel.StandardLights( CenterT5,13,45,15,45 ); //1345-1545
    ReefAngel.StandardLights( CenterT5,16,00,18,00 ); //1600-1800
       
    // Front T5 Light Schedule [ 10:00am - 6:45pm ]
    ReefAngel.StandardLights( FrontT5,10,0,12,0 ); //1000-1200
    ReefAngel.StandardLights( FrontT5,10,0,18,0 ); //1215-1415
    ReefAngel.StandardLights( FrontT5,10,0,18,0 ); //1430-1630
    ReefAngel.StandardLights( FrontT5,10,0,18,0 ); //1645-1845
   
    // Back T5 Light Schedule [ 11:15am - 8:00pm ]
    ReefAngel.StandardLights( BackT5,11,15,13,15 ); //1115-1315
    ReefAngel.StandardLights( BackT5,13,30,15,30 ); //1330-1530
    ReefAngel.StandardLights( BackT5,15,45,17,45 ); //1545-1745
    ReefAngel.StandardLights( BackT5,18,0,20,0 ); //1800-2000
Image

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sun Sep 08, 2013 7:42 pm
It works, but you need to do some leg work, which would make it very hard to understand.
The way I would do it is set the StandardLights for the entire period and override it off when you what them off
Something like this:
Code: Select all
ReefAngel.StandardLights( CenterT5,9,15,18,0 ); //0915-1800
if (hour()==11 && minute()>=15 && minute()<=30) ReefAngel.Relay.Off(CenterT5);
Roberto.

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Fri Sep 13, 2013 4:21 pm
Something is very wrong now. After a few minutes, the red light starts blinking on the RA. On the display only a few ports shown as on, although everything that should be on is in fact on. Same ports show as on with the Android app. Can't turn on anything either.

I did a full power cycle for both relays and it did not help.

I added both MP40s to the RA (used the vortech setup code and such), and they are both white and running.

EDIT: ok, 8PM now, center T5 is still on, App and LCD show it as turned off. MoonLEDs should be on, like signature says, but they are not. I'm going to revert back to older code and see if problem is still there.

Any suggestions? I'm going to wait until 8 and see if the light goes off like it should.

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>

// Define Relay Ports by Name
#define Flow1           1
#define Flow2           2
#define Flow3           3
#define Return          4
#define Skimmer         5
#define VortechL        6
#define VortechR        7
#define HeaterDisp      8

#define CenterT5        Box1_Port1
#define FrontT5         Box1_Port2
#define BackT5          Box1_Port3
#define MoonLED         Box1_Port4
#define Unused          Box1_Port5
#define Unused          Box1_Port6
#define FanSump         Box1_Port7
#define HeaterSump      Box1_Port8

//--------------------------------- 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 Custom Main ---------------------------------
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(5, 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.Clear(DefaultBGColor,5,88,95,95);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,5,88,MoonPhaseLabel());
//Dimmable Moon LEDs
ReefAngel.LCD.DrawText(COLOR_NAVY,255,5,98, "MoonLEDs:");
ReefAngel.LCD.Clear(DefaultBGColor,59,98,75,106);
ReefAngel.LCD.DrawText(COLOR_CORNFLOWERBLUE,255,59,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( 2, 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( 2, 119, TempRelay );
    pingSerial();

}

void DrawCustomGraph()
{}
//--------------------------------- End Custom Main ---------------------------------
//--------------------------------- Begin Setup ---------------------------------
void setup()
{
    // This must be the first line
    ReefAngel.Init(); //Initialize controller
    ReefAngel.InitMenu(pgm_read_word(&(menu_items[0])),SIZE(menu_items)); // Initialize the menu
   
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit; //Flow1-3,Return,Skimmer
    ReefAngel.FeedingModePortsE[0] = Port2Bit | Port7Bit | Port8Bit; //FrontT5,FanSump,SumpHeater
   
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port8Bit; // Flow1-3,Return,Skimmer,DispHeater
    ReefAngel.WaterChangePortsE[0] = Port2Bit | Port3Bit | Port7Bit | Port8Bit; //Front+BackT5,FanSump,SumpHeater
   
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    ReefAngel.LightsOnPortsE[0] = Port1Bit | Port2Bit | Port3Bit; //Center+Front+BackT5
   
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port8Bit; //DispHeater
    ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port8Bit; //Center+Front+BackT5,SumpHeater
   
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
   
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 820 );
   
    //--------------------------------- 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( Flow1 );
    ReefAngel.Relay.On( Flow2 );
    ReefAngel.Relay.On( Flow3 );
    ReefAngel.Relay.On( Return );
    ReefAngel.Relay.On( VortechL );
    ReefAngel.Relay.On( VortechR );
   
    // Ports that are delayed on Power Cycle & Feeding & Water Change
    ReefAngel.Relay.DelayedOn( Skimmer,1 );
   
    //Vortech
    ReefAngel.RF.UseMemory = false;
    ReefAngel.RF.SetMode( ReefCrest,30,10 );

    /*Feed Mode Delay on Pump
    static boolean feeding=true;
    static unsigned long feedingstarted = 0;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE)
    {
      if (!feeding)
      {
      feeding=true;
      feedingstarted = now();
      }
    } else {
      feeding=false;
    }
   
    int pumpdelay=InternalMemory.FeedingTimer_read()-240; // 4 minute delay
    if (now()-feedingstarted<=pumpdelay) {
      ReefAngel.Relay.Off( Flow1 );
      ReefAngel.Relay.Off( Flow2 );
      ReefAngel.Relay.Off( Flow3 );
    }
    */
       
    // Temperature
    ReefAngel.StandardHeater( HeaterDisp,770,774 );
    ReefAngel.StandardHeater( HeaterSump,768,772 );
    ReefAngel.StandardFan( FanSump,812,814 );
   
    // Light Schedule
    ReefAngel.StandardLights( CenterT5,9,0,20,0 ); //CenterT5 9a-8p
    if (hour()==12 && minute()>=30 && minute()<=45) ReefAngel.Relay.Off(CenterT5);
    if (hour()==16 && minute()>=30 && minute()<=45) ReefAngel.Relay.Off(CenterT5);
   
    ReefAngel.StandardLights( FrontT5,10,0,18,0 ); //FrontT5 10a-6p
    if (hour()==13 && minute()>=15 && minute()<=30) ReefAngel.Relay.Off(FrontT5);
    if (hour()==16 && minute()>=15 && minute()<=30) ReefAngel.Relay.Off(FrontT5);
   
    ReefAngel.StandardLights( BackT5,10,30,18,45 ); //BackT5 1030a-645p
    if (hour()==13 && minute()>=45 && minute()<=0) ReefAngel.Relay.Off(BackT5);
    if (hour()==13 && minute()>=45 && minute()<=0) ReefAngel.Relay.Off(BackT5);
   
    // RSMLED Moonlight Schedule
    if (hour()>=6 && hour()<=8) ReefAngel.StandardLights( MoonLED,6,0,8,59 ); //RSMLED Morning 6a-9a
    else if(hour()>=20 && hour()<=23) ReefAngel.StandardLights( MoonLED,20,0,23,45 ); //RSMLED Evening 8p-1145p
    else if(hour()>=23 || hour()<=4) if (MoonPhase()>=90) ReefAngel.StandardLights( MoonLED,23,46,4,0 ); //RSMLED on for Full Moon 1146p-4a
   
    // PWM Dimmable Moonlights Schedule
    if (hour()>=21 || hour()<4) // Turn Dimmable Moonlights on 9p & off 4a
    {
      ReefAngel.PWM.SetActinic(MoonPhase());
      ReefAngel.PWM.SetDaylight(MoonPhase());
    }
    else
    {
      ReefAngel.PWM.SetActinic(0);
      ReefAngel.PWM.SetDaylight(0);
    }
   
    //--------------------------------- Place your custom code below here ---------------------------------
    // Turn on Fuge light during water change mode
    //if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) ReefAngel.Relay.On(Box1_Port5);
   
    if (PowerOutage && ReefAngel.Relay.IsRelayPresent(EXP1_RELAY))
    {
      PowerOutage=false;
      DelayedPowerOutage=false;
      LastStart=now();
    }
   
    // Power Outage
    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 (Flow1);
    ReefAngel.Relay.Off (Flow2);
    ReefAngel.Relay.Off (Flow3);
    ReefAngel.Relay.Off (Return);
    ReefAngel.Relay.Off (Skimmer);
    ReefAngel.Relay.Off (VortechL);
    ReefAngel.Relay.Off (HeaterDisp);
    }
   
    // When Return pump is off shut off Skimmer & FanSump
    if (!ReefAngel.Relay.Status(Return)) {
      ReefAngel.Relay.Override(Skimmer,0);
      ReefAngel.Relay.Override(FanSump,0);
    }
   
    //--------------------------------- Place your custom code above here ---------------------------------

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

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Fri Sep 13, 2013 8:41 pm
Went back to old code and it looks like its stable again. I got scared when I saw the heater light turn on, but the RA and app wasn't aware of that!

On the setup for both Vortech MP40s...I did the reset on each unit and hooked the BOTH to the RF unit. Each pump is either white or orange (when pressing mode).

Is this correct? Do the pumps think the RF module is the master pump, and you can set the left or right pump to sync/anti-sync?
ie: Left Vortech white driver and Right Vortech orange driver for anti-sync/opposite side as master.

EDIT: Also, why does the app show this?
Mode Reef Crest
Speed 20%
Duration 20%

Isn't the code below stating 10 duration?
ReefAngel.RF.UseMemory = false;
ReefAngel.RF.SetMode( ReefCrest,20,10 );
Image

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Sat Sep 14, 2013 7:34 am
I uploaded new code, still stuck with ReefCrest, 20, 10. Had the same issue with the blinking red light on controller, and no response from android app.

I commented out the RF lines and reuploaded. Now both MP40s are in Nutrient Mode, at 50% power and 10ms. I NEVER set a mode other than ReefCrest. What is going on here?

Edit: Red blinking light is back! Cannot control anything again, will need to power cycle the head unit.
Image

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sat Sep 14, 2013 8:45 am
Yes, the pumps will think that the RF module is master and each pump can be setup as sync (white) or anti-sync(orange).
If you use ReefAngel.RF.UseMemory = true;, that's when the controller will use the settings shown in the app or portal.
If you use ReefAngel.RF.UseMemory = false;, it will ignore the memory settings and use your hard coded settings
In my case, I use memory settings (long pulse at 75% with 300s pulse) during the day. I change to UseMemory = false at night to slow down the pumps and also at 3pm through 6pm when it runs long pulse at 100% with 3s pulse.
This is the code for your reference:
Code: Select all
  if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
  {
    if (hour()>=15 && hour()<=17)
    {
      ReefAngel.RF.UseMemory=false;
      ReefAngel.RF.SetMode(LongWave,100,3);
    }
    else if (hour()>=22 || hour()<7)
    {
      ReefAngel.RF.UseMemory=false;
      ReefAngel.RF.SetMode(ReefCrest,40,0);
    }
    else
    {
      ReefAngel.RF.UseMemory=true;
    }
  }

The red blinking is being cause by noise or bad connection somewhere in the expansion bus.
Can you check your connections and see if you've got any cables going too close to any ballasts/drivers?
If that doesn't work, we can try changing the firmware of the rf module.
Roberto.

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Sat Sep 14, 2013 9:28 am
What do you mean by ballasts/drivers? I have both relay boxes, expansion, relay exp,and RF exp in close proximity, and the wifi exp is the only one next to the RA head unit. The two MP40 drivers are 2-3 feet from other equip right now.

I am thinking that when I commented out the RF lines the internal memory setting took over. On the portal it does say Nutrient @ 50%...
Image

Posts: 12225
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sat Sep 14, 2013 9:39 am
I meant LED drivers/MH ballasts.
They generate quite a bit of noise and interference that can be picked up by the bus if place too close to them.
Roberto.

Posts: 163
Joined: Wed Oct 24, 2012 8:37 am
PostPosted: Sat Sep 14, 2013 9:51 am
OK, only LEDs I have are the moonlights on the PWM, which have been in the same location since January.

I will replug everything and see if issue persists...if that's not it, how do I do firmware for RF exp?
Image
Next

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 2 guests