My code - now with RAnet

Share you PDE file with our community
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

just wanted to say the ATO pump went on/off as it should through the nite and it only takes ~1 min for it to go from 58% to 60%. no red light. I did not reconnect float switch yet.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

Awesome!
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

added floatswitch back with HighATO

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 Heater      1
    #define Return      2
    #define Skimmer     3
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7 
    */
    ////// Place global variable code below here
byte vtechmode;

    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled in Water Change Mode
        ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled when Lights On / Off menu entry selected
        ReefAngel.LightsOnPorts = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Use T1 probe as temperature and overheat functions
        ReefAngel.TempProbe = T1_PROBE;
        ReefAngel.OverheatProbe = T1_PROBE;


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
       

        ////// Place additional initialization code below here
       
	// Hardcode calibrations
	ReefAngel.PHMin=576; // PH7.0
	ReefAngel.PHMax=842; // PH10.0
        ReefAngel.SalMax=3000; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
        ReefAngel.StandardHeater( Port1,796,802 );
        ReefAngel.WaterLevelATO( Port7,180,58,60 ); 
        // If water level less than 58, turn on auto top off relay; else, keep it off
            // if (ReefAngel.WaterLevel.GetLevel()<58) ReefAngel.Relay.On(Port7);
             // else ReefAngel.Relay.Off(Port7);
        ReefAngel.PWM.SetChannel( 0, MoonPhase() );
        ReefAngel.PWM.Channel1PWMParabola();
        ReefAngel.PWM.Channel2PWMParabola();
        ReefAngel.PWM.Channel3PWMParabola();
        ReefAngel.PWM.Channel4PWMSlope();
        // ReefAngel.SingleATOLow(Port2);
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
        
        if (hour() <= 8 && hour() >= 20)
            {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,15,0);
            vtechmode = 9;
            }
        else
             {
             ReefAngel.RF.UseMemory=true;
             vtechmode = InternalMemory.RFMode_read();
             }


        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
    void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 126, "--------------------");
  for (byte Left=93; Left < 133; Left+=10)
  {
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, Left, "|");
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, Left, "|");
  }
 ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");
  
  ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,30,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
  pingSerial();

          // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 77, TempRelay );
        pingSerial();
// water level
    ReefAngel.LCD.DrawText(0,255,8,68,"WL:");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();


    }

    void DrawCustomGraph()
    {
    }
so far it's good.

had to use this code to get my RF working

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 Constant      0
    //#define Random1       1 // Lagoonal
    //#define Random2       2 // Reef Crest
    //#define ShortWave     3
    //#define LongWave      4
    //#define Smart_NTM     5 // Nutrient Transport Mode
    //#define Smart_TSM     6 // Tidal Swell Mode
    //#define Feeding_Start 7
    //#define Feeding_Stop  8
    //#define Night         9
    //#define Slave_Start   97
    //#define Slave_Stop    98
    //#define None          99

    void setup()
    {
      ReefAngel.Init();  //Initialize controller
      ReefAngel.LCD.DrawText(0,255,20,50,"Assigning Slaves");
      ReefAngel.RF.SendData(Slave_Start,0,0);
      ReefAngel.RF.UseMemory=false;
      InternalMemory.RFMode_write(0);
      InternalMemory.RFSpeed_write(128);
      InternalMemory.RFDuration_write(10);
    }

    void loop()
    {
      ReefAngel.Refresh();
      if (ReefAngel.Joystick.IsButtonPressed())
      {
        ReefAngel.RF.UseMemory=true;
        ReefAngel.RF.SendData(Slave_Stop,0,0);
        ReefAngel.LCD.DrawText(0,255,50,60,"Done");
      }
    }

Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

so my vortechs are always stuck in night mode

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 Heater      1
    #define Return      2
    #define Skimmer     3
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7 
    */
    ////// Place global variable code below here
byte vtechmode;
    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled in Water Change Mode
        ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled when Lights On / Off menu entry selected
        ReefAngel.LightsOnPorts = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Use T1 probe as temperature and overheat functions
        ReefAngel.TempProbe = T1_PROBE;
        ReefAngel.OverheatProbe = T1_PROBE;


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
       

        ////// Place additional initialization code below here
       
  // Hardcode calibrations
  ReefAngel.PHMin=576; // PH7.0
  ReefAngel.PHMax=842; // PH10.0
        ReefAngel.SalMax=3000; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
        ReefAngel.StandardHeater( Port1,796,802 );
        ReefAngel.WaterLevelATO( Port7,120,58,60 ); 
        // If water level less than 58, turn on auto top off relay; else, keep it off
            // if (ReefAngel.WaterLevel.GetLevel()<58) ReefAngel.Relay.On(Port7);
             // else ReefAngel.Relay.Off(Port7);
        ReefAngel.PWM.SetChannel( 0, MoonPhase() );
        ReefAngel.PWM.Channel1PWMSlope();
        ReefAngel.PWM.Channel2PWMSlope();
        ReefAngel.PWM.Channel3PWMSlope();
        ReefAngel.PWM.Channel4PWMSlope();
        // ReefAngel.SingleATOLow(Port2);
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
        
        if (hour() >=8 && hour() < 20)
            {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,15,0);
            }
        else
             {
             ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
             ReefAngel.RF.UseMemory=true;
             }


        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
    void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 126, "--------------------");
  for (byte Left=93; Left < 133; Left+=10)
  {
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, Left, "|");
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, Left, "|");
  }
 ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");
  
  ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,30,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
  pingSerial();

          // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 77, TempRelay );
        pingSerial();
// water level
    ReefAngel.LCD.DrawText(0,255,8,68,"WL:");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();


    }

    void DrawCustomGraph()
    {
    }
what do I need to change?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

First off, it looks like your Night mode is set to go during the day. Can you check and see if during the night before 8am and after 8pm if you are still in Night mode.

This bit is what says what time... right now it says greater than 8am and before 8pm be in Night mode..

Code: Select all

        if (hour() >=8 && hour() < 20)
            {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,15,0);
            }
This bit says when not in night mode to use Memory. Can you confirm what values you have set in the portal for your Vortechs

Code: Select all

        else
             {
             ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
             ReefAngel.RF.UseMemory=true;
             }
As I said, it looks like your in Night mode during the day...
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

lnevo wrote:First off, it looks like your Night mode is set to go during the day. Can you check and see if during the night before 8am and after 8pm if you are still in Night mode.

This bit is what says what time... right now it says greater than 8am and before 8pm be in Night mode..

Code: Select all

        if (hour() >=8 && hour() < 20)
            {
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,15,0);
            }
This bit says when not in night mode to use Memory. Can you confirm what values you have set in the portal for your Vortechs

Code: Select all

        else
             {
             ReefAngel.RF.SetMode(Feeding_Stop,0,0); //Temp fix for coming out of Night mode
             ReefAngel.RF.UseMemory=true;
             }
As I said, it looks like your in Night mode during the day...
so this instead?

Code: Select all

            if (hour() <=8 && hour() > 20)
                {
                ReefAngel.RF.UseMemory=false;
                ReefAngel.RF.SetMode(Night,15,0);
                }
portal is set to tidal swell. RA display shows "night" and RF is breathing white.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

Yep, you have the time right now. Give it a try.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

Actually that condition would never happen.
Try this:

Code: Select all

  if (hour() >=8 && hour() < 20)
  {
    if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0); 
    ReefAngel.RF.UseMemory=true;
  }
  else
  {
    ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Night,15,0);
  }  
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

Good catch. Can't believe I missed that... the other option is to just change the && to ||
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:Actually that condition would never happen.
Try this:

Code: Select all

  if (hour() >=8 && hour() < 20)
  {
    if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0); 
    ReefAngel.RF.UseMemory=true;
  }
  else
  {
    ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Night,15,0);
  }  
thank you very much!!
this did it!
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

oh my god. I just can't win. port 1 on my relay box is not working now. you can hear the relay clicking when you change it from off/on or on/off via portal or android but no power is coming from the outlet.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

I ran the controller tester sketch as well and that confirms port one doesn't work. what else can I try?

had to move my heater to port 3.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

how do I code temp probe 2 to turn on port 3 at 76 and off at 77?
it's for a second tank.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

StandardHeater(Port3,76,77);

Oh wait..you need it for probe 2...one minute..
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
}
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

lnevo wrote:void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (ReefAngel.Params.Temp[T2_PROBE] == 0) return; // Don't turn the heater on if the temp is reading 0
if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0) ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp) ReefAngel.Relay.Off(HeaterRelay); // If sensor 2 temperature >= HighTemp - turn off heater
}
will try this, thank you!
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

sorry for stupid question: where do I put this in my 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>
    /* 
    #define Heater      1
    #define Return      2
    #define Skimmer     3
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7 
    */
    ////// Place global variable code below here
byte vtechmode;
    ////// Place global variable code above here


    void setup()
    {
        // This must be the first line
        ReefAngel.Init();  //Initialize controller
        // Ports toggled in Feeding Mode
        ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled in Water Change Mode
        ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Ports toggled when Lights On / Off menu entry selected
        ReefAngel.LightsOnPorts = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit | Port4Bit | Port5Bit | Port6Bit;
        // Use T1 probe as temperature and overheat functions
        ReefAngel.TempProbe = T1_PROBE;
        ReefAngel.OverheatProbe = T1_PROBE;


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
       

        ////// Place additional initialization code below here
       
  // Hardcode calibrations
  ReefAngel.PHMin=576; // PH7.0
  ReefAngel.PHMax=842; // PH10.0
        ReefAngel.SalMax=3000; // 35ppt
        ////// Place additional initialization code above here
    }

    void loop()
    {
        ReefAngel.StandardHeater( Port1,796,802 );
        ReefAngel.WaterLevelATO( Port7,120,58,60 );   // If water level less than 58, turn on auto top off relay; else, keep it off
        ReefAngel.PWM.SetChannel( 0,PWMSlope(21,30,8,0,15,31,10,15) );
        ReefAngel.PWM.Channel1PWMSlope();
        ReefAngel.PWM.Channel2PWMSlope();
        ReefAngel.PWM.Channel3PWMSlope();
        ReefAngel.PWM.Channel4PWMSlope();
        // ReefAngel.SingleATOLow(Port2);
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
        
  if (hour() >=8 && hour() < 21)
  {
    if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
    ReefAngel.RF.UseMemory=true;
    ReefAngel.Relay.Off(Port8);
  }
  else
  {
    ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Night,15,0);
    ReefAngel.Relay.On(Port8);
  }


        // This should always be the last line
        ReefAngel.Portal( "bencollinz" );
        ReefAngel.ShowInterface();
    }
   
    void DrawCustomMain()
    {
      char text[7];
        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 2 );
        ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
        pingSerial();

  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 90, "--------------------");
  ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 126, "--------------------");
  for (byte Left=93; Left < 133; Left+=10)
  {
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, Left, "|");
    ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, Left, "|");
  }
 ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
  ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
  if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
  else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
  else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
  else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
  else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
  else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
  else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
  else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");
  
  ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,100,30,"pH");
  ConvertNumToString(text, ReefAngel.Params.PH, 100);
  ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 40, text, Num8x8);
  pingSerial();

  ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
  pingSerial();

          // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 77, TempRelay );
        pingSerial();
// water level
    ReefAngel.LCD.DrawText(0,255,8,68,"WL:");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();


    }

    void DrawCustomGraph()
    {
    }
Image
enigma32
Posts: 74
Joined: Fri Apr 26, 2013 11:48 am
Location: Los Angeles and NYC

Re: My code

Post by enigma32 »

You can put that block ("void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp) ......") at the bottom of your file, beneath:

Code: Select all

void DrawCustomGraph()
{
}
And you'll need to call the new function from within your loop, probably on the line after:

Code: Select all

ReefAngel.StandardHeater( Port1,796,802 );
like:

Code: Select all

StandardHeater2( Port3, 76, 77 );
^^^ I'm not sure about the range of the temperatures there. (i.e., should it be in "degrees F" or "degrees F times 10" ?)


FYI, I happened to run across this in the ReefAngel class:

Code: Select all

OverheatProbe = T2_PROBE;
Not sure if that would be a problem for running a second tank? lnevo, did you take this into account?


In the end, I'd say something like:

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 Heater      1
        #define Return      2
        #define Skimmer     3
        #define Vortech1    5
        #define Vortech2    6
        #define ATO         7
        */
        ////// Place global variable code below here
    byte vtechmode;
        ////// Place global variable code above here


        void setup()
        {
            // This must be the first line
            ReefAngel.Init();  //Initialize controller
            // Ports toggled in Feeding Mode
            ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
            // Ports toggled in Water Change Mode
            ReefAngel.WaterChangePorts = Port7Bit | Port4Bit | Port5Bit | Port6Bit;
            // Ports toggled when Lights On / Off menu entry selected
            ReefAngel.LightsOnPorts = 0;
            // Ports turned off when Overheat temperature exceeded
            ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port7Bit | Port4Bit | Port5Bit | Port6Bit;
            // Use T1 probe as temperature and overheat functions
            ReefAngel.TempProbe = T1_PROBE;
            ReefAngel.OverheatProbe = T1_PROBE;


            // Ports that are always on
            ReefAngel.Relay.On( Port2 );
            ReefAngel.Relay.On( Port5 );
            ReefAngel.Relay.On( Port6 );
           

            ////// Place additional initialization code below here
           
      // Hardcode calibrations
      ReefAngel.PHMin=576; // PH7.0
      ReefAngel.PHMax=842; // PH10.0
            ReefAngel.SalMax=3000; // 35ppt
            ////// Place additional initialization code above here
        }

        void loop()
        {
            ReefAngel.StandardHeater( Port1,796,802 );
            StandardHeater2( Port3, 76, 77 ); // YOU SHOULD VERIFY THE TEMPERATURE VALUES HERE... I'M BASING THIS ON OTHER POSTS FROM THE FORUM.
            ReefAngel.WaterLevelATO( Port7,120,58,60 );   // If water level less than 58, turn on auto top off relay; else, keep it off
            ReefAngel.PWM.SetChannel( 0,PWMSlope(21,30,8,0,15,31,10,15) );
            ReefAngel.PWM.Channel1PWMSlope();
            ReefAngel.PWM.Channel2PWMSlope();
            ReefAngel.PWM.Channel3PWMSlope();
            ReefAngel.PWM.Channel4PWMSlope();
            // ReefAngel.SingleATOLow(Port2);
            if ( ReefAngel.HighATO.IsActive())
            {
              ReefAngel.Relay.On(Port2);
            }
            else
            {
              ReefAngel.Relay.Off(Port2);
            }
           
      if (hour() >=8 && hour() < 21)
      {
        if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
        ReefAngel.RF.UseMemory=true;
        ReefAngel.Relay.Off(Port8);
      }
      else
      {
        ReefAngel.RF.UseMemory=false;
        ReefAngel.RF.SetMode(Night,15,0);
        ReefAngel.Relay.On(Port8);
      }


            // This should always be the last line
            ReefAngel.Portal( "bencollinz" );
            ReefAngel.ShowInterface();
        }
       
        void DrawCustomMain()
        {
          char text[7];
            // Date and Time
            ReefAngel.LCD.DrawDate( 6, 2 );
            ReefAngel.LCD.Clear(COLOR_BLACK, 1, 11, 132, 11);
            pingSerial();

      ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 90, "--------------------");
      ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 6, 126, "--------------------");
      for (byte Left=93; Left < 133; Left+=10)
      {
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, Left, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, Left, "|");
      }
    ReefAngel.LCD.DrawText(0,255,18,12,"EcoSmart Vortech");
      ReefAngel.LCD.Clear(255, 1, 19, 128, 29);
      if (vtechmode == 0) ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN,255,35,21,"Constant");
      else if(vtechmode == 1) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,42,21,"Lagoon");
      else if (vtechmode == 2) ReefAngel.LCD.DrawLargeText(COLOR_GOLD,255,25,21,"Reef Crest");
      else if (vtechmode == 3) ReefAngel.LCD.DrawLargeText(COLOR_CORNFLOWERBLUE,255,22,21,"Short Pulse");
      else if (vtechmode == 4) ReefAngel.LCD.DrawLargeText(COLOR_PINK,255,25,21,"Long Pulse");
      else if (vtechmode == 5) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,8,21,"Nutrient Trnsp.");
      else if (vtechmode == 6) ReefAngel.LCD.DrawLargeText(COLOR_MAGENTA,255,23,21,"Tidal Swell");
      else if (vtechmode == 9) ReefAngel.LCD.DrawLargeText(COLOR_WHITE,0,45,21,"Night");
     
      ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
      ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 40, text, Num8x8);
      pingSerial();

      ReefAngel.LCD.DrawText(0,255,100,30,"pH");
      ConvertNumToString(text, ReefAngel.Params.PH, 100);
      ReefAngel.LCD.DrawLargeText(COLOR_PLUM, 255, 85, 40, text, Num8x8);
      pingSerial();

      ReefAngel.LCD.DrawText(0,255,43,48,"Salinity");
      ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
      ReefAngel.LCD.DrawLargeText(COLOR_LIMEGREEN, 255, 49, 58, text, Num8x8);
      pingSerial();

              // Main Relay Box
            byte TempRelay = ReefAngel.Relay.RelayData;
            TempRelay &= ReefAngel.Relay.RelayMaskOff;
            TempRelay |= ReefAngel.Relay.RelayMaskOn;
            ReefAngel.LCD.DrawOutletBox( 12, 77, TempRelay );
            pingSerial();
    // water level
        ReefAngel.LCD.DrawText(0,255,8,68,"WL:");
        ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
        pingSerial();


        }

        void DrawCustomGraph()
        {
        }

        void StandardHeater2(byte HeaterRelay, int LowTemp, int HighTemp)
        {
                if (ReefAngel.Params.Temp[T2_PROBE] == 0)
                        return; // Don't turn the heater on if the temp is reading 0
                if (ReefAngel.Params.Temp[T2_PROBE] <= LowTemp && ReefAngel.Params.Temp[T2_PROBE] > 0)
                        ReefAngel.Relay.On(HeaterRelay); // If sensor 2 temperature <= LowTemp - turn on heater
                if (ReefAngel.Params.Temp[T2_PROBE] >= HighTemp)
                        ReefAngel.Relay.Off(HeaterRelay); // If sensor temperature >= HighTemp - turn off heater
        }
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

Overheat probe can be set to whatever...and yes the values are temp times 10...

So 77.5 would be 775.

Lee
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

Overheat probe can be set to whatever...and yes the values are temp times 10...

So 77.5 would be 775.

Lee
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

Thank you both. Will try it out.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

I would like my mp10s to go into feeding mode when I choose feeding mode from the menu...how would I go about doing that?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

it does it automatically.
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:it does it automatically.
oh. cool. didn't know that. I'm on 1.03, haven't updated for awhile...it will still do that?
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

bencollinz wrote:
rimai wrote:it does it automatically.
oh. cool. didn't know that. I'm on 1.03, haven't updated for awhile...it will still do that?
yes it does, just tried it out. very cool!
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

ok, so feeding mode isn't strong enough flow. How do I tell it to go to short pulse 53% @ 25 duration when I go into feeding mode?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

You can change the feeding mode speed on the Ecotech driver without having to do any code change. I believe it keeps the mode that you are in.

You can adjust the speed and duration for this mode using the EcoSmart Configuration mode. See Section 4.5: Configuration Mode for instructions on how to do this. The default speed is set to 50% slower than the lowest speed of the pump for a duration of 10 minutes.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

Setting 1: Barely Spinning
Setting 2: 50% lower than lowest speed of pump
Setting 3: lowest speed of pump
Setting 4: 25% speed of pump
Setting 5: 50% speed of pump
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

The only reason I suggest this route is that I like to see my drivers blinking in feeding mode :) You could certainly set it in code, but then you lose the nice light show :D
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

ok, I'll look into that possibility. thank you.
Image
Post Reply