PaulTurner911 Code

Share you PDE file with our community
Post Reply
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

OK, I jumped the gun and downloaded it at work. :)
I see in the wizard that you can set the mode, but I see no duration and no "custom" mode. Duration IS in the portal, but still no custom. Will I have a wat to select and randomize Lagoon, ReefCrest, and Long Pulse?

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

Re: PaulTurner911 Code

Post by lnevo »

I suspect a lot will have to be changed (maybe it will be easy...) in order to incorporate the things we've done. However since it's all in the wizard it might be best to start fresh and go from there... just something to keep in mind.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: PaulTurner911 Code

Post by rimai »

Duration is only available on certain modes.
No custom with the wizard :(
If you are doing custom, you don't need the wizard :)
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

But he wants to utilize the DC Pump portal section... I think it be easiest to start with that fresh from the wizard and add his custom stuff back in after. :)

Also, off topic, but I had no idea new code was pushed :) The sticky with the changelog doesn't show up in New Posts. Can you bump it in the future when a new release is made. :D
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I think Im going to stick with what Im running and possibly (with Lees help) come up with a way to randomize specific modes. I dont see much difference in the DC or the Vortec menus.....What would I gain in changing?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

I just looked at the changes made in the libraries. It will be much easier to do everything with that because your whole if else block to look at the functions is all part of the ReefAngel class now.

You've got a lot of custom stuff so yeah, for you it might be easier to leave it for now, once I see how the new stuff is used, I can help you transition to it.

The main benefit will be that since you don't have a RF module, your using the memory locations, but your not tracking changes to speed duration and mode in the portal charts. (i.e. You can't do a chart on RFS for instance (RFSpeed). You can't even look at what that variable has been set for because the portal doesn't track memory addresses.

With the new libraries, the DCS (DC Speed) is now reported by /r99 and will be part of the XML sent to the portal, so you'll be able to view exactly what state your DC Pump is in and not just look at the PWMD output.

Also, since we'll be doing random modes each day you can track what your DCD value looks like to know which mode your controller chose that day :) Lots of cool things.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I like the idea of being able to identify what mode it IS or WAS in!! Please keep me posted.
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

LOL, back in DEFAULT. UGH!!

Ill wait it out a few, and dabble in the wizard to see what I can do on my own this weekend..... I should be able to get my basic stuff back in after running the wizard, then Ill work on the WP40 stuff.
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Ive run the wizard and stuck all of the custom in that I thought would not conflict. Basically everything with the exception of the custom feed mode and the custom randomized WP mode. The following was what I would like modified to work with the DC
//Feed Mode Delay on Pump
static boolean feeding=false;
static unsigned long feedingstarted = now();
if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
if (!feeding)
{
feeding=true;
feedingstarted = now();
}
} else {
feeding=false;

}

///// Place your custom code below here
//IDK Rimai Posted
#define Mem_B_RFMode VarsStart+55
// Read memory for RF Wave Settings and use for Tunze/Jaebo
int mode=InternalMemory.RFMode_read();
int speed=InternalMemory.RFSpeed_read();
int duration=InternalMemory.RFDuration_read();

// Change this to what you want your min/max based on vortech speed
// This is for those functions that take both, but only one memory slot.
int minOffset=25;
int maxOffset=25;

int min=speed-minOffset;
int max=speed+maxOffset;

// Add random mode if we set to Mode to 12
static int rmode;

if (now()%SECS_PER_HOUR==0) {
rmode=random(7); // Change the mode once per hour to modes 0-6
}
if (mode==12) {
mode=rmode;
}

// keep wavemakers off for first 30 minutes of feeding mode.
if (now()-feedingstarted<=1800 && ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight( 0 );
//ReefAngel.PWM.SetActinic( 0 );
} else if (mode==Constant) {
// Constant
ReefAngel.PWM.SetDaylight( speed );
//ReefAngel.PWM.SetActinic( speed );
} else if (mode==Lagoon) {
// Lagoon
ReefAngel.PWM.SetDaylight( SineMode(min,max,duration,true) );
//ReefAngel.PWM.SetActinic( SineMode(min,max,duration,false) );
} else if (mode==ReefCrest) {
// Reef Crest
ReefAngel.PWM.SetDaylight( ReefCrestMode(speed,duration,true) );
//ReefAngel.PWM.SetActinic( ReefCrestMode(speed,duration,false) );
} else if (mode==ShortPulse) {
// Short Pulse
ReefAngel.PWM.SetDaylight( ShortPulseMode(min,max,duration,true) );
//ReefAngel.PWM.SetActinic( ShortPulseMode(min,max,duration,false) );
} else if (mode==LongPulse) {
// Long Pulse
ReefAngel.PWM.SetDaylight( LongPulseMode(min,max,duration,true) );
//ReefAngel.PWM.SetActinic( LongPulseMode(min,max,duration,false) );
} else if (mode==TidalSwell) {
// Tidal Swell
ReefAngel.PWM.SetDaylight( TidalSwellMode(speed,true) );
//ReefAngel.PWM.SetDaylight( TidalSwellMode(speed,false) );
} else if (mode=NutrientTransport) {
// Smart_NTM
ReefAngel.PWM.SetDaylight( NutrientTransportMode(min,max,duration,true) );
//ReefAngel.PWM.SetActinic( NutrientTransportMode(min,max,duration,false) );
} else {
// Default
ReefAngel.PWM.SetDaylight( TideMode(speed,minOffset,maxOffset) );
//ReefAngel.PWM.SetActinic( TideMode(speed,minOffset,maxOffset) );
}
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Here is my current DC CODE

#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
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | 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


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
ReefAngel.StandardFan( Port2 ); // Canopy Fans
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
//Port 6 NOT USED (Possibly Skimmer)
ReefAngel.DayLights( Port7 ); // MH 1
ReefAngel.DayLights( Port8 ); //MH2
//Moonlight Phase 9pm-10am (CH4-CH5)
if ( (hour() >=10) && (hour() <21) )
ReefAngel.PWM.SetChannel( 4,(0) );
else
ReefAngel.PWM.SetChannel( 4, MoonPhase() );
if ( (hour() >=10) && (hour() <21) )
ReefAngel.PWM.SetChannel( 5,(0) );
else
ReefAngel.PWM.SetChannel( 5, MoonPhase() );
//Over Flow Protection
if (ReefAngel.HighATO.IsActive())
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);
//ATO Protection
if (ReefAngel.LowATO.IsActive())
ReefAngel.Relay.On(Port4);
else
ReefAngel.Relay.Off(Port4);
//Kalk Dose 50sec @ 8pm-12pm (every 15min)
if (hour() >=20 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<50);
else
ReefAngel.Relay.Off(Port4);
// Add night mode (constant 30%)
if (now()%SECS_PER_DAY<30600 || now()%SECS_PER_DAY >=81000) { // Time is before 8:30am and after 10:30pm
ReefAngel.PWM.SetDaylight(30);
}
ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = None;
ReefAngel.DCPump.ExpansionChannel[0] = None;
ReefAngel.DCPump.ExpansionChannel[1] = None;
ReefAngel.DCPump.ExpansionChannel[2] = None;
ReefAngel.DCPump.ExpansionChannel[3] = None;
ReefAngel.DCPump.ExpansionChannel[4] = None;
ReefAngel.DCPump.ExpansionChannel[5] = None;
////// Place your custom code below here


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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();

// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I went ahead and put the night mode in thinking it may work, but I was wrong....

Looking forward to hearing what you guys have to say :)
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Paul,

Thats not from the latest code....i know because i streamlined your feeding mode code and its thats not there, plus you didn't post the night mode portion.

And we need roberto to add custom mode to the portal *cough* *cough* otherwise you'll still have to activate the custom mode from memory manually..

I'll see what i can throw together tomorrow...
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

You are right! I grabbed that from my OP in the thread...

Its pretty cool to see the DC Pump on the dashboard, but it doesnt show what percentage it is running at in that section, it does show above in the PWM though.
Last edited by Paulturner911 on Mon Jun 24, 2013 11:42 am, edited 1 time in total.
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Removed to clean up this thread
Last edited by Paulturner911 on Mon Jun 24, 2013 11:43 am, edited 1 time in total.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Try this:

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


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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | 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


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
ReefAngel.StandardFan( Port2 ); // Canopy Fans
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
//Port 6 NOT USED (Possibly Skimmer)
ReefAngel.DayLights( Port7 ); // MH 1
ReefAngel.DayLights( Port8 ); //MH 2
//Moonlight Phase 9pm-10am (CH4-CH5)
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 4,(0) );
else 
ReefAngel.PWM.SetChannel( 4, MoonPhase() );
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 5,(0) );
else
ReefAngel.PWM.SetChannel( 5, MoonPhase() );

//Over Flow Protection
if (ReefAngel.HighATO.IsActive())
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);

//ATO Protection
if (ReefAngel.LowATO.IsActive())
ReefAngel.Relay.On(Port4);
else
ReefAngel.Relay.Off(Port4);

//Kalk Dose 50sec @ 8pm-12pm (every 15min)
if (hour() >=20 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<50);
else
ReefAngel.Relay.Off(Port4);

//Kalk Stir 12pm-1pm
if (hour() >=12 & hour() < 13)
ReefAngel.Relay.On(Port5);
else
ReefAngel.Relay.Off(Port5);


ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
////// Place your custom code below here

///// Place your custom code below here

// 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;
}

// Are we in custom mode
if (ReefAngel.DCPump.Mode==11) {
  ReefAngel.DCPump.UseMemory=false; // We are going to override the memory (which is currently set to 11..)
  ReefAngel.DCPump.Mode=modes[rmode];  // Put the mode to the random mode :)
} else {
  ReefAngel.DCPump.UseMemory=true;
}

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
feeding = now();
}

// keep wavemakers off for first 30 minutes of feeding mode.
if (now()-feeding<=1800) { // 30 minutes after 
ReefAngel.DCPump.Speed=0;
} else if (now()-feeding<=(1800+3600)) { // // First 30 minutes pump is off.. next 60 minutes will be in NTM
ReefAngel.DCPump.Mode=NutrientTransport;
}


// Add night mode (constant 30%)
if (now()%SECS_PER_DAY<30600 || now()%SECS_PER_DAY >=81000) { // Time is before 8:30am and after 10:30pm
  ReefAngel.DCPump.Speed=30;
}
////// Place your custom code above here

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();

// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Thank YOU SIR!!!

In order to add and remove modes, do I simply type and or remove them in the following section?

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

Could you give a quick explanation of what tidal swell is?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Its cool. I like it. Look at ecotech manual.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I'm having an issue with the feedmode, the wp is not turning to NTM at 1800 on the countdown. It's not turning back on once the 3600s times out either. I'm not sure the night mode is activating either, I uploaded late last night and it didn't run at 30.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Let me know what it did. I'll look again at the code...
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Its not activating NTP at 1800 and once the feedmode is complete (3600) the WP pump stays off. Basically once the feed mode is activate it turns the WP pump off until I goto the portal and select a mode other than NTM.
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Paul I had an error in the feeding mode section that I fixed in my post above. Can you try it and let me know. If it doesn't work, I'll have to relook at the logic, but the error I had could have caused it to f up :)
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I'm having the same results with the newer code. The night mode doesn't activate and once feedmode has been activated the wp never resumes, it in theory should activate NTM at 1800s on the feedmode countdown. I'd appreciate any help, no rush!!!

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

Re: PaulTurner911 Code

Post by lnevo »

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

Re: PaulTurner911 Code

Post by lnevo »

I see where I went wrong. When we get to NTM mode we never reset the speed. Lots of other issues. I'm fairly confident in this rework. Please give it a try.

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


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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | 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


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
ReefAngel.StandardFan( Port2 ); // Canopy Fans
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
//Port 6 NOT USED (Possibly Skimmer)
ReefAngel.DayLights( Port7 ); // MH 1
ReefAngel.DayLights( Port8 ); //MH 2
//Moonlight Phase 9pm-10am (CH4-CH5)
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 4,(0) );
else 
ReefAngel.PWM.SetChannel( 4, MoonPhase() );
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 5,(0) );
else
ReefAngel.PWM.SetChannel( 5, MoonPhase() );

//Over Flow Protection
if (ReefAngel.HighATO.IsActive())
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);

//ATO Protection
if (ReefAngel.LowATO.IsActive())
ReefAngel.Relay.On(Port4);
else
ReefAngel.Relay.Off(Port4);

//Kalk Dose 50sec @ 8pm-12pm (every 15min)
if (hour() >=20 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<50);
else
ReefAngel.Relay.Off(Port4);

//Kalk Stir 12pm-1pm
if (hour() >=12 & hour() < 13)
ReefAngel.Relay.On(Port5);
else
ReefAngel.Relay.Off(Port5);


ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
////// Place your custom code below here

///// Place your custom code below here

// 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;
}

if (now()-feeding<=1800) { 
  // 30 minutes after feeding mode. Pump is off
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Speed=ReefAngel.DCPump.FeedingSpeed;
} else if (now()-feeding<=(1800+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.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==11) { 
  // Custom Mode and nothing else going on
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=modes[rmode];  // Set 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
}

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
feeding = now();
}

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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();

// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Awesome! Ill try tonight and let you know! I really appreciate the help Lee.

Thank You
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I had to move

// Set timer when in feeding mode
static unsigned long feeding;
if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
feeding = now();

ABOVE

if (now()-feeding<=1800) {

b/c I was getting an error for feeding being undefined, when I switched them it worked.

However I am in the same boat, or even worse with the NTP/Feedmode. It still does not activate at the 1800s mark nor after feedmode has timed out. The only difference is before I could go in the portal and activate any mode, now it is unresponsive. Meaning the WP will not run in any mode right now.....Please help :)
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Well go back to your older code..gonna take me a while to figure it out.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

It eventually turned back on, just not in or right after feedmode. I looked in the portal after feedmode timed out and it read NTM instead of custom, BUT it read a speed of ZERO at that time. Now its seems to be running "night mode, in NTM" at 30 in stead of nightmode constant 30....its pulsing. Keep me posted, Thanks
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

Oh ok thats cool..we can figure some of that out...

Also just an fyi can you confirm your feeding mode time...how long your return pump is off for..

Right now it goes:

Feeding mode start 00:00
Feeding mode finish 15:00???
Wavemaker at 0 till 45:00
Ntm at usual speed till 1:45

The extended wavemaker off used to be 30 minutes total but now its 45 minutes.. I can fix that but just making sure you are expecting the right thing.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

So it looks like you reset your controller at around 3:30..mode was in NTM from that point on..which is part of your random rotation... At about 7:05 you went into feeding mode. Your speed was at 0 and mode still at NTM... until 8:14 when it went back to 60. You were still in NTM mode...now forced (ignoring custom mode) until 10:30 when night mode kicked in staying in NTM at 30%.

This is based on the charts below. Keep in mind 0 values do not show on the graph...but note the gap between 7:04 and 8:14.

Speed
http://forum.reefangel.com/status/chart ... filter=DCS

Mode
http://forum.reefangel.com/status/chart ... filter=DCM

So it looks like everything is working except the following which I've fixed below:

Change extension of feeding mode to 15 minutes so total duration is 30. Feel free to make the 900 back to 1800.

Fixed the timer issue you had as well...sorry bout that one.
Force night mode to Constant instead of whatever is default mode (NTM was today's mode.)

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


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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port7Bit | Port8Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port3Bit | 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


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
ReefAngel.StandardFan( Port2 ); // Canopy Fans
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
//Port 6 NOT USED (Possibly Skimmer)
ReefAngel.DayLights( Port7 ); // MH 1
ReefAngel.DayLights( Port8 ); //MH 2
//Moonlight Phase 9pm-10am (CH4-CH5)
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 4,(0) );
else 
ReefAngel.PWM.SetChannel( 4, MoonPhase() );
if ( (hour() >=10) && (hour() <21) ) 
ReefAngel.PWM.SetChannel( 5,(0) );
else
ReefAngel.PWM.SetChannel( 5, MoonPhase() );

//Over Flow Protection
if (ReefAngel.HighATO.IsActive())
ReefAngel.Relay.On(Port1);
else
ReefAngel.Relay.Off(Port1);

//ATO Protection
if (ReefAngel.LowATO.IsActive())
ReefAngel.Relay.On(Port4);
else
ReefAngel.Relay.Off(Port4);

//Kalk Dose 50sec @ 8pm-12pm (every 15min)
if (hour() >=20 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<50);
else
ReefAngel.Relay.Off(Port4);

//Kalk Stir 12pm-1pm
if (hour() >=12 & hour() < 13)
ReefAngel.Relay.On(Port5);
else
ReefAngel.Relay.Off(Port5);


ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
////// Place your custom code below here

///// Place your custom code below here

// 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
}

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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();

// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
pingSerial();

// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}

void DrawCustomGraph()
{
}

Post Reply