3 black box (SB Basics) on Dimming Expansion

Do you have a question on how to do something.
Ask in here.

Posts: 81
Joined: Mon Aug 11, 2014 6:45 am
Location: Clermont, Florida
PostPosted: Sun Jul 10, 2016 7:00 am
I have ordered both the dimming expansion, and (3) SB ReefLights basic black boxes. I am upgrading from a 2 channel T5 fixture. My tank is 150 gallon mixed reef, 5x2x2 .

Currently:
I have my Blues turning on/off with local sunrise/sunset, with an hour later offset for better viewing time. My whites are on a 195 minute offset from the actinics. My current moonlights are run by a cheap Walmart timer as I don't have any ports available. I am not addressing moonlights at this time, but will in the future.

What I am wanting to do:
I will have my 3 black boxes running off the dimming expansion. I know I will need to slowly acclimate my tank to these new lights, and I am fine with having to adjust max and reload code as I ramp up intensity over time

Ch0 = Left Blue
Ch1 = Left White
Ch2 = Center Blue
Ch3 = Center White
Ch4 = Right Blue
Ch5 = Right White

I will use Parabolas for all 6 channels, but will want left to start first, then center (30 minutes later?), then right (30 minutes after center?). An East to West effect is what I am going for, the delay time may need to be tweaked and I welcome input here.

I would like clouds to "move" across all 3 lights, but random (selected daily) on left to right, or right to left. To clarify, today all clouds will move east to west, but tomorrow they could move west to east all day. I will also want the variable degree of lightning effects, with the ability to call storms on demand (can this be done with the iPhone app).

I know a lot, if not all of this work has already been done, and I am just starting to work on my code so it will be ready once my lights arrive, and I finish hacking them to work with the dimming expansion. I have been going through the various threads on this subject, but have not found (yet) where someone has applied the logic for 3 lights. I am still very much a novice when it comes to coding.

Any insight is appreciated. Thanks!

Current code below for reference:

Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>
#include <Tide.h>
#include <Moon.h>
#include <WiFiAlert.h>


////// Place global variable code below here
 
  SunLocation sl;
 
  int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;                                    // Color for drawing temperature
      boolean HeatOn = ReefAngel.Relay.Status(Port6);   // Get the status of the heater relay
      if (HeatOn)
      {
        TempColor = COLOR_NAVY;                         // Blue text, too cold, heater is on
      }

      if (!HeatOn)
      {
          TempColor = COLOR_GREEN;                      // Green text, no fan or heater on
      }
      // ***********************************************************************************
             int pHColor;                                 // Color for drawing pH
      boolean LowpH = (ReefAngel.Params.PH < 780) ;     // Check for Low pH Value
      boolean HighpH = (ReefAngel.Params.PH > 850);     // Check for High pH Value
      if (LowpH)
      {
        pHColor = COLOR_NAVY;                          // Blue text, Low pH value
      }
      if (HighpH)   
      {
        pHColor = COLOR_RED;                           // Red text, High pH value
      }
      if (!LowpH && !HighpH)
      {
        pHColor = COLOR_GREEN;                         // Green text, pH acceptable
      }
      // ***********************************************************************************
      ReefAngel.LCD.DrawLargeText(COLOR_DARKSLATEBLUE,DefaultBGColor, 6, 3, " Thunder Reef",Font8x8);   // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                                   // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 12, 132, 12);                                                 // Draw a black line under the banner
      x = 6;
      y += MENU_START_ROW*1.4;                                                                          // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawLargeText(COLOR_BLUE, COLOR_WHITE, x, y+1, " Temp      pH");

      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                                    // Get T1 temp and convert
      x = 2;
      y += MENU_START_ROW*1.6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_BLACK, TempColor, x, y, text);                                // Draw the temperature, white numbers on a colored background
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                               // Get pH reading and convert
      x = 2;
      y = MENU_START_ROW*2.6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_YELLOW, pHColor, x+65, y+6, text);                            // Put pH on the screen
     
      x += 6;
      y += MENU_START_ROW*3.3;
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Sump Level",Font8x8);      // Draw the Sump Float switch status
  if (ReefAngel.LowATO.IsActive())
  {ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  }
  else
  {
  ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
  x += 6;
  y += MENU_START_ROW*2.0;
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Skimmer Cup",Font8x8);     // Draw the Skimmer Cup Float switch status
  if (ReefAngel.HighATO.IsActive()) {ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
  else
  {
  ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  }
     
     
      byte TempRelay = ReefAngel.Relay.RelayData;                                          // Code for drawing the relay box
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);
   }
void DrawCustomGraph()
{
}

unsigned long LastUpdate1=0;    // For virtual dosing pumps

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


void setup()
{
    // This must be the first line
    ReefAngel.Init();                                                                        //Initialize controller
    ReefAngel.Use2014Screen();                                                               // Let's use 2014 Screen
    ReefAngel.FeedingModePorts = Port7Bit;                                                   // Ports toggled in Feeding Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;       // Ports toggled in Water Change Mode
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;                                // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit;   // Ports turned off when Overheat temperature exceeded
    ReefAngel.TempProbe = T1_PROBE;                                                          // Use T1 probe as temperature and overheat functions
    ReefAngel.OverheatProbe = T1_PROBE;
    InternalMemory.OverheatTemp_write( 830 );                                                // Set the Overheat temperature setting


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
   
    // Delayed start for skimmer to allow sump level to return to normal after water change or feed mode
    ReefAngel.Relay.DelayedOn( Port7,4 );

    ////// Place additional initialization code below here
   
    sl.Init(28.5708, -81.6995);    // Lat/long for Clermont, FL
    sl.SetOffset(-3,0,-3,0);       // rise_hour, rise_seconds, set_hour, set_seconds (set 1 hr later for better viewing time)

    randomSeed(now()%SECS_PER_DAY);
     
      //Custom Variable [0] =  Month/Season
   
    ReefAngel.CustomLabels[0]="Return"; 
    ReefAngel.CustomLabels[1]="Daylights"; 
    ReefAngel.CustomLabels[2]="Actinics"; 
    ReefAngel.CustomLabels[3]="Fuge Light"; 
    ReefAngel.CustomLabels[4]="Kalk Dosing"; 
    ReefAngel.CustomLabels[5]="Heater"; 
    ReefAngel.CustomLabels[6]="Skimmer"; 
    ReefAngel.CustomLabels[7]="ATO RoDi"; 


    ////// Place additional initialization code above here
}

void loop()
{
 

    // seasonal temperatures
    SeasonalTemps();

    ReefAngel.DayLights( Port2 );             // ATI DayLights (White+Purple)  On 195 min after sunrise, off 195 min before sunset.
    ReefAngel.ActinicLights( Port3 );         // ATI Actinic+ Lights (Blues).   On at sunrise, off at sunset.
    ReefAngel.MoonLights( Port4 );            // Refugium light.  On 195 min before sunset, off 195 min after sunrise.
    ReefAngel.DosingPumpRepeat( Port5,0,10,22 );
   
    ////// Place your custom code below here

// Kalk Dosing (2 tsp per gal), Port 5.  Between 8pm & 11am, Every 10 minutes run for 22 seconds.
if (hour()>=11 && hour()<20) ReefAngel.Relay.Off(Port5);



// WP-25 powerheads schedule   
if (hour()>=9 && hour()<13)
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(52,12,true) ); // reefcrest at 55% +/- 12% on sync mode       (Day Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(52,12,false) ); // reefcrest at 55% +/- 12% on Anti-sync mode  (Day mode)
}
else if (hour()>=13 && hour()<18)
{
 ReefAngel.PWM.SetDaylight( ShortPulseMode(0,68,408,true) ); // Short pulse at 68% with 408ms pulse on sync mode (3/4" surface wave)
 ReefAngel.PWM.SetActinic( ShortPulseMode(0,68,408,false) ); // Short pulse at 68% with 408ms pulse on Anti-sync mode (3/4" surface wave)
}
else if (hour()>=18 && hour()<19)
{
 ReefAngel.PWM.SetDaylight( LongPulseMode(35,70,2,true) ); // Long Pulse 35% ramping up to 70% for 2 seconds on sync mode (nutrient transport)
 ReefAngel.PWM.SetActinic( LongPulseMode(35,70,2,false) ); // Long Pulse 35% ramping up to 70% for 2 seconds on Anti-sync mode  (nutrient transport)
}
else if (hour()>=19 && hour()<20)
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(52,12,true) ); // reefcrest at 55% +/- 12% on sync mode       (Day Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(52,12,false) ); // reefcrest at 55% +/- 12% on Anti-sync mode  (Day mode)
}
else
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(48,8,true) ); // reefcrest at 48% +/- 8% on sync mode       (night Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(48,8,false) ); // reefcrest at 48% +/- 8% on Anti-sync mode  (night mode)
}
 
if( ReefAngel.DisplayedMenu==FEEDING_MODE )
{
 ReefAngel.PWM.SetActinic( LongPulseMode(0,37,1,true) );
 ReefAngel.PWM.SetDaylight( LongPulseMode(0,37,1,true) );
}

if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE )
{
 ReefAngel.PWM.SetActinic(35);
 ReefAngel.PWM.SetDaylight(35);
}

// enter feeding mode at 11am & 5pm
 if ( (hour()==11 && minute()==0 && second()==0))
 {
 ReefAngel.FeedingModeStart(); // turn on feeding mode
 }
  if ( (hour()==17 && minute()==0 && second()==0))
 {
 ReefAngel.FeedingModeStart(); // turn on feeding mode
 }
 
 
if(ReefAngel.HighATO.IsActive())           //  Float switch in Skimmer Locker
{
ReefAngel.Relay.DelayedOn( Port7,4 );
}
 else
{
 ReefAngel.Relay.Off(Port7);               //  Turn off Skimmer when locker full.
}
 

// ATO, Port 8 is ATO using Clear RoDi

 ReefAngel.SingleATO(true,Port8,400,0);   //  Sump switch.  If ATO/RoDi runs for 400 seconds, then shut off and send alert.




 
  {
    sl.CheckAndUpdate();  // handle updating sunrise and sunset values
  }
 
    ////// Place your custom code above here

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

 void SeasonalTemps ()
 {
  static int heatArray[][2] = { {796,800},                  // default in case of error in month=0 (June)
                    {781,785},//January (winter)            // 78.3
                    {784,788},//February (winter)           // 78.6
                    {787,791},//March (early spring)        // 78.9
                    {790,794},//April (spring)              // 79.2
                    {793,797},//May (spring)                // 79.5
                    {796,800},//June (early summer)         // 79.8
                    {799,803},//July (summer)               // 80.1
                    {802,806},//August (summer)             // 80.4
                    {798,802},//September (early fall)      // 80.0
                    {794,798},//October (fall)              // 79.6
                    {790,794},//November (fall)             // 79.2
                    {786,790} };//December (early winter)   // 78.8
                   
               
  ReefAngel.StandardHeater( Port6,heatArray[month()][0],heatArray[month()][1]);
 }//end seasonalTemps
Image
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Jul 12, 2016 5:25 am
I'm doing east to west effects today with two lights. Wouldn't be that hard to do with 3 (maybe even easier actually in a for loop). Al you need to do is bump the offset for the third light.

I also have a relay bar (virtual only, no actual bar) with presets for different lighting settings and one of those triggers cloud/lightning mode. I do have issues with the current cloud functionality but I havent had time to debug it yet. But everything you've described is in my code.

Posts: 81
Joined: Mon Aug 11, 2014 6:45 am
Location: Clermont, Florida
PostPosted: Tue Jul 12, 2016 3:20 pm
My lights haven't shipped yet, but my dimming expansion should be here Thursday. I am going to get supplies for hacking the lights for RA dimming tomorrow.

Lee, you had mentioned once before about an upgrade that would allow the lights to dim to 0/off, which would free up 2 ports. Do you have any more info on this?

Thanks,
Chris
Image
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Jul 12, 2016 7:41 pm
Are you on Facebook. I can make the introduction online easier...

Posts: 81
Joined: Mon Aug 11, 2014 6:45 am
Location: Clermont, Florida
PostPosted: Sat Jul 16, 2016 12:10 am
Ok, Let me break this into pieces.

Can someone help me with code for this part?

Ch0 = Left Blue
Ch1 = Left White
Ch2 = Center Blue
Ch3 = Center White
Ch4 = Right Blue
Ch5 = Right White

I will use Parabolas for all 6 channels, but will want left to start first, then center (30 minutes later?), then right (30 minutes after center?). An East to West effect is what I am going for, the delay time may need to be tweaked and I welcome input here.

Relays
(port3) // (blues) will turn on at sunrise
(port2) // (Whites) will turn on 150 minutes after sunrise

Dimming Expansion
Ch0 to start parabola (5%-40%) at sunrise, and end 1 hour before sunset
Ch2 to start parabola (5%-40%) 30 minutes after sunrise, and end 30 minutes before sunset
Ch4 to start parabola (5%-40%) 1 hour after sunrise, and end at sunset

Ch1 to start parabola (5%-18%) 150 minutes after sunrise, and end 210 minutes before sunset
Ch3 to start parabola (5%-18%) 180 minutes after sunrise, and end 180 minutes before sunset
Ch5 to start parabola (5%-18%) 210 minutes after sunrise, and end 150 minutes before sunset

I can work on the weather portion later, but this will get me started. Thank you very much in advance! :)
Image
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sat Jul 16, 2016 2:03 am
Ok, go into the portal and make sure a few things are set in the Internal Memory section.

First go into the first section for Time Schedule and make sure that your Start and End times match the Sunrise/Sunet you are looking for. This should be getting set by the SunLocation if you're using it.

Lastly go to the Dimming Expansion screen and in there you can set the start and end % for each channel that you want. You can adjust this as you see fit without having to reload your code :)

Code: Select all
ReefAngel.PWM.Channel0PWMParabola(0,60); // Actinic Left
ReefAngel.PWM.Channel2PWMParabola(30,30); // Actinic Center
ReefAngel.PWM.Channel4PWMParabola(60,0); // Actinic Center

ReefAngel.PWM.Channel1PWMParabola(150,210); // Daylight Left
ReefAngel.PWM.Channel3PWMParabola(180,180); // Daylight Center     
ReefAngel.PWM.Channel5PWMParabola(210,150); // Daylight Center

// Turn Actinic outlet on if any % is >= 10
(ReefAngel.PWM.GetChannelValue(0)>=10 || ReefAngel.PWM.GetChannelValue(2)>=10 || ReefAngel.PWM.GetChannelValue(4)>=10) ?  ReefAngel.Relay.On(WhiteLED) :  ReefAngel.Relay.Off(WhiteLED);

// Turn Daylight outlet on if any % is >=10   
(ReefAngel.PWM.GetChannelValue(1)>=10 || ReefAngel.PWM.GetChannelValue(3)>=10 || ReefAngel.PWM.GetChannelValue(5)>=10) ?  ReefAngel.Relay.On(BlueLED) : ReefAngel.Relay.Off(BlueLED);

Posts: 81
Joined: Mon Aug 11, 2014 6:45 am
Location: Clermont, Florida
PostPosted: Sat Jul 16, 2016 5:41 pm
Do I leave this portion in my code, or will the new code replace it?

Code: Select all
    ReefAngel.DayLights( Port2 );  // (Whites)  On 150 min after sunrise, off 150 min before sunset.
    ReefAngel.ActinicLights( Port3 );  // (Blues) On at sunrise, off at sunset.
    ReefAngel.MoonLights( Port4 );  // Refugium light.  Opposite Whites.
   
Image

Posts: 81
Joined: Mon Aug 11, 2014 6:45 am
Location: Clermont, Florida
PostPosted: Sat Jul 16, 2016 5:53 pm
I think I answered my own question. Is 10% the lowest the SB Light will actually dim to? I can raise my lights from 3" to 16" above water level. I am planning on initially setting them around 14". What ramping schedule has been working, 5% increase a week until you find the sweet spot?

Here is my code as modified.

Code: Select all
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>
#include <RA_ATO.h>
#include <RA_Joystick.h>
#include <LED.h>
#include <RA_TempSensor.h>
#include <Relay.h>
#include <RA_PWM.h>
#include <Timer.h>
#include <Memory.h>
#include <InternalEEPROM.h>
#include <RA_Colors.h>
#include <RA_CustomColors.h>
#include <Salinity.h>
#include <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <Humidity.h>
#include <DCPump.h>
#include <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>
#include <Tide.h>
#include <Moon.h>
#include <WiFiAlert.h>


////// Place global variable code below here
 
  SunLocation sl;
 
  int avgph[10];
    unsigned long totalavgph=0;
    byte avgindex=0;

void DrawCustomMain()
    {
      byte x;
      byte y = 2;
      char text[7];

      // *********** CHANGE TEMP READOUT COLOR DEPENDENT ON FAN AND HEATER STATUS ***********
      int TempColor;                                    // Color for drawing temperature
      boolean HeatOn = ReefAngel.Relay.Status(Port6);   // Get the status of the heater relay
      if (HeatOn)
      {
        TempColor = COLOR_NAVY;                         // Blue text, too cold, heater is on
      }

      if (!HeatOn)
      {
          TempColor = COLOR_GREEN;                      // Green text, no fan or heater on
      }
      // ***********************************************************************************
             int pHColor;                                 // Color for drawing pH
      boolean LowpH = (ReefAngel.Params.PH < 780) ;     // Check for Low pH Value
      boolean HighpH = (ReefAngel.Params.PH > 850);     // Check for High pH Value
      if (LowpH)
      {
        pHColor = COLOR_NAVY;                          // Blue text, Low pH value
      }
      if (HighpH)   
      {
        pHColor = COLOR_RED;                           // Red text, High pH value
      }
      if (!LowpH && !HighpH)
      {
        pHColor = COLOR_GREEN;                         // Green text, pH acceptable
      }
      // ***********************************************************************************
      ReefAngel.LCD.DrawLargeText(COLOR_DARKSLATEBLUE,DefaultBGColor, 6, 3, " Thunder Reef",Font8x8);   // Put a banner at the top
      ReefAngel.LCD.DrawDate(6, 119);                                                                   // Put the date and time at the bottom
      ReefAngel.LCD.Clear(COLOR_BLACK, 1, 12, 132, 12);                                                 // Draw a black line under the banner
      x = 6;
      y += MENU_START_ROW*1.4;                                                                          // MENU_START_ROW is 10, according to globals.h, so y=2+10+1=13
      ReefAngel.LCD.DrawLargeText(COLOR_BLUE, COLOR_WHITE, x, y+1, " Temp      pH");

      ConvertNumToString(text, ReefAngel.Params.Temp[T1_PROBE], 10);                                    // Get T1 temp and convert
      x = 2;
      y += MENU_START_ROW*1.6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_BLACK, TempColor, x, y, text);                                // Draw the temperature, white numbers on a colored background
      ConvertNumToString(text, ReefAngel.Params.PH, 100);                                               // Get pH reading and convert
      x = 2;
      y = MENU_START_ROW*2.6;
      ReefAngel.LCD.DrawHugeNumbers(COLOR_YELLOW, pHColor, x+65, y+6, text);                            // Put pH on the screen
     
      x += 6;
      y += MENU_START_ROW*3.3;
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Sump Level",Font8x8);      // Draw the Sump Float switch status
  if (ReefAngel.LowATO.IsActive())
  {ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  }
  else
  {
  ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
  x += 6;
  y += MENU_START_ROW*2.0;
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,25,y,"Skimmer Cup",Font8x8);     // Draw the Skimmer Cup Float switch status
  if (ReefAngel.HighATO.IsActive()) {ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_GREEN);
  }
  else
  {
  ReefAngel.LCD.FillCircle(15,y+3,7,COLOR_RED);
  }
     
     
      byte TempRelay = ReefAngel.Relay.RelayData;                                          // Code for drawing the relay box
      TempRelay &= ReefAngel.Relay.RelayMaskOff;
      TempRelay |= ReefAngel.Relay.RelayMaskOn;
      ReefAngel.LCD.DrawOutletBox(12, 100, TempRelay);
   }
void DrawCustomGraph()
{
}



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


void setup()
{
    // This must be the first line
    ReefAngel.Init();                                                                        //Initialize controller
    ReefAngel.Use2014Screen();                                                               // Let's use 2014 Screen
    ReefAngel.FeedingModePorts = Port7Bit;                                                   // Ports toggled in Feeding Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;       // Ports toggled in Water Change Mode
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit;                                // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port3Bit | Port4Bit | Port6Bit | Port7Bit;   // Ports turned off when Overheat temperature exceeded
    ReefAngel.TempProbe = T1_PROBE;                                                          // Use T1 probe as temperature and overheat functions
    ReefAngel.OverheatProbe = T1_PROBE;
    InternalMemory.OverheatTemp_write( 830 );                                                // Set the Overheat temperature setting


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
   
    // Delayed start for skimmer to allow sump level to return to normal after water change
    ReefAngel.Relay.DelayedOn( Port7,4 );

    ////// Place additional initialization code below here
   
    sl.Init(28.5708, -81.6995);    // Lat/long for Clermont, FL
    sl.SetOffset(-3,0,-3,0);       // rise_hour, rise_seconds, set_hour, set_seconds (set 1 hr later for better viewing time)

    randomSeed(now()%SECS_PER_DAY);
     
      //Custom Variable [0] =  Month/Season
   
    ReefAngel.CustomLabels[0]="Return"; 
    ReefAngel.CustomLabels[1]="Daylights"; 
    ReefAngel.CustomLabels[2]="Actinics"; 
    ReefAngel.CustomLabels[3]="Fuge Light"; 
    ReefAngel.CustomLabels[4]="Alk Dosing"; 
    ReefAngel.CustomLabels[5]="Heater"; 
    ReefAngel.CustomLabels[6]="Skimmer"; 
    ReefAngel.CustomLabels[7]="ATO RoDi"; 


    ////// Place additional initialization code above here
}

void loop()
{
 

    // seasonal temperatures
    SeasonalTemps();


ReefAngel.PWM.Channel0PWMParabola(0,60);     // Actinic Left
ReefAngel.PWM.Channel2PWMParabola(30,30);    // Actinic Center
ReefAngel.PWM.Channel4PWMParabola(60,0);     // Actinic Right

ReefAngel.PWM.Channel1PWMParabola(150,210);  // Daylight Left
ReefAngel.PWM.Channel3PWMParabola(180,180);  // Daylight Center     
ReefAngel.PWM.Channel5PWMParabola(210,150);  // Daylight Right

// Turn Actinic outlet on if any % is >= 10
(ReefAngel.PWM.GetChannelValue(0)>=10 || ReefAngel.PWM.GetChannelValue(2)>=10 || ReefAngel.PWM.GetChannelValue(4)>=10) ?  ReefAngel.Relay.On(Port2) :  ReefAngel.Relay.Off(Port2);

// Turn Daylight outlet on if any % is >=10   
(ReefAngel.PWM.GetChannelValue(1)>=10 || ReefAngel.PWM.GetChannelValue(3)>=10 || ReefAngel.PWM.GetChannelValue(5)>=10) ?  ReefAngel.Relay.On(Port3) : ReefAngel.Relay.Off(Port3);

ReefAngel.MoonLights( Port4 );  // Refugium light.  Opposite Whites.

ReefAngel.DosingPumpRepeat( Port5,0,10,17 );
   
    ////// Place your custom code below here

// Kalk Dosing (2 tsp per gal), Port 5.  Between 9pm & 9am, Every 10 minutes run for 17 seconds.
if (hour()>=9 && hour()<21) ReefAngel.Relay.Off(Port5);



// WP-25 powerheads schedule   
if (hour()>=9 && hour()<13)
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(52,12,true) ); // reefcrest at 55% +/- 12% on sync mode       (Day Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(52,12,false) ); // reefcrest at 55% +/- 12% on Anti-sync mode  (Day mode)
}
else if (hour()>=13 && hour()<18)
{
 ReefAngel.PWM.SetDaylight( ShortPulseMode(0,68,408,true) ); // Short pulse at 68% with 408ms pulse on sync mode (3/4" surface wave)
 ReefAngel.PWM.SetActinic( ShortPulseMode(0,68,408,false) ); // Short pulse at 68% with 408ms pulse on Anti-sync mode (3/4" surface wave)
}
else if (hour()>=18 && hour()<19)
{
 ReefAngel.PWM.SetDaylight( LongPulseMode(35,70,2,true) ); // Long Pulse 35% ramping up to 70% for 2 seconds on sync mode (nutrient transport)
 ReefAngel.PWM.SetActinic( LongPulseMode(35,70,2,false) ); // Long Pulse 35% ramping up to 70% for 2 seconds on Anti-sync mode  (nutrient transport)
}
else if (hour()>=19 && hour()<20)
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(52,12,true) ); // reefcrest at 55% +/- 12% on sync mode       (Day Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(52,12,false) ); // reefcrest at 55% +/- 12% on Anti-sync mode  (Day mode)
}
else
{
 ReefAngel.PWM.SetDaylight( ReefCrestMode(48,8,true) ); // reefcrest at 48% +/- 8% on sync mode       (night Mode)
 ReefAngel.PWM.SetActinic( ReefCrestMode(48,8,false) ); // reefcrest at 48% +/- 8% on Anti-sync mode  (night mode)
}
 
if( ReefAngel.DisplayedMenu==FEEDING_MODE )
{
 ReefAngel.PWM.SetActinic( LongPulseMode(0,37,1,true) );
 ReefAngel.PWM.SetDaylight( LongPulseMode(0,37,1,true) );
}

if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE )
{
 ReefAngel.PWM.SetActinic(35);
 ReefAngel.PWM.SetDaylight(35);
}

// enter feeding mode at 11am & 5pm
 if ( (hour()==11 && minute()==0 && second()==0))
 {
 ReefAngel.FeedingModeStart(); // turn on feeding mode
 }
  if ( (hour()==17 && minute()==0 && second()==0))
 {
 ReefAngel.FeedingModeStart(); // turn on feeding mode
 }
 
 
if(ReefAngel.HighATO.IsActive())           //  Float switch in Skimmer Locker
{
ReefAngel.Relay.DelayedOn( Port7,4 );
}
 else
{
 ReefAngel.Relay.Off(Port7);               //  Turn off Skimmer when locker full.
}
 

// ATO, Port 8 is ATO using Clear RoDi

 ReefAngel.SingleATO(true,Port8,400,0);   //  Sump switch.  If ATO/RoDi runs for 400 seconds, then shut off and send alert.




 
  {
    sl.CheckAndUpdate();  // handle updating sunrise and sunset values
  }
 
    ////// Place your custom code above here

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

 void SeasonalTemps ()
 {
  static int heatArray[][2] = { {796,800},                  // default in case of error in month=0 (June)
                    {781,785},//January (winter)            // 78.3
                    {784,788},//February (winter)           // 78.6
                    {787,791},//March (early spring)        // 78.9
                    {790,794},//April (spring)              // 79.2
                    {793,797},//May (spring)                // 79.5
                    {796,800},//June (early summer)         // 79.8
                    {799,803},//July (summer)               // 80.1
                    {802,806},//August (summer)             // 80.4
                    {798,802},//September (early fall)      // 80.0
                    {794,798},//October (fall)              // 79.6
                    {790,794},//November (fall)             // 79.2
                    {786,790} };//December (early winter)   // 78.8
                   
               
  ReefAngel.StandardHeater( Port6,heatArray[month()][0],heatArray[month()][1]);
 }//end seasonalTemps
Image
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sun Jul 17, 2016 2:18 pm
Few % a week is good. There's recommendation in the files section. Set the height for best coverage and then use % to get right levels. YMMV on the dimming but I was able to get measurable par down to 7% on the analog ones and the pwm shut off between 10-15% but I heard thats tuneable..gotta try
User avatar
Posts: 5356
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Sun Jul 17, 2016 2:24 pm
And yes you can remove the Daylight Ports. The nice thing with the code I gave to turn the relays on, if you override dimming when lights are out they will come on :)
Next

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 1 guest

cron