Jebao code using reefangel.pwm but feeding mode doesnt work

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

Posts: 32
Joined: Thu Apr 03, 2014 11:37 pm
PostPosted: Sun Nov 09, 2014 8:04 am
Hi...

I am using the following code for my reefangel.
I have managed to get my dc wave pumps working the way I like it.
the big problem is that the pumps does not switch off when I go into feeding mode.
Please let me know what code I need to add?

#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


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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature

ReefAngel.AddStandardMenu(); // Add Standard Menu

ReefAngel.Use2014Screen(); // Let's use 2014 Screen
ReefAngel.AddPHExpansion(); // pH Expansion Module
ReefAngel.AddWaterLevelExpansion(); // Water Level Expansion Module
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port6Bit | Port7Bit | Port8Bit;
ReefAngel.FeedingModePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port7Bit | Port8Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 280 );

// Feeeding and Water Change mode speed

ReefAngel.DCPump.WaterChangeSpeed=0;


// Ports that are always on
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 );

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


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

void loop()
{
ReefAngel.StandardLights( Port1,6,45,19,0 );
ReefAngel.StandardLights( Port2,11,45,17,30 );
ReefAngel.StandardHeater( Port3,240,255 );
ReefAngel.StandardHeater( Port4,240,255 );
ReefAngel.StandardFan( Port5,260,265 );
ReefAngel.CO2Control( Port7,650,660 );
ReefAngel.Relay.DelayedOn( Port8,3 );

////// Place your custom code below here
static unsigned long atoTimer;

if (ReefAngel.DisplayedMenu==FEEDING_MODE) atoTimer=now();

if (now()-atoTimer < 120) {
ReefAngel.Relay.Off(Port6);

} else {
ReefAngel.SingleATO( true,Port6,60,0 );
}



if (hour()>=7 && hour()<11)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,80,1,true) ); // Ramp from 0% to 80% with 1 min duration in sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,80,1,false) );
}

if (hour()>=11 && hour()<20)
{
ReefAngel.PWM.SetDaylight( ElseMode(80,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ElseMode(80,20,false) );
}
else if (hour()>=20 && hour()<23)
{
ReefAngel.PWM.SetDaylight( NutrientTransportMode(40,80,4000,true) ); // Nutrient Transport 40%minspeed - 80%maxspeed - 200ms
ReefAngel.PWM.SetActinic( NutrientTransportMode(40,80,4000,false) );
}
else if (hour()>=23 && hour()<7)
{
ReefAngel.PWM.SetDaylight( ElseMode(40,15,true) ); // ReefCrest at 45% +/- 15% on sync mode
ReefAngel.PWM.SetActinic( ElseMode(40,15,false) );
}
if(ReefAngel.HighATO.IsActive())
{
ReefAngel.Relay.Off(Port8);
}
else
{
ReefAngel.Relay.On(Port8);
}

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

// This should always be the last line
ReefAngel.ShowInterface();
}
byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
// Static's only initialize the first time they are called
static unsigned long LastChange=millis(); // Set the inital time that the last change occurred
static int Delay = random( 500, 3000); // Set the initial delay
static int NewSpeed = MidPoint; // Set the initial speed
static int AntiSpeed = MidPoint; // Set the initial anti sync speed
if ((millis()-LastChange) > Delay) // Check if the delay has elapsed
{
Delay=random(500,5000); // If so, come up with a new delay
int ChangeUp = random(Offset); // Amount to go up or down
if (random(100)<50) // 50/50 chance of speed going up or going down
{
NewSpeed = MidPoint - ChangeUp;
AntiSpeed = MidPoint + ChangeUp;
}
else
{
NewSpeed = MidPoint + ChangeUp;
AntiSpeed = MidPoint - ChangeUp;
}
LastChange=millis(); // Reset the time of the last change
}
if (WaveSync)
{
return NewSpeed;
}
else
{
return AntiSpeed;
}
}

Posts: 12288
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sun Nov 09, 2014 4:16 pm
Try adding this:
Code: Select all
  ReefAngel.DCPump.FeedingSpeed=0;
Roberto.

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 2 guests

cron