Reefology's code

Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

this is awesome, im in love with my reef angel and what it is capable of...

now that i have my dc pump up and running, I'm going back to something i put on hold, can someone please look at the code i just put up and tell me why i still cant log into the iphone app using my DDNS?

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

Re: Reefology's code

Post by rimai »

Make sure you enter reefology-ddns.myreefangel.com
Change the ddns to whatever you choose. Make sure it is - and not _
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Thanks Roberto but I've checked it too many times to count. Are there other possibilities?
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

PM me what you are entering. I checked the server and the entries are all there.
I saw 3 entries for you, but they were all same ip address.
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

pm sent
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

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 <Humidity.h>
#include <DCPump.h>
#include <PAR.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
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port5Bit | Port6Bit | Port7Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on

    ////// Place additional initialization code below here
    
    // Password Protection username:xxxx password:xxxx
    // ReefAngel.Network.WifiAuthentication("xxxx"); 

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

void loop()
{
    ReefAngel.DosingPumpRepeat1( Port1 );
    ReefAngel.MoonLights( Port2 );
    ReefAngel.ActinicLights( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.WavemakerRandom1( Port5,120,1500 );
    ReefAngel.WavemakerRandom2( Port6,180,1000 );
    ReefAngel.StandardHeater( Port7 );
    ReefAngel.DosingPumpRepeat2( Port8 );
    ReefAngel.DCPump.ActinicChannel = AntiSync; // Now pump will be affected by the portal settings
    // Comment out next 2 lines for single dc pump
    // ReefAngel.DCPump.DaylightChannel = Sync; // Now pump will be affected by the portal settings
    // ReefAngel.DCPump.AntiSyncOffset=100; 
    
    ////// Place your custom code below here
    
  // Wavemaker Koralia night mode
    if (hour()>=22 || hour()<7) ReefAngel.Relay.Off (Port5 );
    if (hour()>=23 || hour()<8) ReefAngel.Relay.Off (Port6 );
   
  // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3000) {
    // Continue NutrientTranspot Mode for 45 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }

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

    // This should always be the last line
    ReefAngel.Portal( "Reefology" );
    ReefAngel.DDNS("xxxx"); // Your DDNS is Reefology-xxxx.myreefangel.com
    ReefAngel.ShowInterface();
}

Have another dc pump coming and just want to makes sure i'm ready with code.
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

// Comment out next 2 lines for single dc pump
// ReefAngel.DCPump.DaylightChannel = Sync; // Now pump will be affected by the portal settings
// ReefAngel.DCPump.AntiSyncOffset=100;

do i just change this?
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

and does the antisync offset delay 2nd pump by 100 seconds?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reefology's code

Post by lnevo »

No, it allows the antisync channel to be 100% of what it should be. If you have a strong or weaker pump, you could adjust that pump to compensate.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

sorry, i don't understand.

so if i have a Jebao wp40 and a wp25, how would i use the offset?

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

Re: Reefology's code

Post by lnevo »

What do you want to do with them...if you want to speed one up or slow one down? Which is currently sync/antisync?
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Yup, that's what I want. So do I remove the offset then? Leave it at 100? Or change it to some other figure?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reefology's code

Post by lnevo »

I gave you two choices...you answered yup. If you want to speed up the antisync channel then make it 125 for a 25% increase. Or make it 75 for a 25% decrease on the one set to antisync
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

thanks for the info Lee :)

i answered "yup" because i'd like to know how to manipulate the fields/data going forward, don't just want to rely on you guys to write code for me (though at times i need you to and certainly do appreciate it). sorry for the confusion :P
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Reefology's code

Post by lnevo »

No worries just confusing. All good now
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Hi all,

How do I figure out why I can't upload a sketch when it complies just fine?

This is the error message I'm getting:

avrdude: stk500v2_ReceiveMessage(): timeout

Same message I get when try to upload without cable. Can it be a cable issue? It seemed to work yesterday to upload wifitestcode? Sort of...
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

Make sure you are connecting the cable correctly on RA. It should be all the way to the right and you should have 2 pins unconnected on the left.
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Hi Roberto,

Yes thanks, I've uploaded sketches many times so it's definitely not that. Any other ideas?
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Code: Select all

 // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3000) {
    // Continue NutrientTranspot Mode for 45 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
hi, based on the code above, I don't understand why my pwm channels have been at 0 for the past 45 mins? can someone help me figure out what I've done wrong? thanks
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Code: Select all

 // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3000) {
    // Continue NutrientTranspot Mode for 45 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
hi, based on the code above, I don't understand why my pwm channels have been at 0 for the past 45 mins? can someone help me figure out what I've done wrong? thanks
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Code: Select all

 // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { NutrientTransport, Sine, ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%1200==0 || changeMode==true) { // Change every 20 (1200seconds) mins or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    if (now()-feeding<3000) {
    // Continue NutrientTranspot Mode for 45 minutes
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    } else if (now()%SECS_PER_DAY<37800 || now()%SECS_PER_DAY>=81000) { // 10:30am / 10:30pm
    // Night mode (go to 30%)
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
hi, based on the code above, I don't understand why my pwm channels have been at 0 for the past 45 mins? can someone help me figure out what I've done wrong? thanks
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

What mode do you see in the screen?
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

not sure which screen you're referring to but in the portal, the internal memory keeps getting reset to 0's for both speed and duration? currently the mode alternates but it was set up in custom??
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

The RA screen. Move the joystick to the right or left.
Or are you using a custom screen?
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

it says normal mode. what is that? don't see it listed in the portal as a mode.
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

Normal?
Are you sure you are in the RF screen?
Can you send a picture?
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

sorry Roberto, the mode is gyre, duration is 15 and speed is 30
Image
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Reefology's code

Post by rimai »

Which channels did you assign for DCPump?
Roberto.
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

lol, I just logged in to tell you i figured it out...had the actinic channel set to None and of course thought I had the pump wired to daylights :p

thanks Roberto
Image
Reefology
Posts: 209
Joined: Fri Dec 26, 2014 6:38 pm

Re: Reefology's code

Post by Reefology »

Code: Select all

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

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;
    
  

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

    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.DayLights( Port2 );
    ReefAngel.StandardHeater( Port3 );
    ReefAngel.StandardLights( Port5, 19,0,7,0);
    ReefAngel.DosingPumpRepeat1( Port6 );
    ReefAngel.DosingPumpRepeat2( Port7 );
    ReefAngel.DosingPumpRepeat3( Port8 );
    ReefAngel.PWM.DaylightPWMParabola();
    ReefAngel.PWM.ActinicPWMParabola();
    ReefAngel.DCPump.LowATOChannel = Sync; // WP40 
    ReefAngel.DCPump.HighATOChannel = AntiSync; // SW 8 
    ReefAngel.DCPump.AntiSyncOffset=125;
    
    ////// Place your custom code below here
    
    // DC pumps
    // To run this code must choose Custom in portal
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, LongPulse, Else, Gyre, NutrientTransport };

    if (now()%3600==0 || changeMode==true) { // Change every 60 mins (3600seconds) or controller reboot
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    // Continue NutrientTranspot Mode for 30 minutes after feeding
    if (now()-feeding<1800) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=NutrientTransport;
    ReefAngel.DCPump.Speed=80;
    // Night mode (go to 30%)
    } else if (now()%SECS_PER_DAY>25200 && now()%SECS_PER_DAY<=68400) { // 7am to 7pm
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=Gyre;
    ReefAngel.DCPump.Speed=30;
    } else if (InternalMemory.DCPumpMode_read()==11) {
    // Custom Mode and nothing else going on
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
Can someone here please tell me why my Jebao wavemaker pump is running full throttle constantly on the ATO high? the ATO low is working great. in fact I made an adaptor to run both pumps on my ATO low and they're working but I'd really like to get the antisync working. The code I'm using in the meantime is below.

thanks

Code: Select all


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

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;
    
  

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

    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.ActinicLights( Port1 );
    ReefAngel.DayLights( Port2 );
    ReefAngel.StandardHeater( Port3 );
    ReefAngel.StandardLights( Port5 );
    ReefAngel.DosingPumpRepeat1( Port6 );
    ReefAngel.DosingPumpRepeat2( Port7 );
    ReefAngel.DosingPumpRepeat3( Port8 );
    ReefAngel.PWM.DaylightPWMParabola();
    ReefAngel.PWM.ActinicPWMParabola();
    ReefAngel.DCPump.LowATOChannel = Sync; // WP40 & SW 8
    ReefAngel.DCPump.HighATOChannel = None; //  
    
    ////// Place your custom code below here
    
    // DC pumps....................................
    static int rmode;
    static boolean changeMode=true;

    // These are the modes we can cycle through. You can add more and even repeat...
    byte modes[] = { ReefCrest, Lagoon, TidalSwell, ShortPulse, Sine, Else, Gyre, NutrientTransport };

    if (now()%1800==0 || changeMode==true)  // Change every 30 mins (1800seconds) or controller reboot
    {
    rmode=random(100)%sizeof(modes); // Change the mode by picking from our array
    changeMode=false;
    }

    // Set timer when in feeding mode
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE) feeding=now();
    
    // Continue NutrientTranspot Mode for 30 minutes after feeding
    if (now()-feeding<1800) 
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=ReefCrest;
    ReefAngel.DCPump.Speed=80;
    }
    
    // Night/Quiet mode
      else if (hour()>=2 && hour()<8 ) // 2am to 8am
    { 
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( Sine,35,10 );
    } 
      else if (hour()>=15 && hour()<19) // 3pm and 7pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( LongPulse,30,1 ); 
    }
    
    //Storm mode
    else if (hour()>=1 && hour()<2) // 1am and 2am
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( Else,80,15 );  
    }
      else if (hour()>=11 && hour()<12) // 11am and 12pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( LongPulse,95,2 );  
    }
    else if (hour()>=21 && hour()<22) // 9pm and 10pm
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.SetMode( ReefCrest,85,15 );  
    }
    
    // Custom Mode and nothing else going on
    else if (InternalMemory.DCPumpMode_read()==11) 
    {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
    ReefAngel.DCPump.Mode=modes[rmode]; // Put the mode to the random mode :)
    ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Set speed from portal
    } else {
    ReefAngel.DCPump.UseMemory=true; // Will reset all values from memory
    }
    ////// Place your custom code above here

Image
Post Reply