PaulTurner911 Code

Share you PDE file with our community

Posts: 278
Joined: Wed Jan 23, 2013 12:36 pm
PostPosted: Fri Jun 14, 2013 3:12 pm
First I would have to thank Lee for "helping" get this dialed in.....
AND BY HELP I MEAN PRETTY MUCH DO IT FOR ME!!
He has been a great help in this from the start.

Currently Running:

Overflow Protection- Shuts down Return Pump
ATO Low Protection- Shuts down Aqua Lifter
Moon Phase from 9pm-10am
ATO/Kalk Doser running for 50sec every 15min from 8pm-12pm
Custom Feed Mode(WP40 off for 30min, Return Pump off for 60min)
WP40 Tidal Modes (Randomized Daily)
Night Mode for the WP40



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 <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 | Port7Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | 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;
InternalMemory.OverheatTemp_write( 869 );


// Ports that are always on

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


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

void loop()
{
ReefAngel.Relay.On( Port1 );
ReefAngel.StandardFan( Port2 );
ReefAngel.ActinicLights( Port3 );
ReefAngel.DayLights( Port7 );
ReefAngel.DayLights( Port8 );
//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() );
//Pump Delay and 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);
//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) );
}
// 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);
}
////// 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()
{
}



status/chart.aspx?id=Paulturner911&filter=PWMD
Last edited by Paulturner911 on Mon Jun 23, 2014 12:14 pm, edited 2 times in total.
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Jun 17, 2013 8:55 am
Try this code, I added the following requested features:

Changed random mode to switch daily instead of hourly
Changed the duration for NTM and short pulse to use a better value (duration * 100) since the argument is milliseconds
Added in the NTM after feeding mode is done. (30 minutes pumps off, then 60 minutes of NTM)
Added indentations to make it readable.

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 <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 | Port7Bit | Port8Bit;
  // Ports toggled in Water Change Mode
  ReefAngel.WaterChangePorts = Port1Bit | 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;
  InternalMemory.OverheatTemp_write( 869 );
 
 
  // Ports that are always on
 
  ////// Place additional initialization code below here
 
 
  ////// Place additional initialization code above here
}

void loop()
{
  ReefAngel.Relay.On( Port1 );
  ReefAngel.StandardFan( Port2 );
  ReefAngel.ActinicLights( Port3 );
  ReefAngel.DayLights( Port7 );
  ReefAngel.DayLights( Port8 );

  //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() );
 
  //Pump Delay and 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);
 
  ///// 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;
  static boolean changeMode=true;
  if (now()%SECS_PER_DAY==0 || changeMode=true) { // Change at midnight or if controller rebooted
    rmode=random(7); // Change the mode once per day to modes 0-6
    changeMode=false;
  }
  if (mode==12) {
    mode=rmode;   
  }
 
  // 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.PWM.SetDaylight( 0 );
  } else if (now()-feeding<=(1800+3600)) { // // First 30 minutes pump is off.. next 60 minutes will be in NTM
      ReefAngel.PWM.SetDaylight( NutrientTransportMode(min,max,duration*100,true) );
  } else if (mode==Constant) {               // Constant
      ReefAngel.PWM.SetDaylight( speed );
  } else if (mode==Lagoon) {                 // Lagoon
      ReefAngel.PWM.SetDaylight( SineMode(min,max,duration,true) );
  } else if (mode==ReefCrest) {              // Reef Crest
      ReefAngel.PWM.SetDaylight( ReefCrestMode(speed,duration,true) );
  } else if (mode==ShortPulse) {             // Short Pulse
      ReefAngel.PWM.SetDaylight( ShortPulseMode(min,max,duration*100,true) );
  } else if (mode==LongPulse) {              // Long Pulse
      ReefAngel.PWM.SetDaylight( LongPulseMode(min,max,duration,true) );
  } else if (mode==TidalSwell) {             // Tidal Swell
      ReefAngel.PWM.SetDaylight( TidalSwellMode(speed,true) );
  } else if (mode=NutrientTransport) {       // Smart_NTM
      ReefAngel.PWM.SetDaylight( NutrientTransportMode(min,max,duration*100,true) );
  } else {                                   // Default
      ReefAngel.PWM.SetDaylight( TideMode(speed,minOffset,maxOffset) );
  }

  // 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);
  }
  ////// 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;
  }
 
  // 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
 
  // Main Relay Box
  byte TempRelay = ReefAngel.Relay.RelayData;
  TempRelay &= ReefAngel.Relay.RelayMaskOff;
  TempRelay |= ReefAngel.Relay.RelayMaskOn;
  ReefAngel.LCD.DrawOutletBox( 12, 84, TempRelay );
 
  // Date and Time
  ReefAngel.LCD.DrawDate( 6, 122 );
}

void DrawCustomGraph()
{
}

Posts: 278
Joined: Wed Jan 23, 2013 12:36 pm
PostPosted: Mon Jun 17, 2013 2:35 pm
Error:

if (now()%SECS_PER_DAY==0 || changeMode=true) { // Change at midnight or if controller rebooted

Ivalue required as left operand of assignment
Image

Posts: 12188
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Jun 17, 2013 2:38 pm
It need == instead of =
Roberto.

Posts: 278
Joined: Wed Jan 23, 2013 12:36 pm
PostPosted: Mon Jun 17, 2013 3:36 pm
Error

if (now()-feeding<=1800) { // 30 minutes after

expected unqualified-id before "if"
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Jun 17, 2013 3:45 pm
Its this line above that...

Code: Select all
  if (ReefAngel.DisplayedMenu==FEEDING_MODE)


It needs a {

Posts: 278
Joined: Wed Jan 23, 2013 12:36 pm
PostPosted: Mon Jun 17, 2013 5:25 pm
Thanks guys, it took!!

Lee, what is your duration set at?
If I understand(rarely) I would set it at 25 inorder for reefcrest to run @45 +/-25.

I did this in the portal, while saving all read "OK" but DC Pump Speed & Duration- both ERR
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Jun 17, 2013 6:52 pm
The libraries arent supporting dc pump yet.

Posts: 278
Joined: Wed Jan 23, 2013 12:36 pm
PostPosted: Mon Jun 17, 2013 7:34 pm
k, just seemed sketchy.

When I select custom in the portal ive only run 45 tonight no change (maybe it randomized 45 constant), Ill check to see if it changes tuesday. Night mode does work though! Just watched it click over.

Thanks


Could I just remove ones that I dont want to run from this section??

if (now()-feeding<=1800) { // 30 minutes after
ReefAngel.PWM.SetDaylight( 0 );
} else if (now()-feeding<=(1800+3600)) { // // First 30 minutes pump is off.. next 60 minutes will be in NTM
ReefAngel.PWM.SetDaylight( NutrientTransportMode(min,max,duration*100,true) );
} else if (mode==Constant) { // Constant
ReefAngel.PWM.SetDaylight( speed );
} else if (mode==Lagoon) { // Lagoon
ReefAngel.PWM.SetDaylight( SineMode(min,max,duration,true) );
} else if (mode==ReefCrest) { // Reef Crest
ReefAngel.PWM.SetDaylight( ReefCrestMode(speed,duration,true) );
} else if (mode==ShortPulse) { // Short Pulse
ReefAngel.PWM.SetDaylight( ShortPulseMode(min,max,duration*100,true) );
} else if (mode==LongPulse) { // Long Pulse
ReefAngel.PWM.SetDaylight( LongPulseMode(min,max,duration,true) );
} else if (mode==TidalSwell) { // Tidal Swell
ReefAngel.PWM.SetDaylight( TidalSwellMode(speed,true) );
} else if (mode=NutrientTransport) { // Smart_NTM
ReefAngel.PWM.SetDaylight( NutrientTransportMode(min,max,duration*100,true) );
} else { // Default
ReefAngel.PWM.SetDaylight( TideMode(speed,minOffset,maxOffset) );
}
Image
User avatar
Posts: 5342
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Jun 17, 2013 7:43 pm
If you pick custom it will just do the tide mode which is almost a constant, unless you changed the mode==12 line.

Otherwise set the RFMode memory to 12 manually.
Next

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest

cron