PaulTurner911 Code

Share you PDE file with our community
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

Remove everything else from the list of options except else mode and then that will be the one that it chooses.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I'm not sure how to.
No way to call it from a memory location manually?

Ok, I think I understand.
Thanks
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

Change this...

Code: Select all

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

To this...

Code: Select all

// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { Else };
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

+1
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Could someone refresh my memory on how to have Relay 6 run constant, unless Im in feed mode?

I didnt realize it but when I added the skimmer it runs on the same schedule as my MH lamps. I would like it to be on all of the time unless its in feed mode.
Any help is greatly apprerciated.

Thank you
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

You need 2 things....

This in // Ports toggled in Feeding Mode

Code: Select all

ReefAngel.FeedingModePorts = Port6Bit;
And then in // Ports that are always on

Code: Select all

ReefAngel.Relay.On( Port6 );
If you want to delay the start after feeding mode by 10 min so your main pump gets up to speed and your water leve gets back to normal you can add this in the loop section...

Code: Select all

ReefAngel.Relay.DelayedOn( Port6,10 );
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Great! Thank you
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I HAVE PICKED UP A NEW TANK!!!
Im wondering if I should just run the wizard and start over, but cut and paste some "custom lines" ??? Please advise which would be easier.

Ditching a few things -
MH (port7&8)
FANS (port2)
ACTINIC (port3)

I have a few things that Id like to add-
3 Ecoray112DX whites/red (port7) Actinics (port8)
Chiller (port2) Should function similar to the fan settings? * NEEDS TO SHUT DOWN IN FEED/WATERCHANGE MODES
Skimmer (port3) ** Id like it off for 2 hours after feedmode activation

ANY AND ALL INPUT IS WELCOMED AND VERY APPRECIATED
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

I would keep what you have and go in and manually cut out what you don't want.

Then use the wizard to create the code you want to add and paste it in to your existing code.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Ill give it a try!! thanks
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I decided to keep my code and change a few relays and make it work for the most part. I have the following questions:

Chiller will now be on port 2. It has a 2 deg variance, if I want the tank at 78 i would set this to 80?

Code: Select all

ReefAngel.LCD.DrawOutletBox( 12, 80, TempRelay );
Wouldnt it then turn the chiller off when it goes to 79?


Skimmer is on port 6- Does shut off in feedmode , but I would like this to have a 2 hour delay after feed mode. How would i code this?


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

Re: PaulTurner911 Code

Post by lnevo »

No that code is for screen drawing. Post your code and I'll be able to help
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Code: Select all

// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit ;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit ;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts =  Port3Bit | Port7Bit ;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port6Bit | Port7Bit ;
// 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
ReefAngel.Relay.On( Port6 );
////// Place additional initialization code below here


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
//Port 2 Chiller
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
ReefAngel.DayLights( Port6 );// Skimmer
ReefAngel.DayLights( Port7 ); // White LEDS
//Port8 Empty
//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 60sec @ 11pm-12pm (every 15min)
if (hour() >=23 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<65);
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;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// 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;

// Add Else Mode definition..
const int Else=16;

// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { Else, Lagoon, Else, ReefCrest, ShortPulse, LongPulse, 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) { 
  // First 15 minutes after feeding mode stops. Return Pump is off
  ReefAngel.Relay.Off(Port1);
  // First 15 minutes after feeding mode stops. Smart_NTM
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()-feeding<4500) { // 15 minutes plus 1 hour
  // Continue NTM for the next 60 minutes (75 minutes total)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} 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.Duration=InternalMemory.DCPumpDuration_read();
  if (modes[rmode]==Else) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Mode=Constant;
    ReefAngel.DCPump.Speed=ElseMode(InternalMemory.DCPumpSpeed_read(),25,true );    // ElseMode on sync mode, Portal Speed Setting +/- 25%
  } else {
    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, 80, TempRelay );
pingSerial();

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

void DrawCustomGraph()
{
}
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;
  }
}
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I've noticed that the skimmer (port6) is functioning like the old mh ports 7/8 as far as off and on schedule.


Is like this to run 24/7 unless water change or feed mode has been activated.

Thanks
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

Port 6 is included in Feeding, Water Change and Overheating off.
You also have it as Always on.

The one line of code that refers to Port 6 that I see has no time associated to it.
it just this...

ReefAngel.DayLights( Port6 );// Skimmer
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Port 6 definatly does not run 24/7
It does shut off for WC and feed mode correct.
I would like it to stay off for 2 hours after either.
What should it read? It's currently shitting down with the "daylight" LEDs.


Thank you
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

I think it has to do with this ReefAngel.DayLights( Port6 );// Skimmer

Just remove this line ReefAngel.DayLights( Port6 );// Skimmer and it should stay on all the time except Feeding, Water Change and Overheat because of this...

// Ports that are always on
ReefAngel.Relay.On( Port6 );

You can probably remove i the Port6Bit from the Overheat as well, you don't need to turn off the skimmer during an overheat situation.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

He wanted a delay so use DelayedOn instead of On and put 120 as the second argument for 2 hours.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Code: Select all

// Ports that are always on
ReefAngel.Relay.DelayedOn( Port6 );120;
will this work?
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

ReefAngel.Relay.DelayedOn(Port6, 120);
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Thanks! here is my current code

Code: Select all

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

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


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

void loop()
{
ReefAngel.DayLights( Port1 ); // Return Pump
//Port 2 Chiller
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Kalk Stir
//Port6 Skimmer
ReefAngel.DayLights( Port7 ); // White LEDS
//Port8 Empty
//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 60sec @ 11pm-12pm (every 15min)
if (hour() >=23 || hour() < 12)
ReefAngel.Relay.Set(Port4, now()%900<60);
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;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// 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;

// Add Else Mode definition..
const int Else=16;

// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { Else, Lagoon, Else, ReefCrest, ShortPulse, LongPulse, 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) { 
  // First 15 minutes after feeding mode stops. Return Pump is off
  ReefAngel.Relay.Off(Port1);
  // First 15 minutes after feeding mode stops. Smart_NTM
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()-feeding<4500) { // 15 minutes plus 1 hour
  // Continue NTM for the next 60 minutes (75 minutes total)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} 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.Duration=InternalMemory.DCPumpDuration_read();
  if (modes[rmode]==Else) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Mode=Constant;
    ReefAngel.DCPump.Speed=ElseMode(InternalMemory.DCPumpSpeed_read(),25,true );    // ElseMode on sync mode, Portal Speed Setting +/- 25%
  } else {
    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, 80, TempRelay );
pingSerial();

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

void DrawCustomGraph()
{
}
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;
  }
}
The skimmer is still running the schedule of my white leds (old MH Port)
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

ReefAngel.Relay.DelayedOn( Port6,120 );

That needs to be inside loop with the other ports. Otherwise from what I can see it would just stay off...but definitely wouldn't be doing what it's designed to do.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

THANK YOU!

I HAVE NOTICED THAT THERE ARE NEW MODES ON THE PORTAL FOR THE JAEBO.

HOW WOULD I ADD THESE TO THE RANDOM FUNCTION?

DO I ADD THE NAMES IN HERE-
// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { Else, Lagoon, Else, ReefCrest, ShortPulse, LongPulse, NutrientTransport };

??

WRITE THEM EXACTLY AS THE LIST IN THE PORTAL MODES? IS THERE A BRIEF DESCRIPTION OF THE MODES ANYWHERE?
Image
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

Yes, just write them as listed in the portal.

This is how I have them in my code...

Code: Select all

// These are the modes we can cycle through. You can add more and even repeat...
byte modes[] = { ReefCrest, Lagoon, Constant, TidalSwell, ShortPulse, LongPulse, Else, Gyre };
Really the only new ones are SineMode, Else and Gyre.

Else is a very random flow that emulates the Else mode of the Jebao pumps.
lnevo wrote:A gyre is like when you create a whirlpool in a swimming pool. At some point the momentum builds up and it has a strength of its own. The idea is one run pump in constant for x amount then switch the gyre into another direction.
AlanM wrote:Gyre is just like Long Pulse but with round edges. So it ramps up and back down while the opposing pump is off and then switches. The "duration" argument is in minutes, btw, not seconds, to support longer than 4 minutes. Since "Duration" is a byte number if it was in seconds it would overflow at 255 seconds.
I don't use SineMode it seems to mechanical to me.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

You will need the dev libraries to use the new modes.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: PaulTurner911 Code

Post by Sacohen »

That's correct. I've been using then for a while now and forgot that they were still only in the dev libraries.
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

i havent done anything with the dev libs.

My custom wave mode called "Else" today but stayed at 30% all day. Portal showed else, 70% duration 20...

what wouldnt ti be like reef crest or lagoon mode?
Image
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

Its been getting cold here and I decided to get a heater. I would like to have it on relay port 2 and only come on if the tank is below 74. Could someone please help code this?

Code: Select all

// This must be the first line
ReefAngel.Init(); //Initialize controller
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit ;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port6Bit | Port7Bit ;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts =  Port3Bit | Port7Bit ;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port3Bit | Port6Bit | Port7Bit ;
// 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
//Port 2 Heater
ReefAngel.ActinicLights( Port3 ); // Actinic LEDS
//Port4 Kalk/ATO
//Port5 Empty
ReefAngel.Relay.DelayedOn( Port6,120 );//Port6 Skimmer
ReefAngel.DayLights( Port7 ); // White LEDS
//Port8 Empty
//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() );

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

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



ReefAngel.DCPump.UseMemory = true;
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// 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[] = { Else, Lagoon, ReefCrest, ShortPulse, LongPulse, Gyre, 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) { 
  // First 15 minutes after feeding mode stops. Return Pump is off
  ReefAngel.Relay.Off(Port1);
  // First 15 minutes after feeding mode stops. Smart_NTM
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()-feeding<4500) { // 15 minutes plus 1 hour
  // Continue NTM for the next 60 minutes (75 minutes total)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Mode=NutrientTransport;
} 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.Duration=InternalMemory.DCPumpDuration_read();
  if (modes[rmode]==Else) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Mode=Constant;
    ReefAngel.DCPump.Speed=ElseMode(InternalMemory.DCPumpSpeed_read(),25,true );    // ElseMode on sync mode, Portal Speed Setting +/- 25%
  } else {
    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, 80, TempRelay );
pingSerial();

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

void DrawCustomGraph()
{
}


I think this is my most current code! Thanks
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: PaulTurner911 Code

Post by lnevo »

What temp do you want it to go off at? 74 is a bit low though, no?
Paulturner911
Posts: 288
Joined: Wed Jan 23, 2013 12:36 pm

Re: PaulTurner911 Code

Post by Paulturner911 »

I would like it to turn on at 74 and off at 76. I never though I would need a heater here. My last tank had halides and would keep it just under 80. Now I have a chiller, that I run stand alone at 78, and the heater i want on the RA at 75. I want the heater on the RA for failure protection in case it locks ON when it fails, and it will... They both have a +/- 2deg so I assume another degree or two buffer to keep them from cycling each other. Any and all help is appreciated!
Image
Post Reply