Issues with Feeding Mode code

Share you PDE file with our community
Post Reply
meadowsad
Posts: 53
Joined: Sat Jun 15, 2013 9:56 am

Issues with Feeding Mode code

Post by meadowsad »

I am trying to change my feeding mode code to switch to nutrient transport after feeding and I can't seem to get it to work. Unfortunately I don't think I understand this enough to figure it out...

To start this line works fine for Feeding Mode

Code: Select all

ReefAngel.DCPump.FeedingSpeed=30
In the end I would like the Feeding Mode to spin my pumps down to 30% and then do nutrient transport after feeding has completed.

I tried something like this;

Code: Select all

   static unsigned long feeding;
  if (ReefAngel.DisplayedMenu==FEEDING_MODE)
       {  
       feeding = now();
       ReefAngel.DCPump.SetMode( Constant,30,10 );
       }
  else if (now()-feeding<=3600)
       {
       ReefAngel.DCPump.SetMode( NutrientTransport,100,30 );
       }
This stopped the pumps in Feeding Mode and when that mode ended it went in to NTM but stayed in that mode. The pumps didn't come back to their original speed.

As a test I have tried removing;

Code: Select all

ReefAngel.DCPump.FeedingSpeed=30
And added;

Code: Select all

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
ReefAngel.DCPump.SetMode( Constant,30,10 );
This code doesn't work, the pumps just stop during feeding. I have tried putting it in the setup function and after the loop function. I'm not sure where this code should go in order for this to work correctly. In the loop function?

Basically I need some guidance here since my coding experience is very very limited. Any help would be appreciated, thanks!
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issues with Feeding Mode code

Post by rimai »

You said this worked:

Code: Select all

ReefAngel.DCPump.FeedingSpeed=30
So, keep it.
Also, you said this didn't work:

Code: Select all

ReefAngel.DCPump.SetMode( Constant,30,10 );
So, remove it.
Give it a shot and keep us posted.
Roberto.
meadowsad
Posts: 53
Joined: Sat Jun 15, 2013 9:56 am

Re: Issues with Feeding Mode code

Post by meadowsad »

Ended up using

Code: Select all

    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE)
    {
    feeding = now();
    ReefAngel.DCPump.SetMode( Constant,30,10 ); 
    }
    else if (now()-feeding<=9000)
    { 
    ReefAngel.DCPump.SetMode( NutrientTransport,100,30 );
    }
Without removing the

Code: Select all

ReefAngel.DCPump.FeedingSpeed=30
in the setup function. Not sure if I can remove that now or not but it isn't hurting anything so I will leave it. This is the same thing I did last night, with the line above removed, but maybe I just needed a break :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues with Feeding Mode code

Post by lnevo »

You need a final else to go back to the mode you want since you are setting the mode instead of just overriding...
meadowsad
Posts: 53
Joined: Sat Jun 15, 2013 9:56 am

Re: Issues with Feeding Mode code

Post by meadowsad »

Do I just put a simple else at the end and that is it?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues with Feeding Mode code

Post by lnevo »

} else {
ReefAngel.DCPump.Mode=whatever you normally use;
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Issues with Feeding Mode code

Post by lnevo »

You may be having a problem with the setmode because you might have UseMemory=true (default) so it may be reverting to your memory settings.

Anyway try some out and let's see your full code next.
meadowsad
Posts: 53
Joined: Sat Jun 15, 2013 9:56 am

Re: Issues with Feeding Mode code

Post by meadowsad »

So this is the code I am using now and it is working great! I verified it goes to the pump setting before feeding at least 3 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 <Humidity.h>
#include <DCPump.h>
#include <ReefAngel.h>

////// Place global variable code below here

// Define Relay Ports by Name
#define Tunze1             1  // Tunze 6095 #1
#define Tunze2             2  // Tunze 6095 #2
#define ReturnPump         3  // Laguna 1350 Pump
#define Skimmer            4  // Reef Dynamics INS80 Skimmer
#define AIVega1            5  // Aqua Illumination Vega Color #1
#define AIVega2            6  // Aqua Illumination Vega Color #2
#define Heater             7  // Eheim Jager 250w Heater
#define ATOPump            8  // Aqua Lifter Pump

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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.FeedingModePorts = Port3Bit | Port4Bit | Port8Bit; // Turn off Return Pump, Skimmer, ATO during feeding
    ReefAngel.WaterChangePorts = Port3Bit | Port4Bit | Port8Bit; // Turn off Return Pump, Skimmer, ATO during water change
    ReefAngel.LightsOnPorts = Port5Bit | Port6Bit; // Turn on/off Aqua Illumination Vega Color #1 and #2 in Lights On / Off menu
    ReefAngel.OverheatShutoffPorts = Port5Bit | Port6Bit | Port7Bit; // Turn off Aqua Illumination Vega Color #1 and 2 and Eheim Jager Heater on over heat status
    ReefAngel.TempProbe = T1_PROBE; // Use Temp Probe 1 for temperature reading
    ReefAngel.OverheatProbe = T1_PROBE; // Use Temp Probe 1 for over head alert
    InternalMemory.OverheatTemp_write( 830 ); // Over heat status when temperature reaches 83 degrees Fahrenheit
    ReefAngel.Timer[FEEDING_TIMER].SetInterval(600); // Feeding Mode length
    
    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=30; // Set Tunze 6095 #1 and #2 to 30% speed
    ReefAngel.DCPump.WaterChangeSpeed=0; // Turn off Tunze 6095 #1 and #2

    // Ports that are always on
    ReefAngel.Relay.On( ReturnPump ); 
    ReefAngel.Relay.On( AIVega1 );
    ReefAngel.Relay.On( AIVega2 );


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

void loop()
{
    ReefAngel.Relay.DelayedOn( Tunze1,1 ); // Delay Tunze 6095 #1 by 1 minute
    ReefAngel.Relay.DelayedOn( Tunze2,1 ); // Delay Tunze 6095 #2 by 1 minute
    ReefAngel.Relay.DelayedOn( Skimmer,1 ); // Delay Skimmer by 1 minute
    ReefAngel.StandardHeater( Heater,780,800 ); // Keep temp between 78-80 degrees Fahrenheit
    ReefAngel.StandardATO(ATOPump,1200); // ATO Pump with 20 minute timout
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    ReefAngel.ShowInterface();
    
    ////// Place your custom code below here
    
    // Schedule for Tunze 6095 #1 and #2  
    if (hour()>=0000 && hour()<8) // Tunze 6095 #1 and #2 at 30% from 12am-8am
    {
    ReefAngel.DCPump.SetMode( Constant,30,10 );
    }
    if (hour()>=8 && hour()<9) // Tunze 6095 #1 and #2 at 50% in Lagoon mode from 8am-9am
    {
    ReefAngel.DCPump.SetMode( Lagoon,50,10 );
    }
    if (hour()>=9 && hour()<20) // Tunze 6095 #1 and #2 at 70% in Reef Crest mode from 9am-10pm
    { 
    ReefAngel.DCPump.SetMode( LongPulse,80,10 );
    }
    if (hour()>=20 && hour()<21) // Tunze 6095 #1 and #2 at 50% in Lagoon mode from 10pm-11pm
    {
    ReefAngel.DCPump.SetMode( Lagoon,50,10 );
    }
    if (hour()>=21 && hour()<2359) // Tunze 6095 #1 and #2 at 30% 11pm-12am
    {
    ReefAngel.DCPump.SetMode( Constant,30,10 );
    }
    
    // Run Nutrient Transport Mode after Feeding Mode completes
    static unsigned long feeding;
    if (ReefAngel.DisplayedMenu==FEEDING_MODE)
    {
    feeding = now();
    ReefAngel.DCPump.SetMode( Constant,30,10 ); // Set Tunze 6095 #1 and #2 to 30% speed 
    }
    else if (now()-feeding<=30) // Next 30 seconds are in Nutrient Transport Mode(for testing)
    { 
    ReefAngel.DCPump.SetMode( NutrientTransport,100,30 ); // Set Tunze 6095 #1 and #2 to 100% speed with 30ms pulse in Nutirnet Transport Mode
    }
    
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "meadowsad" );
    ReefAngel.ShowInterface();
}
Last edited by meadowsad on Thu Aug 22, 2013 3:04 pm, edited 1 time in total.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Issues with Feeding Mode code

Post by rimai »

Awesome!!
Roberto.
Post Reply