My code - now with RAnet

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

My code - now with RAnet

Post by bencollinz »

ReefAngel Plus with RAnet relay expansion, Vortech, Salinity, pH, Temp, wifi, RAnet pwm, water level and ATO
Last edited by bencollinz on Wed Jan 07, 2015 3:02 pm, edited 5 times in total.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

This post will always be my most current code

09/24/2015

Code: Select all

        #include <SoftwareSerial.h>
    #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 <RA_Colors.h>
    #include <RA_CustomColors.h>
    #include <Salinity.h>
    #include <RF.h>
    #include <IO.h>
    #include <ORP.h>
    #include <AI.h>
    #include <PH.h>
    #include <WaterLevel.h>
    #include <Humidity.h>
    #include <DCPump.h>
    #include <PAR.h>
    #include <ReefAngel.h>
    /* 
    #define Heater      1
    #define Return      2
    #define             3
    #define Skimmer     4
    #define Vortech1    5
    #define Vortech2    6
    #define ATO         7 
    #define Sump Light  8
    */
    ////// Place global variable code below here
byte vtechmode, vtSpeed, vtDuration;
    ////// 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 = 0;
        ReefAngel.FeedingModePortsE[0] = Port2Bit;
        // Ports toggled in Water Change Mode
        ReefAngel.WaterChangePorts = 0;
        ReefAngel.WaterChangePortsE[0] = 0;
        // Ports toggled when Lights On / Off menu entry selected
        ReefAngel.LightsOnPorts = 0;
        ReefAngel.LightsOnPortsE[0] = 0;
        // Ports turned off when Overheat temperature exceeded
        ReefAngel.OverheatShutoffPorts = 0;
        ReefAngel.OverheatShutoffPortsE[0] = Port1Bit | Port2Bit;
        // Use T1 probe as temperature and overheat functions
        ReefAngel.TempProbe = T1_PROBE;
        ReefAngel.OverheatProbe = T1_PROBE;
        // Set the Overheat temperature setting
        InternalMemory.OverheatTemp_write( 830 );
        ReefAngel.AddRANet();


        // Ports that are always on
        ReefAngel.Relay.On( Port2 );
        ReefAngel.Relay.On( Port3 );
        ReefAngel.Relay.On( Port4 );
        ReefAngel.Relay.On( Port5 );
        ReefAngel.Relay.On( Port6 );
        ReefAngel.Relay.On( Port7 );
        ReefAngel.Relay.On( Port8 );
        ReefAngel.Relay.On( Box1_Port1 );
        ReefAngel.Relay.On( Box1_Port2 );
        ReefAngel.Relay.On( Box1_Port3 );
        ReefAngel.Relay.On( Box1_Port4 );
        ReefAngel.Relay.On( Box1_Port5 );
        ReefAngel.Relay.On( Box1_Port6 );
        ReefAngel.Relay.On( Box1_Port7 );
        ReefAngel.Relay.On( Box1_Port8 );
      

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

    void loop()
    {
    vtechmode=InternalMemory.RFMode_read();
    vtSpeed=InternalMemory.RFSpeed_read();
    vtDuration=InternalMemory.RFDuration_read();

    static unsigned long feeding;
    ReefAngel.StandardHeater( Port1,778,782 );
      //  ReefAngel.WaterLevelATO( Port7,180,71,74 );
    //    ReefAngel.StandardLights( Port8,15,0,2,0 );
        ReefAngel.PWM.SetChannel( 0,PWMSlope(13,40,21,00,0,0,40,0) );  //LIME
        ReefAngel.PWM.SetChannel( 1,PWMSlope(13,40,22,00,15,100,30,0) );  //RB
        ReefAngel.PWM.SetChannel( 2,PWMSlope(13,40,21,00,15,100,30,0) ); //WHITE
        ReefAngel.PWM.SetChannel( 3,PWMSlope(13,40,21,00,15,80,30,0) );  //BLUE&CYAN
        ReefAngel.PWM.SetChannel( 4,PWMSlope(13,40,21,00,15,80,30,0) ); //UV
        
        if ( ReefAngel.HighATO.IsActive())
        {
          ReefAngel.Relay.On(Port2);
        }
        else
        {
          ReefAngel.Relay.Off(Port2);
        }
        
if (now() % 10800 == 0 ) while(1);
if (hour() >=12 && hour() < 21)
      {
        // if (ReefAngel.RF.Mode==Night) ReefAngel.RF.SetMode(Feeding_Stop,0,0);
        ReefAngel.RF.UseMemory=true;
        // ReefAngel.RF.SetMode(ReefCrest,60,20);
        if (ReefAngel.DisplayedMenu==FEEDING_MODE)
            {
             feeding=now();
             }
             if (now()-feeding<5400) {
            // if (now()-feeding > 1 && now()-feeding < 5400) { // 1 second after feeding mode until 90 minutes after feeding mode.
  ReefAngel.RF.UseMemory=false;
    ReefAngel.RF.SetMode(Smart_NTM,75,10);
    } 
           }
      else
      {
        ReefAngel.RF.UseMemory=false;
        ReefAngel.RF.SetMode(Constant,10,0);
       }
         if (vtechmode!=InternalMemory.RFMode_read())
          InternalMemory.RFMode_write(vtechmode);
         if (vtSpeed!=InternalMemory.RFSpeed_read())
          InternalMemory.RFSpeed_write(vtSpeed);
         if (vtDuration!=InternalMemory.RFDuration_read())
          InternalMemory.RFDuration_write(vtDuration);

        // 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(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,4,30,"RF Speed:");
  ReefAngel.LCD.Clear(255,59,29,128,39);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,71,31,vtSpeed);
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,90,31,"/");
  ReefAngel.LCD.DrawText(COLOR_BLUE, DefaultBGColor,100,31,vtDuration);
  
  ReefAngel.LCD.DrawText(0,255,10,40,"Salt");
  ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(COLOR_INDIANRED, 255, 10, 50, text, Num8x8);
  pingSerial();

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

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

  // water level
    ReefAngel.LCD.DrawText(0,255,68,58,"WL");
    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 68, 68, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();

       // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 108, TempRelay );
        pingSerial();
         // Relay Expansion
        TempRelay = ReefAngel.Relay.RelayDataE[0];
        TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
       TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
       ReefAngel.LCD.DrawOutletBox( 12, 120, TempRelay );
        pingSerial();
     
    }
    
    void DrawCustomGraph()
    {
    }
 
 
Last edited by bencollinz on Thu Sep 24, 2015 5:15 am, edited 16 times in total.
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

I'm uploading to internal memory btw
Image
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

and my damn heater temps as well...I'm lost.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Did you try going with hard coded settings to get familiar?
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:Did you try going with hard coded settings to get familiar?
this better?

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


    ////// 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 PH calibrations
		ReefAngel.PHMin=576; // PH7.0
		ReefAngel.PHMax=842; // PH10.0
        ////// Place additional initialization code above here
    }

    void loop()
    {
        ReefAngel.StandardHeater( Port1,796,802 );
        ReefAngel.WaterLevelATO( Port7,60,52,58 ); // 60 seconds timeout, turn on at 52% and turn off at 58%
        ReefAngel.PWM.SetChannel( 0, MoonPhase() );
        ReefAngel.PWM.Channel1PWMParabola();
        ReefAngel.PWM.Channel2PWMParabola();
        ReefAngel.PWM.Channel3PWMParabola();
        ReefAngel.PWM.Channel4PWMSlope();
        ReefAngel.RF.UseMemory = true;
        ////// Place your custom code below here
       

        ////// Place your custom code above here

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

    void DrawCustomMain()
    {
        int x,y;
        char text[10];
        // Dimming Expansion
        x = 15;
        y = 2;
        for ( int a=0;a<6;a++ )
        {
          if ( a>2 ) x = 75;
          if ( a==3 ) y = 2;
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
          y += 10;
        }
        pingSerial();

        // Parameters
    #if defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 35, ReefAngel.Params,
        ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
    #else // defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 35, ReefAngel.Params );
    #endif // defined DisplayLEDPWM && ! defined RemoveAllLights
        pingSerial();

        // Salinity
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,68, "SAL:" );
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,68, ReefAngel.Params.Salinity );
        pingSerial();

        // pH Expansion
        // ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,82, "PHE:" );
        // ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,39,82, ReefAngel.Params.PHExp );
        // pingSerial();

        // Water Level
        ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,82, "WL:" );
        ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,82, ReefAngel.WaterLevel.GetLevel() );
        pingSerial();

        // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 95, TempRelay );
        pingSerial();

        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 122 );
        pingSerial();
    }

    void DrawCustomGraph()
    {
    }
Can I hard code the SALINITY calibration as well?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Yes, looks good.
You can hardcode sal calibration like this:

Code: Select all

      ReefAngel.SalMax=2250; // 35ppt
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:Yes, looks good.
You can hardcode sal calibration like this:

Code: Select all

      ReefAngel.SalMax=2250; // 35ppt
should I use 2250 or 2998 that shows on the controller when I calibrate with fluid?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Yeah, whatever number you have it when calibrating.
I'm just trying to show you how to do it.
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

so i'm using this code now...

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


    ////// 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 PH 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,60,52,58 ); // 60 seconds timeout, turn on at 52% and turn off at 58%
        ReefAngel.PWM.SetChannel( 0, MoonPhase() );
        ReefAngel.PWM.Channel1PWMParabola();
        ReefAngel.PWM.Channel2PWMParabola();
        ReefAngel.PWM.Channel3PWMParabola();
        ReefAngel.PWM.Channel4PWMSlope();
        ReefAngel.RF.UseMemory = true;
        ////// Place your custom code below here
       

        ////// Place your custom code above here

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

    void DrawCustomMain()
    {
        int x,y;
        char text[10];
        // Dimming Expansion
        x = 15;
        y = 2;
        for ( int a=0;a<6;a++ )
        {
          if ( a>2 ) x = 75;
          if ( a==3 ) y = 2;
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
          ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
          y += 10;
        }
        pingSerial();

        // Parameters
    #if defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 35, ReefAngel.Params,
        ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
    #else // defined DisplayLEDPWM && ! defined RemoveAllLights
        ReefAngel.LCD.DrawMonitor( 15, 35, ReefAngel.Params );
    #endif // defined DisplayLEDPWM && ! defined RemoveAllLights
        pingSerial();

        // Salinity
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,68, "SAL:" );
        ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,68, ReefAngel.Params.Salinity );
        pingSerial();

        // pH Expansion
        // ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,82, "PHE:" );
        // ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,39,82, ReefAngel.Params.PHExp );
        // pingSerial();

        // Water Level
        ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,82, "WL:" );
        ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,82, ReefAngel.WaterLevel.GetLevel() );
        pingSerial();

        // Main Relay Box
        byte TempRelay = ReefAngel.Relay.RelayData;
        TempRelay &= ReefAngel.Relay.RelayMaskOff;
        TempRelay |= ReefAngel.Relay.RelayMaskOn;
        ReefAngel.LCD.DrawOutletBox( 12, 95, TempRelay );
        pingSerial();

        // Date and Time
        ReefAngel.LCD.DrawDate( 6, 122 );
        pingSerial();
    }

    void DrawCustomGraph()
    {
    }
it makes a red light on the RA controller come on, until I choose clear ATO from the menu but then it unchooses auto and on goes to on. if I change it back to auto via portal I get the red light again and it stops working.

advice?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Does the red light turns on immediately or it turns on after 60 seconds?
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:Does the red light turns on immediately or it turns on after 60 seconds?
ok, so I unplugged RA and plugged back in. no red light. ATO is on auto per portal. water level is at 55 currently, so it should be running but it's not.

I turn it to on manually, it doesn't shut off when it hits 60 seconds or 58% water level. If I set it back to auto it stays off.

the portal still says water is 55% but RA says 59%

unfortunately, I couldn't reproduce the red light issue now.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

It won't turn on until it reaches 52%. That's what you set it at.
It turns on at 52% and off at 58%.
So, when the level does get to 52, you have 60 seconds to pump water until it hits 58% or the timeout will happen and disable the ATO. This is a safety feature to prevent overflow. That's when the red light goes on, indicating an ATO timeout.
So, I think you are using too high of a range and too low of a timeout. Can you pump that much water in 60 seconds?
It will never shut off if you turn on manually. That's what we call override. You are forcing an on position situation no matter what the controller thinks it should be.
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:It won't turn on until it reaches 52%. That's what you set it at.
It turns on at 52% and off at 58%.
So, when the level does get to 52, you have 60 seconds to pump water until it hits 58% or the timeout will happen and disable the ATO. This is a safety feature to prevent overflow. That's when the red light goes on, indicating an ATO timeout.
So, I think you are using too high of a range and too low of a timeout. Can you pump that much water in 60 seconds?
It will never shut off if you turn on manually. That's what we call override. You are forcing an on position situation no matter what the controller thinks it should be.
I found this is someone else's thread http://forum.reefangel.com/viewtopic.ph ... ion#p14563

Code: Select all

  // 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);
can I use that instead?
or does it still need a timeout, just in case?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Yeah, you can use that.
Roberto.
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

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 PH 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,60,52,58 ); // 60 seconds timeout, turn on at 52% and turn off at 58%
        // 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.Channel1PWMParabola();
        ReefAngel.PWM.Channel2PWMParabola();
        ReefAngel.PWM.Channel3PWMParabola();
        ReefAngel.PWM.Channel4PWMSlope();
        ReefAngel.RF.UseMemory = true;
            if ( ReefAngel.LowATO.IsActive())
            {
                ReefAngel.Relay.On(Port2);
            }
            else
            {
                ReefAngel.Relay.Off(Port2);
            }
        if (hour() <= 8 && hour() >= 20)
            {
            ReefAngel.PWM.SetChannel( 0, MoonPhase() );
            ReefAngel.RF.UseMemory=false;
            ReefAngel.RF.SetMode(Night,15,0);
            vtechmode = 9;
            }
        else
             {
             ReefAngel.RF.UseMemory=true;
             vtechmode = InternalMemory.RFMode_read();
             ReefAngel.PWM.SetChannel( 0, MoonPhase(0) );
             }


        // 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, "--------------------");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 93, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 103, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 113, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 123, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 93, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 103, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 113, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 123, "|");

  ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
  ConvertNumToString(text, ReefAngel.Params.[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, 100);
  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, 40, 68, 10, ReefAngel.WaterLevel.GetLevel() );
    pingSerial();


    }

    void DrawCustomGraph()
    {
    }
so this makes my ATO PORT 7 just continually cycle instead of remaining on until it reaches the proper %. what am I doing incorrect?

and I can't get water level to display on screen, what's wrong there?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: My code - water level ATO help needed

Post by rimai »

Your coordinates are wrong.
It's printing at coordinates x=68 and y=10.
I think you what you want is this:

Code: Select all

    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
The code you are using does just that. It will turn on whenever the level goes below 58. There is no hysteresis.
If you want hysteresis, you need to use the previous function you were using before. The one you commented out.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: My code - water level ATO help needed

Post by lnevo »

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%
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

now I get this...
Untitled4.jpg
Untitled4.jpg (143.74 KiB) Viewed 10410 times

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 PH 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,55,58 ); // 60 seconds timeout, turn on at 55% and turn off at 58%
        // 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();
            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, "--------------------");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 93, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 103, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 113, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 2, 123, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 93, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 103, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 113, "|");
        ReefAngel.LCD.DrawText(COLOR_TOMATO,255, 126, 123, "|");

  ReefAngel.LCD.DrawText(0,255,10,30,"Temp");
  ConvertNumToString(text, ReefAngel.Params.[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
bencollinz
Posts: 151
Joined: Wed Mar 13, 2013 5:36 pm

Re: My code - water level ATO help needed

Post by bencollinz »

rimai wrote:Your coordinates are wrong.
It's printing at coordinates x=68 and y=10.
I think you what you want is this:

Code: Select all

    ReefAngel.LCD.DrawText( COLOR_CORNFLOWERBLUE,255, 40, 68, ReefAngel.WaterLevel.GetLevel() );
.
Thank you, that worked!
Image
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
Post Reply