Different settings for 2 different DC Pumps.

Requests for new functions or software apps
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

You can take out the const int and the ElseMode function you have in your code.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

Ok so just remove all the code for Else Mode?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

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

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

As you know i don't know about coding.
I finally got my code to a point where it won't give me errors prior to the compiling when I remove the Else Mode Code.
It will check everything add then do the compiling and return a message that says
"Error Compiling" at the end.

Code: Select all

#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>fF
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include <InternalEEPROM.h>
#include <RA_NokiaLCD.h>f
#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 Kalkwasser         3
#define Pumps              4
#define Sump_Fan           5
#define DeNit_Doser        6
#define DeNit_Pump         7
#define ATO_Pump           8

#define Unused             Box1_Port1
#define Feeder             Box1_Port2
#define Unused             Box1_Port3
#define Unused             Box1_Port4
#define Unused             Box1_Port5
#define Unused             Box1_Port6
#define Unused             Box1_Port7
#define Dummy              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 T1 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=0;
ReefAngel.DCPump.WaterChangeSpeed=0;
ReefAngel.DCPump.ActinicChannel=Sync; // Now you're pump will be affected by the portal settings.
ReefAngel.DCPump.DaylightChannel=AntiSync; // Now you're pump will be affected by the portal settings.
ReefAngel.DCPump.AntiSyncOffset=85;

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

////// 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 );
  ReefAngel.WaterLevelATO(ATO_Pump,720,28,31);
  if ( hour()>=13 && hour()<21 )
  ReefAngel.PWM.SetChannel( 5, 0 );
  else
  ReefAngel.PWM.SetChannel( 5, PWMSlope(21,0,13,0,0,MoonPhase() ,60,0) );
 
  ////// Place your custom code below here
  
  //Mix Kalkwasser
static unsigned long Kalk_Mixing = 0;

static unsigned long stopTime = 0;
static byte prevWL=0;

if (ReefAngel.WaterLevel.GetLevel(1)>=100 && prevWL<100) {
  stopTime=now()+3600; // Get time one hour from now.
}
prevWL = ReefAngel.WaterLevel.GetLevel(1); // Store the water level

if (now() < stopTime) { ReefAngel.Relay.On(Kalkwasser); } else { ReefAngel.Relay.Off(Kalkwasser); } 
  
  //AutoFeeder
static unsigned long autofeeding = 0;

if ((now()%SECS_PER_DAY==64800)) //if it is 6 pm
{
ReefAngel.FeedingModeStart(); //START FEEDING MODE
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
if ( autofeeding == 0 ) {
autofeeding = now(); //set the time of the start of feeding to variable feeding
}

if ((now()-autofeeding>=60) && (now()-autofeeding<=61)) //if between 60 and 61 seconds has past
{
ReefAngel.Relay.On(Feeder); //TURN FEEDER RELAY ON
}
else 
{
ReefAngel.Relay.Off(Feeder); //TURN FEEDER RELAY OFF
}
} else {
if ( autofeeding > 0 ) {
autofeeding = 0;
}
}
  // DeNitrate Routine
int DeNit_Offset=3600; 
int DeNit_Repeat=21600;
int DeNit_Doser_Offset=1200;
int DeNit_Doser_Runtime=600;
int DeNit_Pump_Runtime=1200;
int DeNit_ATO_Offtime=1500;

// Pump comes on first
ReefAngel.Relay.Set(DeNit_Pump,(now()-DeNit_Offset)%DeNit_Repeat<DeNit_Pump_Runtime);  // Runs denitrator pump
// Doser comes on second
ReefAngel.Relay.Set(DeNit_Doser,((now()-DeNit_Offset)-DeNit_Doser_Offset)%DeNit_Repeat<DeNit_Doser_Runtime); // Runs denitrator doser
   
  // Disable ATO
if ( (now()-3600)%21600<DeNit_ATO_Offtime) ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);

  // Delay WL ATO after water change and DeNit_Dosing
  static time_t wcTimer=0;
  if (ReefAngel.DisplayedMenu == WATERCHANGE_MODE) wcTimer=now();

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

    // Track Salinity low duration
    static unsigned long lastGoodSal;
    static boolean lowSalFlag;
   
    // Salinity is good, update counter
    if (ReefAngel.Params.Salinity>=335) lastGoodSal=now(); 
    
    // Counter hasn't been updating in 300 seconds..
    if (now()-lastGoodSal>300) {
      lowSalFlag=true; // Salinity is definitely below 33.5
    } else {
      lowSalFlag=false; // Salinity back to normal
    }
    
    // Disable ATO if lowSalFlag is true
    if (lowSalFlag) ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);
    
  // Disable ATO if ATO High IsActive()
  if (ReefAngel.HighATO.IsActive()) 
    ReefAngel.WaterLevelATO(ATO_Pump,720,0,1);
    

// 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, Lagoon, Constant, TidalSwell, ShortPulse, LongPulse, Else };

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<3600) { 
  // Continue NTM for the 60 minutes
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
  ReefAngel.DCPump.Mode=NutrientTransport;
} else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
  // Night mode (go to 30%)
  ReefAngel.DCPump.UseMemory=false;
  ReefAngel.DCPump.Duration=InternalMemory.DCPumpDuration_read();
  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();
  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( "Sacohen","S3tho31o" );
  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,57, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,57, ReefAngel.WaterLevel.GetLevel() );

ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,66,66, "WL 1:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,66, ReefAngel.WaterLevel.GetLevel(1) );

//Salinity  
  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()
{
}
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Just Error Compiling? Odd.i'll take a look tonight
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

Yeah. That's all it says on the bar.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

So I got "Error Compiling" as well with the following info though in the box at the bottom..

/Users/lnevo/Documents/Arduino/libraries/ReefAngel/ReefAngel.cpp: In member function 'void ReefAngelClass::SetDCPumpChannels(byte, byte)':
/Users/lnevo/Documents/Arduino/libraries/ReefAngel/ReefAngel.cpp:2333: error: name lookup of 'a' changed for new ISO 'for' scoping
/Users/lnevo/Documents/Arduino/libraries/ReefAngel/ReefAngel.cpp:2322: error: using obsolete binding at 'a'
/Users/lnevo/Documents/Arduino/libraries/ReefAngel/ReefAngel.cpp:2333: error: expected primary-expression before ')' token

I think I hit that before and fixed it, maybe it forgot to get in the commit? Checking it now....
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

What are you two working on? You want one pump running ReefCrest while another runs Nutrient Transport? lol
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Ok. Fixed it. Not sure why I was able to compile on my test code. Guess it would depend on what channels were used, I think in my I was just doing daylight/actinic.

Anyway, re-download the update at here
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

AlanM wrote:What are you two working on? You want one pump running ReefCrest while another runs Nutrient Transport? lol
No, just the ability to slow one of the pumps down if it's overpowered.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

It compiled now.

I had all that stuff at the bottom too, but there is always stuff running down there.
I pay attention to what's in the bar,

I'm going to upload it now and see how it works.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

It uploaded and either it's not working properly or it;s not working because my pumps are coded to run at 30% at night.

Both the portal and Android show the pumps running at 29% rather than the 30 they are coded at during the night.

I tried it with an offset of 85% and then 50% and both the same results.

Is it because of this line of code....

Code: Select all

} else if (now()%SECS_PER_DAY<43200 || now()%SECS_PER_DAY>=79200) { // 12pm / 10pm
  // Night mode (go to 30%)
that puts it at 30% between 10pm and noon.

If so why is it at 29% and not 30%?

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

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

I've also noticed that other readings are off.

The main WL sensor is reading 29% where it would normally be 32% where the water level in the sump sits now.

Also the multi WL sensors are not reporting now.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Can you try with Roberto's dev library and see if it's the same?

One reason it could say 29% instead of 30% is that everything is high resolution now. So there may be some rounding issues somewhere. As far as the WL, I don't believe any of that has been touched... I dont' recall seeing any commits that would change that.

Also try with the offset set to 100. That would be 100% and should have no change on what your pumps were at.

Finally one other thing to try is to run the wizard and just set a generic code (without all the random stuff and things we have in yours...) to see what the result is...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

I'll try later today.
I have to try a repair a pool pump today.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

Pumps are not high resolution. But I always see 29 instead of 30 on mine too. Maybe there is an off by 1 error somewhere in dev.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Good to remember...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

I tried Robertos Dev Code and got the same issues.
29% of ump speeds and main WL sensor.
The Multi WL is not displaying.

Obviously I had to pull the offset out to use Roberto's libraries, but I did try it at 100% before switching to his libraries and it still showed 29%.

I haven't tried an INO from the wizard yet.

The wife it bugging me to look at the pool pump.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

Wait, so you set it to 100 and it shows 29? I thought it was showing 29 when you set it to 30.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

The offset of the pumps speed is set to 100% or no offset as opposed to 50% (half speed).

The 30% is what the pump is running at.
It supposed to run at 30% over night and it is running at 29%.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Different settings for 2 different DC Pumps.

Post by rimai »

I noticed that too.
The high resolution may be messing with the rounding.
Roberto.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

Yep. Probably some change I introduced for reporting the value set on the daylight and actinic channels. It multiplies by 2.55 to send the value to the port, but then divides by 2.55 to report it and I bet there's an integer truncation happening in the math that keeps it at 29 instead of 30 when it chops off 29.8 in to just 29.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

Testing fix now. If it works. I'll send a pull request in to /dev. I realized that we used to divide by 2.55, now by 40.95, so it's more likely to be a round error.
AlanM
Posts: 263
Joined: Wed Jan 01, 2014 7:26 am

Re: Different settings for 2 different DC Pumps.

Post by AlanM »

OK. Think it's fixed. Submitted pull against /dev. I believe it was just a display error, not that it was actually at 29% when you asked for 30.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

I think it also may not actually update the channel speed so we may not see the offset..the best way to see if its working is by looking at the pumps..i'll have to check the functionality again tonight...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

The important thing about the patch too is whether or not its even setting sync/antisync right at all, because i updated the whole code that outputs to the channels. See if elsemode works as expected with offset set to 100
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

No, I'm wrong. It should update the anti-sync channel with the new offset speed. The time schedule should not affect it the way you have it written... confusing.
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

Happy Labor Day all.
Sorry didn't really get to try anything yesterday.
Lee;

You want me to try Else Mode @ 100% offset?

Is that correct?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Yes i want to know if its behaving as expected. Then try for some offsets...it should be noticable i think if you went to 50 or 25 or 10 or even 0 from there...
User avatar
Sacohen
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL

Re: Different settings for 2 different DC Pumps.

Post by Sacohen »

Ok. I'll try it later. We're having a little Labor Day partyt today, so afterwards I'll try it.
Post Reply