Different settings for 2 different DC Pumps.

Requests for new functions or software apps
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 »

Anything new on this front?

Lee you said you may have an idea, but I know you have very little time and may have not gotten to it.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Looking at the code, it would be very complicated without a complete overhaul with how it's being done.

I would recommend at this point in time, to do it manually without the DCPump class if you need this functionality.
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 don't need it, but it's one of those things that would be nice to be able to do.

I know a couple of others have asked about it too.

My setup is working fine.
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 I can do something and it would greatly simplify the code, but I don't have a DCPump and no way to test it. If someone is willing to try it, I can put up a patch...
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 it since I'm the one asking for it.
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, Steve, you ask and you shall receive.

You can activate the offset for the AntiSync channel by specifying the percent power of the other channel by using a statement like this:

Code: Select all

    ReefAngel.DCPump.AntiSyncOffset=75;
This is a percent, so if you were at Constant 100, the Sync channel would be 100 and the AntiSync would be 75.
If you were at Constant 50, the Sync would be at 50 while the AntiSync would be at 37.5 (whatever that rounds to as a byte)

Download the branch from here

I basically cleaned up all of the case statements for each mode. It should make adding a new modes much easier. just set the Sync and AntiSync speeds accordingly and at the end of the case statement it will now call ReefAngel.SetDCPumpChannels(byte SyncSpeed,byte AntiSyncSpeed) which will apply the DCPump.Threshold and the AntiSyncOffset to the speeds and write to the proper channels. There is now also one function that writes the speed to the channel which will make it much easier to add future channels to the list. It should also make adding future channel modes easier, like back-wall or something :)

Let me know if you have any questions. This compiles for me and I have confidence that it should work.
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 »

Thanks a lot Lee.
I'll try it tonight or over the weekend.
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 downloaded the libraries and replaced my previous version of them.

1st of all when I check the Library version it stall reads 1.1.0. Is this a change to 1.1.0 or 1.1.1?

2nd the ReefAngel.DCPump.AntiSyncOffset=75; goes in the setup section.
I put it here...

Code: Select all

// 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=75;
It seems to compile fine until it gets to the point of the random wave mode.

I get the following error "expected unqualified-id before numeric constant"

Code: Select all

// Add Else Mode definition..
const int Else=16;
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 error message came up when I was trying out the new libraries to test the DNS server.
So it's not related to what you modified for the DCPump Offset.

There is something in (or noti in) the libraries on GITHub that seems to be causing a problem with the Else Mode definition for the Random wave modes.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

ElseMode is now built in. :)
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%.
Post Reply