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

Different settings for 2 different DC Pumps.

Post by Sacohen »

Roberto;

I don't think there is a was to has different settings (speed, duration or offset) for differrent DC pumps.

For example I have a WP-25 and a WP-40. I want the 40 to run cosmith71 ElseMode from the DCPump mode now that lenvo reworked my code to handle the denitrification chamber and ATO settings better.

He set the Jebao pumps to use the DCPump libraries and the portal if I wanted to change them.

My problem is that both pumps are using the same settings.

The WP-40 needs to be set lower than the WP-25.

If I put the setting at a good point for the 40 then the 25 runs to slow and may even stop. (it doesn't like to run below 30%).

lenvo suggested adding a per channel offset to handle mixed pumps.

Anything like this possible?

Thanks;
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Different settings for 2 different DC Pumps.

Post by rimai »

You will need to code the dimming channels independently instead of dcpump class

Sent from my SPH-L710 using Tapatalk 4
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Roberto what about a setting for the anti sync channel.. Otherwise its a bit of custom coding for every function etc...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Different settings for 2 different DC Pumps.

Post by rimai »

Not with the dcpump class.
It will set the percentage .and apply it inside the refresh () function.
If you use the pwm class, you can set it to whatever you want before it is applied.

Sent from my SPH-L710 using Tapatalk 4
Roberto.
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 PWM setting is the way I had it before.
change the
So with the DCPump class you can't have different settings, but with the PWM class you can't use the portal to change the modes.

I think I may have found a happy medium for both pumps.

Even though I have them set to Sync and AntiSync they are reading as running the same on the portal and phone.
I did have them working when they were set to true and false, but that was on lnevo's first code, when he fixed some stuff and I re-entered the info for the 2nd pump I can't get them to work in Anti-Sync.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Different settings for 2 different DC Pumps.

Post by rimai »

You could still use the portal to change the settings even if you use the PWM class...
But you would have to recreate everything that was already created behind the scenes.
Something like this:

Code: Select all

if (InternalMemory.DCPumpMode_read()==ReefCrest)
{
ReefAngel.PWM.SetActinic(ReefCrestMode(InternalMemory.DCPumpSpeed_read()-30,10,Sync)); // Internal memory Speed minus 30%
ReefAngel.PWM.SetDaylight(ReefCrestMode(InternalMemory.DCPumpSpeed_read(),10,Sync));
}
And you would have to do this for each mode.
That's what the libraries does behind the scenes.
}
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Thad why the offset should be implemented inside the dcpump class...i'd submit a patch if i had time...
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 have an idea how to do this without a lot of code. Let me think on it.
meadowsad
Posts: 53
Joined: Sat Jun 15, 2013 9:56 am

Re: Different settings for 2 different DC Pumps.

Post by meadowsad »

Any progress on this? :)

This is exactly what I was trying to do with my Tunzes a month or so ago. I wanted one running LongPulse and one running Constant. I ended up getting this working but it felt very cobbled together lol.

It would be awesome if we could have the channels performing at different speeds or even different wave patterns while still using the dcpump class.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Different settings for 2 different DC Pumps.

Post by lnevo »

Would be impossible to have them use dcpump class and be in two different modes. Speed is one thing...that would have been an offset. I forgot my idea and havent had time to work on this.

You could do what your asking but one pump would not be able to use the dcpump class. You could base the independent pump on the settings for dcpump though...
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.
Post Reply