Prevent Dosing Pump "ON" Override

Do you have a question on how to do something.
Ask in here.
Post Reply
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Prevent Dosing Pump "ON" Override

Post by jolt »

Not sure how it happened, but I found one of my dosing pumps to be overridden "ON".

Has anyone else already written a routine to prevent a dosing pump from remaining indefinitely overridden as "ON" (indefinite override of "OFF" should always be allowed though)
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

Yes. I added into the library an option to define ports that are never allowed to be overridden. It works for both on and off though...however you can change the value on the fly using a few different methods...so for me i turn an unused port on and then i can override my dosing pumps. When i'm done i turn that port back off. Loon for the OverridePorts statement in my INO for an example
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

Thanks, I'll give it a look.
Image
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

Hi Lee -

I tried grabbing your code for this but I am obviously missing something important in how the RA build process works.

I stuck this in my loop() function (dosers on ports 7 and 8)

Code: Select all

    ////// Place your custom code below here
    // don't allow doser ports to be overridden
    ReefAngel.OverridePortsE[6] = 0;
    ReefAngel.OverridePortsE[7] = 0;   
    ////// Place your custom code above here
I get compile errors:

jims_sketch_mar08:81: error: 'class ReefAngelClass' has no member named 'OverridePortsE'

I notice that the definition of OverridePortsE in ReefAngel.h is surrounded by #ifdef OVERRIDE_PORTS

What I can't figure out is where to define that. I don't see a corresponding #define in your code. Tried putting it in ReefAngel_Features.h but it just gets blown away, apparently by the IDE. Tried hacking it into Globals.h, and no luck

What's the magic?

Than ks,
Jim
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

Theres a function i call...think its in setup or maybe in that code block that "activated" that feature...

I think its ReefAngel.AllowOverride() ? I forget...but you can figure it out if you look in feature.txt
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

ReefAngel.AddPortOverrides();
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

Hmmm, I think something is still missing in my understanding/execution of this simple task.

I added this to my sketch, as you suggested:

Code: Select all

    ////// Place your custom code below here
    ReefAngel.AddPortOverrides(); 
    ReefAngel.OverridePortsE[6] = 0;
    ////// Place your custom code above here
Still getting the same error message:
jims_sketch_mar08:81: error: 'class ReefAngelClass' has no member named 'OverridePortsE'

I see that this function is defined in ReefAngel.h as follows:

Code: Select all

	void inline AddPortOverrides() {};
But even after adding this call to my code the definition of OverridePortsE is still not enabled, apparently due to this #define structure in ReefAngel.h:

Code: Select all

#ifdef OVERRIDE_PORTS
	byte OverridePortsE[MAX_RELAY_EXPANSION_MODULES];
#endif  // OVERRIDE_PORTS
So can someone explain to me the "magic" that leads from calling an inline function (ReefAngel.AddPortOverrides()) in my sketch and having OVERRIDE_PORTS auto-magically defined for the C preprocessor?? I'm sure there is something going on under the hood, but it is not obvious to me...

I am happy to read through an old thread if I knew what I was looking for, so if it exists please point me in the right direction ....

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

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

Can you look at your feature.txt file and see if you have a line for OVERRIDE_PORTS in it?
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

It took me a while to find this file, I was not aware it existed. I found it in a folder called 'update', so I assume that is the one you are referring to.

No text 'OVERRIDE_PORTS' in that file.

Found your discussion of that here:

http://forum.reefangel.com/viewtopic.php?f=11&t=2328

Added the line to feature.txt:

Code: Select all

OVERRIDE_PORTS,ReefAngel.AddPortOverrides(),Override Port RelayMasks
Now this shows up in ReefAngel_features.txt:
  • OVERRIDE_PORTS,ReefAngel.AddPortOverrides(),Override Port RelayMasks
But, sadly, still the same compile error. Really scratching my head at this point ...

Here is a simple sketch I am testing this with:

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>

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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    ReefAngel.AddSalinityExpansion();  // Salinity Expansion Module
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit | Port4Bit | Port6Bit | Port7Bit | Port8Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


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

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

void loop()
{
    ReefAngel.Relay.DelayedOn( Port2 );
    ReefAngel.Relay.DelayedOn( Port3 );
    ReefAngel.DayLights( Port4 );
    ReefAngel.Relay.DelayedOn( Port5 );
    ReefAngel.StandardHeater( Port6 );
    ReefAngel.DosingPumpRepeat1( Port7 );
    ReefAngel.DosingPumpRepeat2( Port8 );
    ReefAngel.PWM.DaylightPWMParabola();
    ReefAngel.PWM.ActinicPWMSlope();
 
    ////// Place your custom code below here
     ReefAngel.AddPortOverrides(); 
    ReefAngel.OverridePortsE[6] = 0;
    ////// Place your custom code above here

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


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

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

Yes, it's in the update folder. Sounds like you have the right file.

When you compile what features do you see being enabled?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

You can try manually #define 'ing the OVERRIDE_PORTS in ReefAngel/ReefAngel.h and ReefAngel/ReefAngel.cpp for the worst case...

You might need that in some other files that reference #ifdef OVERRIDE_PORTS... maybe easier to just stick it in Globals\Globals.h
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

Assuming you are asking about ReefAngel_Features.h.

After I updated features.txt I get this:

Code: Select all

#ifndef __REEFANGEL_FEATURES_H__
#define __REEFANGEL_FEATURES_H__

#define SIMPLE_MENU
#define OVERRIDE_PORTS
#define SALINITYEXPANSION
#define FONT_8x8
#define MAIN_2014
#define wifi
#define DisplayLEDPWM
#define VersionMenu
#define WDT


#endif  // __REEFANGEL_FEATURES_H__
But it still gives the compile error :(

jims_sketch_apr30:75: error: 'class ReefAngelClass' has no member named 'OverridePortsE'
Image
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Prevent Dosing Pump "ON" Override

Post by lnevo »

How many relay expansions you have? Take off the E[x] if you are trying to do this on the main relay bar. The 6 and 7 in your code refer to the 6th and 7th relay expansion not the port.

Assigning 0 to these variables will not override any ports.

If you want to override port 6 & 7 do this...

ReefAngel.OverridePorts = Port6Bit | Port7Bit;
jolt
Posts: 15
Joined: Fri Dec 13, 2013 2:44 pm

Re: Prevent Dosing Pump "ON" Override

Post by jolt »

Thanks Lee, that did it!

I do not have any relay expansions.
Image
Post Reply