Basic questions most any of you can answer I'm sure...

Do you have a question on how to do something.
Ask in here.
Post Reply
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

I got my RA+ pwm and wifi setup and ran the RA wizard that got my simple stuff running (heaters, reactors, skimmer, etc) and things are working good.

Running libraries v1.0.9


I have two WP40 pumps that I want to control. I bought two cables for them and they are plugged into the two dimming ports on the relay (correct place?). To set them up I use the regular reef angel arduino sketch program right? I see under sketch->import library-> that there is a DCpump which i clicked put it all it puts into the sketchbook is - #include <DCPump.h> what does that do? Is that what I want to do for these WP40 pumps?


Now, I see a reference to dc pumps on the portal...can I set them up entirely from there or what? If I click to save on the internal memory-> dcpumps tab does that upload/save settings to my RA+ or ???


...and while on the question about the portal...none of the settings under the internal memory option list match how I set my RA+ up using the wizard - why? It appears they are all the original default settings but how do the things listed here work with my unit? (the portal is working as my info is displayed under the dashboard correctly though)


I also have two RA dosing pumps that I want to control better (although for the moment they are setup with a very basic setting through the wizard). Would I do that through a code on the regular reef angel arduino sketch program too?


Sorry for what is redundant questions you've heard a million times already...

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

Re: Basic questions most any of you can answer I'm sure...

Post by lnevo »

First off, can you post your code. When you run the wizard you should get some options to say how each channel is set as Sync / AntiSync or None.

Second is your wifi working properly now? Can you browse the IP address of the ra wifi?

What do you see in the upper right on the portal for connection status?
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

lnevo wrote:First off, can you post your code. When you run the wizard you should get some options to say how each channel is set as Sync / AntiSync or None.

Second is your wifi working properly now? Can you browse the IP address of the ra wifi?

What do you see in the upper right on the portal for connection status?

I'll check for code when I get home later.


Do I want sync AntiSync or None?

Wifi is working great now! Portal connects and updates good to go. :smile:
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Basic questions most any of you can answer I'm sure...

Post by lnevo »

Depends on how you want the. If both pumps are set to sync they will be running at the same speeds all the time. If one is sync and one is anti-sync they will work together as one goes up the other goes down and vice-versa. It's all about what you want.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic questions most any of you can answer I'm sure...

Post by rimai »

If you choose the wizard, you can pick the DC pump option and it should generate the code for you.
You don't need to manually import the library.
In order to use the internal memory section of the portal, you must go with the in the memory settings when creating your code with the wizard.
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

rimai wrote:If you choose the wizard, you can pick the DC pump option and it should generate the code for you.
You don't need to manually import the library.
In order to use the internal memory section of the portal, you must go with the in the memory settings when creating your code with the wizard.

How would I code it if I want the pumps to randomly change modes throughout the day and say power way down at night? Can the wizard do that?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic questions most any of you can answer I'm sure...

Post by rimai »

After you generate your code, you can modify it to do change the mode through the day.
I would suggest you start with the wizard and make sure everything works and then go to customizing the code.
There are several posts in the forums about the subject.
Here are a couple:
http://forum.reefangel.com/viewtopic.ph ... our#p26993
http://forum.reefangel.com/viewtopic.ph ... our#p27828
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

Ok I got both pumps hooked and ran the wizard. Here the code as it sits now:


#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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 810 );

// 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.StandardHeater( Port1,795,800 );
ReefAngel.StandardHeater( Port2,793,800 );
ReefAngel.StandardLights( Port3,9,0,23,0 );
ReefAngel.StandardLights( Port4,11,0,21,0 );
ReefAngel.DosingPumpRepeat( Port7,0,720,20 );
ReefAngel.DosingPumpRepeat( Port8,0,720,10 );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( NutrientTransport,60,10 );
ReefAngel.DCPump.DaylightChannel = AntiSync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here


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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// pH Expansion
ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );
pingSerial();

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

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

void DrawCustomGraph()
{
}






WP40 code from your link (this would cause the pumps to change modes throughout the day I believe)



if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
ReefAngel.PWM.SetDaylight(30);
ReefAngel.PWM.SetActinic(30);
}
else if (hour()>=6 && hour()<11) {
ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
} else if (hour()>=11 && hour()<15) {
ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(70,20,false) ); // ReefCrest at 70% +/- 20% on anti-sync mode
} else if (hour()>=15 && hour()<18) {
ReefAngel.PWM.SetDaylight( NutrientTransportMode(30,60,6000,true) );
ReefAngel.PWM.SetActinic( NutrientTransportMode(30,60,6000,false) );
} else if (hour()>=18 && hour()<20) {
ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% +/- 20% on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(70,20,false) ); // ReefCrest at 70% +/- 20% on anti-sync mode
} else if (hour()>=20 && hour ()<23) {
ReefAngel.PWM.SetDaylight( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(45,true) ); // TidalSwell at 45% on sync mode
} else {
ReefAngel.PWM.SetDaylight(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
ReefAngel.PWM.SetActinic(SineMode(15,40,30,true) ); //SineMode from 15% to 40% for 30 seconds on sync mode
}




Now if I want to add that code I would copy/paste that into this part of my original code right?

ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here
PASTE IN HERE?

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




Then I upload all that original code plus new code to the RA unit?


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

Re: Basic questions most any of you can answer I'm sure...

Post by lnevo »

That is older code that doesnt use the DCPump class. Also you are currently locking your DCPump to use nutrient transport mode. Also you have both pumps set to antisync. I suggest making one Sync and the other AntiSync or both Sync. I wouldnt do both anti as anti is the secondary pump for each mode.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

lnevo wrote:That is older code that doesnt use the DCPump class. Also you are currently locking your DCPump to use nutrient transport mode. Also you have both pumps set to antisync. I suggest making one Sync and the other AntiSync or both Sync. I wouldnt do both anti as anti is the secondary pump for each mode.
Ok. It seemed like within the wizard you had to choose one mode and no option for multiple modes there, right?

Would you happen to have a link to current code that would cycle through different modes throughout the day?
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

lnevo wrote:That is older code that doesnt use the DCPump class.



Is this code current?




if (hour()>=8 && hour()<11)
{
vtechmode=6;
ReefAngel.PWM.SetDaylight( TidalSwellMode(40,true) ); // Tidal Swell at 40% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(40,false) ); // Tidal Swell at 40% on anti-sync mode
}
else if (hour()>=11 && hour()<12)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ReefCrestMode(50,20,true) ); // ReefCrest at 50% + - 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(50,20,false) ); // ReefCrest at 50% + - 20 on anti-sync mode
}
else if (hour()>=12 && hour()<13)
{
vtechmode=0;
ReefAngel.PWM.SetDaylight( millis()%1000>800?80:0); // WaveMode on sync mode
ReefAngel.PWM.SetActinic( ElseMode(70,30,true) ); // ElseMode at 70 on anti-sync mode
}
else if (hour()>=13 && hour()<14)
{
vtechmode=2;
ReefAngel.PWM.SetDaylight( ReefCrestMode(70,20,true) ); // ReefCrest at 70% + - 20 on sync mode
ReefAngel.PWM.SetActinic( ReefCrestMode(70,20,false) ); // ReefCrest at 70% + - 20 on anti-sync mode
}
else if (hour()>=15 && hour()<18)
{
vtechmode=0;
ReefAngel.PWM.SetDaylight( ElseMode(70,30,true) ); // Else on sync mode
ReefAngel.PWM.SetActinic( millis()%1000>800?80:0); // Wave on anti-sync mode
}
else if (hour()>=18 && hour()<21)
{
vtechmode=5;
ReefAngel.PWM.SetDaylight( NutrientTransportMode(77,90,3000,true) ); // Nutrient Transport on sync mode
ReefAngel.PWM.SetActinic( NutrientTransportMode(77,90,3000,false) ); // Nutrient Transport on anti-sync mode
}
else if (hour()>=21 && hour()<24)
{
vtechmode=1;
ReefAngel.PWM.SetDaylight( millis()%1000>800?70:0); // Wave on sync mode
ReefAngel.PWM.SetActinic( ElseMode(70,30,true) ); // Else on anti-sync mode
}
else
{
vtechmode=4;
ReefAngel.PWM.SetDaylight( LongPulseMode(40,40,10,true) ); // Long pulse at 40% with 10s pulse on syncy mode
ReefAngel.PWM.SetActinic( LongPulseMode(40,40,10,false) ); // Long pulse at 40% with 10s pulse on on anti-sync mode
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE)
{
ReefAngel.PWM.SetActinic(0);
ReefAngel.PWM.SetDaylight(0);
}
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic questions most any of you can answer I'm sure...

Post by rimai »

Try something like this:

Code: Select all

if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}
else if (hour()>=8 && hour()<11)
ReefAngel.DCPump.SetMode( NutrientTransport,60,10 );
else if (hour()>=11 && hour()<12)
ReefAngel.DCPump.SetMode( ReefCrestMode,60,10 );
else if (hour()>=12 && hour()<20)
ReefAngel.DCPump.SetMode( TidalSwellMode,60,10 );
else
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

rimai wrote:Try something like this:

Code: Select all

if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}
else if (hour()>=8 && hour()<11)
ReefAngel.DCPump.SetMode( NutrientTransport,60,10 );
else if (hour()>=11 && hour()<12)
ReefAngel.DCPump.SetMode( ReefCrestMode,60,10 );
else if (hour()>=12 && hour()<20)
ReefAngel.DCPump.SetMode( TidalSwellMode,60,10 );
else
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}

Ok.

The way that looks it would tell the pumps what to do between hours 8-20 each day right? If so, what will pumps do for the other 4 hours?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic questions most any of you can answer I'm sure...

Post by rimai »

That's what the last else is for
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

rimai wrote:That's what the last else is for


Oh ok. Thanks.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

rimai wrote:Try something like this:

Code: Select all

if (hour()<8)
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}
else if (hour()>=8 && hour()<11)
ReefAngel.DCPump.SetMode( NutrientTransport,60,10 );
else if (hour()>=11 && hour()<12)
ReefAngel.DCPump.SetMode( ReefCrestMode,60,10 );
else if (hour()>=12 && hour()<20)
ReefAngel.DCPump.SetMode( TidalSwellMode,60,10 );
else
{
ReefAngel.PWM.SetActinic(0);
 ReefAngel.PWM.SetDaylight(0);
}



I tried to use this and it keeps giving me an error message...(see pic)

I copied and pasted your code into the wizard setup code sketch that i had from my initial setup into the area that is listed as custom code.
Attachments
Untitled.jpg
Untitled.jpg (240.68 KiB) Viewed 4170 times
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Basic questions most any of you can answer I'm sure...

Post by rimai »

Sorry, just remove the Mode in ReefCrestMode and TidalSwellMode
Roberto.
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

The code is working.


What exactly do the different modes do? I know what fast pulse and slow pulse do but what about the others? It seemed like tide mode made the constant speed of the pumps slowly increase over time...


What can I do to make the pumps run more random as far as flow? Is there a code to run the pumps in the original random else mode?

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

Re: Basic questions most any of you can answer I'm sure...

Post by Sacohen »

There is not code to run the pumps in the original Else mode, but cosmith71 created some code that is very random, maybe even better then the original else mode.

Here is the thread...

http://forum.reefangel.com/viewtopic.php?f=3&t=3481

This was originally written prior to the DCPump class.

If you look at my code here it is in there written (with help from lnevo) for the DCPump class.

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>

// Define Relay Ports by Name
#define Actinic_Lights     1
#define Day_Lights         2
#define Unused             3
#define Pumps              4
#define Sump_Fan           5
#define DeNit_Pump         6
#define DeNit_Doser        7
#define Unused             8

#define ATO_Pump           Box1_Port1
#define Moon_Lights        Box1_Port2
#define Unused             Box1_Port3
#define Unused             Box1_Port4
#define Unused             Box1_Port5
#define Unused             Box1_Port6
#define Unused             Box1_Port7
#define Unused             Box1_Port8


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

// Does not need to be global.
// unsigned long ATOUpdate=0;

////// 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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 825 );
//Set Standard Menu
ReefAngel.AddStandardMenu();

// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=20;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.ActinicChannel=Sync; // Now you're pump will be affected by the portal settings.

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

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


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

void loop()
{
  ReefAngel.StandardLights( Actinic_Lights,12,0,22,0 );
  ReefAngel.StandardLights( Day_Lights,13,0,21,0 );
  ReefAngel.StandardLights( Sump_Fan,13,0,21,0 );

  ////// Place your custom code below here
  ReefAngel.Relay.Set( Moon_Lights, !ReefAngel.Relay.Status( Actinic_Lights ) );

  ReefAngel.Relay.Set(DeNit_Doser,(now()-3600)%21600<1200);       // Runs for 1200s every 21600 seconds
  ReefAngel.Relay.Set(DeNit_Pump,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset

  // ReefAngel.Relay.DelayedOn( ATO_Pump,10 );
  // ReefAngel.WaterLevelATO(ATO_Pump,720,32,32); // Enable ATO the ATO

  // Delay WL ATO after water change and DeNit_Dosing
  static time_t wcTimer=0;
  static time_t denitTimer=0;
  
  if (ReefAngel.DisplayedMenu == WATERCHANGE_MODE) wcTimer=now();
  if (ReefAngel.Relay.Status(DeNit_Pump)) denitTimer=now();
  
  // Start with defined WaterLevel ATO 
  ReefAngel.WaterLevelATO(ATO_Pump,720,32,34); 
  // You should see a much more stable pump usage with a wider threshold 32-34.
  // Also since the water level measure can fluctuate it could lead to a lot of on/off cycling
  // which could also cause the relay to be on more often and it we reboot, we may maintain the state we don't want...
  // Especially if it could take up to 30 seconds to reboot :)
  
  // First 10 minutes after WC disable ATO
  if (now()-wcTimer >= 0 && now()-wcTimer < 600)
    ReefAngel.Relay.Off(ATO_Pump); 

  // First 5 minutes after DeNit_Doser was on
  if (now()-denitTimer >= 0 && now()-denitTimer < 300)
    ReefAngel.Relay.Off(ATO_Pump); 

  // Disable ATO if Salinity is below 33.5. 
  if (ReefAngel.Params.Salinity<335) 
    ReefAngel.Relay.Off(ATO_Pump); 
    
  // Disable ATO if ATO High IsActive()
  if (ReefAngel.HighATO.IsActive()) 
    ReefAngel.Relay.Off(ATO_Pump);
    
  // Modified to use the DCPump class
  if (hour()<12 || hour()>=22) {
    ReefAngel.DCPump.UseMemory=false;                
    ReefAngel.DCPump.Mode=Constant;                  
    ReefAngel.DCPump.Speed=30;
  } else if (InternalMemory.DCPumpMode_read()==Custom) {
    ReefAngel.DCPump.UseMemory=false;
    ReefAngel.DCPump.Mode=Constant;                  // Won't really be constant. See next line.
    ReefAngel.DCPump.Speed=ElseMode(40,20,true );    // ElseMode on sync mode, 40 +/- 20%
  } else  {
    ReefAngel.DCPump.UseMemory=true;                 // Use whatever is in the portal
  }

  // No longer necessary since we've defined the speeds for these modes in setup();
  //
  // if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(20);
  // if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);

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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,66, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel() );
  ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
  strcat(text,"  ");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,39,75,"Salinity:");
  ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,99,75,text);
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
pingSerial();
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 104, TempRelay);

// 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;
  }
}
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

Sacohen wrote:There is not code to run the pumps in the original Else mode, but cosmith71 created some code that is very random, maybe even better then the original else mode.

Here is the thread...

http://forum.reefangel.com/viewtopic.php?f=3&t=3481

This was originally written prior to the DCPump class.

If you look at my code here it is in there written (with help from lnevo) for the DCPump class.








// Modified to use the DCPump class
if (hour()<12 || hour()>=22) {
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==Custom) {
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=Constant; // Won't really be constant. See next line.
ReefAngel.DCPump.Speed=ElseMode(40,20,true ); // ElseMode on sync mode, 40 +/- 20%
} else {
ReefAngel.DCPump.UseMemory=true; // Use whatever is in the portal
}

// No longer necessary since we've defined the speeds for these modes in setup();
//







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;
}
}[/code]

So... Would it be those two sections of code I would need to add???
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Basic questions most any of you can answer I'm sure...

Post by Sacohen »

I believe you would need to add or make sure it is in the code what I have highlighted red...
List code is set to run the "Else" mode from 12pm to 10pm and then run a constant 30% at night and it drops to 20% during feeding and 0% during Water Changes.

#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>

// Define Relay Ports by Name
#define Actinic_Lights 1
#define Day_Lights 2
#define Unused 3
#define Pumps 4
#define Sump_Fan 5
#define DeNit_Pump 6
#define DeNit_Doser 7
#define Unused 8

#define ATO_Pump Box1_Port1
#define Moon_Lights Box1_Port2
#define Unused Box1_Port3
#define Unused Box1_Port4
#define Unused Box1_Port5
#define Unused Box1_Port6
#define Unused Box1_Port7
#define Unused Box1_Port8


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

// Does not need to be global.
// unsigned long ATOUpdate=0;

////// 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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port4Bit;
ReefAngel.WaterChangePortsE[0] = Port1Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port1Bit | Port2Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit;
// Use T2 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 825 );
//Set Standard Menu
ReefAngel.AddStandardMenu();

// Feeeding and Water Change mode speed
ReefAngel.DCPump.FeedingSpeed=20;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.ActinicChannel=Sync; // Now you're pump will be affected by the portal settings.

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

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


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

void loop()
{
ReefAngel.StandardLights( Actinic_Lights,12,0,22,0 );
ReefAngel.StandardLights( Day_Lights,13,0,21,0 );
ReefAngel.StandardLights( Sump_Fan,13,0,21,0 );

////// Place your custom code below here
ReefAngel.Relay.Set( Moon_Lights, !ReefAngel.Relay.Status( Actinic_Lights ) );

ReefAngel.Relay.Set(DeNit_Doser,(now()-3600)%21600<1200); // Runs for 1200s every 21600 seconds
ReefAngel.Relay.Set(DeNit_Pump,((now()-3600)-1200)%21600<1200); // Runs for 1200s every 21600 seconds with 1200s offset

// ReefAngel.Relay.DelayedOn( ATO_Pump,10 );
// ReefAngel.WaterLevelATO(ATO_Pump,720,32,32); // Enable ATO the ATO

// Delay WL ATO after water change and DeNit_Dosing
static time_t wcTimer=0;
static time_t denitTimer=0;

if (ReefAngel.DisplayedMenu == WATERCHANGE_MODE) wcTimer=now();
if (ReefAngel.Relay.Status(DeNit_Pump)) denitTimer=now();

// Start with defined WaterLevel ATO
ReefAngel.WaterLevelATO(ATO_Pump,720,32,34);
// You should see a much more stable pump usage with a wider threshold 32-34.
// Also since the water level measure can fluctuate it could lead to a lot of on/off cycling
// which could also cause the relay to be on more often and it we reboot, we may maintain the state we don't want...
// Especially if it could take up to 30 seconds to reboot :)

// First 10 minutes after WC disable ATO
if (now()-wcTimer >= 0 && now()-wcTimer < 600)
ReefAngel.Relay.Off(ATO_Pump);

// First 5 minutes after DeNit_Doser was on
if (now()-denitTimer >= 0 && now()-denitTimer < 300)
ReefAngel.Relay.Off(ATO_Pump);

// Disable ATO if Salinity is below 33.5.
if (ReefAngel.Params.Salinity<335)
ReefAngel.Relay.Off(ATO_Pump);

// Disable ATO if ATO High IsActive()
if (ReefAngel.HighATO.IsActive())
ReefAngel.Relay.Off(ATO_Pump);

// Modified to use the DCPump class
if (hour()<12 || hour()>=22) {
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=Constant;
ReefAngel.DCPump.Speed=30;
} else if (InternalMemory.DCPumpMode_read()==Custom) {
ReefAngel.DCPump.UseMemory=false;
ReefAngel.DCPump.Mode=Constant; // Won't really be constant. See next line.
ReefAngel.DCPump.Speed=ElseMode(40,20,true ); // ElseMode on sync mode, 40 +/- 20%
} else {
ReefAngel.DCPump.UseMemory=true; // Use whatever is in the portal
}

// No longer necessary since we've defined the speeds for these modes in setup();
//
// if( ReefAngel.DisplayedMenu==FEEDING_MODE ) ReefAngel.PWM.SetActinic(20);
// if( ReefAngel.DisplayedMenu==WATERCHANGE_MODE ) ReefAngel.PWM.SetActinic(0);

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

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

void DrawCustomMain()
{
int x,y;
char text[10];
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,66, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel() );
ConvertNumToString(text, ReefAngel.Params.Salinity, 10);
strcat(text," ");
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,39,75,"Salinity:");
ReefAngel.LCD.DrawText(DefaultFGColor,DefaultBGColor,99,75,text);
pingSerial();

// Main Relay Box
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
pingSerial();
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox(12, 104, TempRelay);

// 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;
}
}
DavidinGA
Posts: 83
Joined: Fri Jun 07, 2013 11:26 am

Re: Basic questions most any of you can answer I'm sure...

Post by DavidinGA »

Oh ok. Thanks
Post Reply