DCPump Custom, Night, Extended Feeding Modes

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

DCPump Custom, Night, Extended Feeding Modes

Post by lnevo »

For anyone looking to implement some of these elements with the new DCPump class, please take a look at what I did with Paulturner911.

http://forum.reefangel.com/viewtopic.php?p=29100#p29100

In the custom mode for that INO we implemented a daily change of the mode from a set array of choices. We extended the Feeding Mode Speed past the end of Feeding Mode to give the corals more time grabbing food in the water column. Then after that we kick off Nutrient Transport for 60 minutes.

There is also the Night Mode setting in the same block. The night and feeding stuff will work on any mode and the random selection only when we've chosen Custom.

I started a new thread since these things are commonly asked and not to muddy up Paul's thread for those with specific questions and how do I's
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: DCPump Custom, Night, Extended Feeding Modes

Post by lnevo »

Here's the code excerpt to make it easier for everyone. It's pretty straight forward and is a great reference for anyone who wants to use the new DCPump routines and have scheduled modes, etc.

Code: Select all

// Add random mode if we set to Mode to 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, TidalSwell, ShortPulse, NutrientTransport };

if (now()%SECS_PER_DAY==0 || changeMode==true) { // Change at midnight or if controller rebooted
rmode=random(100)%sizeof(modes); // Change the mode once per day to pick 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<=900) { 
  // 30 minutes after feeding mode. Pump is off
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Speed=0;
} else if (now()-feeding<=(900+3600)) { 
  // First 30 minutes pump is off, Next 60 is NTM
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
  ReefAngel.DCPump.Speed=InternalMemory.DCPumpSpeed_read(); // Resume previous speed
} else if (now()%SECS_PER_DAY<30600 || now()%SECS_PER_DAY>=81000) { // 8:30am / 10:30pm
  // Night mode (go to 30%)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=Constant;
  ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) { 
  // Custom Mode and nothing else going on
  ReefAngel.DCPump.UseMemory=false;
  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
}
Post Reply