My code - now with RAnet

Share you PDE file with our community
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

I think you already figured out, but just for records...
Your reference to T1 was wrong....
It should be this:

Code: Select all

 ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

rimai wrote:I think you already figured out, but just for records...
Your reference to T1 was wrong....
It should be this:

Code: Select all

 ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
yessir! everything is working so far, have to wait and see about the ATO changes.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

Code: Select all

            if ( ReefAngel.LowATO.IsActive())
            {
                ReefAngel.Relay.On(Port2);
            }
            else
            {
                ReefAngel.Relay.Off(Port2);
for this, how do I require a clear command from RA menu when tripped?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code

Post by lnevo »

Use the SingleATOLow function

Code: Select all

SingleATOLow(Port2);
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

lnevo wrote:Use the SingleATOLow function

Code: Select all

SingleATOLow(Port2);
maybe I'm misunderstanding, I changed it to this:

Code: Select all

ReefAngel.SingleATOLow(Port2);
and it doesn't turn port 2 off, just changes the status on the portal....?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

My code

Post by lnevo »

Did you change that whole section of code? It should go off when the switch is inactive. You may have the switch upside down. Which way is it facing?
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

lnevo wrote:Did you change that whole section of code? It should go off when the switch is inactive. You may have the switch upside down. Which way is it facing?
the wires are facing up. i removed

Code: Select all

   if ( ReefAngel.LowATO.IsActive())
            {
                ReefAngel.Relay.On(Port2);
            }
            else
            {
                ReefAngel.Relay.Off(Port2);
and replaced with

Code: Select all

ReefAngel.SingleATOLow(Port2);
again, maybe I'm misunderstanding, sorry.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

lnevo wrote:It sounds like from what you want is to use the WaterLevelATO and just increase your timeout... or reduce the high/low difference...

I would suggest something like this.. 3 minutes instead of 1.

Code: Select all

ReefAngel.WaterLevelATO( Port7,180,52,58 ); // 180 seconds timeout, turn on at 52% and turn off at 58%
Another thing that will help to put the numbers in a better perspective is.. How long does it take to fill your sump from 52 to 58. That plus a few seconds is what you want your timeout to be.

The code you have everytime it drops to 57 it will turn on till 58 and sometimes the reported level varies from the sensor, so thats why you're seeing on / off / on / off

The other choice is making the numbers smaller. If you want it on at 52%, then leave than and reduce the 58 to something you can get to within 60 seconds.. Say 54%

Code: Select all

ReefAngel.WaterLevelATO( Port7,60,52,54 ); // 60 seconds timeout, turn on at 52% and turn off at 54%
so i changed it back to this format

Code: Select all

ReefAngel.WaterLevelATO( Port7,60,52,54 );
water went from 61% to now 50% and it didn't turn on even for a blip...ideas?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

Are you sure it isn't timed out already?
Just to be sure, can you clear ATO?
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:Are you sure it isn't timed out already?
Just to be sure, can you clear ATO?
the red light was on, I chose clear ATO it started and wouldn't stop. the red light came on again, I cleared again, it still wouldn't turn off. it's now at 61% again. I had to turn off manually.
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>
    /* 
    #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,600,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.LowATO.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()
    {
    }
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

Are you sure you uploaded this code?
It says timeout is 600 seconds. Was your ATO pump on for 600 seconds before it turned the red led again?
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:Are you sure you uploaded this code?
It says timeout is 600 seconds. Was your ATO pump on for 600 seconds before it turned the red led again?

yes, that is the current code.
the red light comes on after 10 mins every time I 'clear ATO' from menu, regardless of the port running or not.
The port did turn itself off at the proper % finally, though.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

So, you are getting ato timeout even when the port is supposed to be off?
You are not overriding it off, are you?
If you do, it would definitely timeout.
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:So, you are getting ato timeout even when the port is supposed to be off?
You are not overriding it off, are you?
If you do, it would definitely timeout.
so, for example, right now, the red light is on. i'll 'clear ato', the water is at 56%, so the port turned on for ATO, the red light came back on ~1-2 mins, i 'clear ato' (the port still on all the while), the port shuts off at 60%.

it's on auto via portal or reboot, not changing to off.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

and now the red light is on again. ~10 mins after I last pressed 'clear ato'

cleared it again, got it ~2 mins later
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

I think you found a bug :)
Can you disconnect the ATO Low float switch and see if the problem is fixed?
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

rimai wrote:I think you found a bug :)
Can you disconnect the ATO Low float switch and see if the problem is fixed?
I unplugged that, rebooted RA, let it sit for 20 mins and now my return pump port 2 just shut off.
but that was also the first time i set port 2 to auto instead of on.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code

Post by bencollinz »

the ATO pump went on and off just as it should without the float switch! and no red light to clear.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

Yeah, just what thought.
The libraries code is sharing the part of the code with the low float switch.
I'll have to update it.
Should be fixed in the next update.
In the mean time, you can use the high ato port for your return.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code

Post by rimai »

Roberto.
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
Post Reply