Set wave speed based on feeding mode?

Basic / Standard Reef Angel hardware
Post Reply
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Set wave speed based on feeding mode?

Post by Smotz »

I am looking to keep my wave pump (WP-40) but set it to a steady 35 during feeding mode.
Can someone assist?

Also, how do I rename the ports in the code - instead of "Port1", etc?

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 <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 = Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port5Bit | 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( Port3 );
    ReefAngel.Relay.On( Port4 );
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Port7 );
    ReefAngel.Relay.On( Port8 );

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

void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.StandardATO( Port2 );
    ////// Place your custom code below here
 
    ReefAngel.PWM.SetDaylight( LongPulseMode(35,60,5,false)); 
    ReefAngel.PWM.SetActinic( LongPulseMode(40,75,4,false));  
   
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "Smotz" );
    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();

    // Salinity
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,66, "SAL:" );
    ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,66, ReefAngel.Params.Salinity );
    pingSerial();

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

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

void DrawCustomGraph()
{
}


////  Wave Modes

byte ShortPulseMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync)
{
  byte tspeed=0;
  PulseMinSpeed=constrain(PulseMinSpeed,30,100);
  PulseMaxSpeed=constrain(PulseMaxSpeed,30,100);
  tspeed=(millis()%(PulseDuration*2)<PulseDuration?PulseMinSpeed:PulseMaxSpeed);
  if (PulseSync)
    return tspeed;
  else
    return (tspeed==PulseMinSpeed)?PulseMaxSpeed:PulseMinSpeed;
}
byte LongPulseMode(byte PulseMinSpeed, byte PulseMaxSpeed, int PulseDuration, boolean PulseSync)
{
  byte tspeed=0;
  PulseMinSpeed=constrain(PulseMinSpeed,30,100);
  PulseMaxSpeed=constrain(PulseMaxSpeed,30,100);
  tspeed=(now()%(PulseDuration*2)<PulseDuration?PulseMinSpeed:PulseMaxSpeed);
  if (PulseSync)
    return tspeed;
  else
    return (tspeed==PulseMinSpeed)?PulseMaxSpeed:PulseMinSpeed;
}

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

Set wave speed based on feeding mode?

Post by lnevo »

Here's how to define the ports:

Code: Select all


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

#define Heater Port1

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

And I added the if statement if your in feeding mode to set the wp40 to 35%

Code: Select all


void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.StandardATO( Port2 );
    ////// Place your custom code below here
 
    If (ReefAngel.DisplayedMenu==FEEDING_MODE) {
       ReefAngel.PWM.SetDaylight(35); 
       ReefAngel.PWM.SetActinic(35);       
    } else {
       ReefAngel.PWM.SetDaylight( LongPulseMode(35,60,5,false)); 
       ReefAngel.PWM.SetActinic( LongPulseMode(40,75,4,false));  
    }
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "Smotz" );
    ReefAngel.ShowInterface();
}
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Set wave speed based on feeding mode?

Post by Smotz »

Nice!

I saw a code that turned off the skimmer if the return pump was off. I would like to do the same for my skimmer and reactor pump? Got some magic for that?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Set wave speed based on feeding mode?

Post by lnevo »

This is what I use..

// Turn off Skimmer if Return pump has been shutoff.
if (bitRead(ReefAngel.Relay.RelayMaskOff,ReturnBit)==0) {
bitClear(ReefAngel.Relay.RelayMaskOff,SkimmerBit);
}

I have ReturnBit and SkimmerBit #defined so keep in mind the actual value is port# minus 1.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Set wave speed based on feeding mode?

Post by Smotz »

lnevo wrote:This is what I use..

// Turn off Skimmer if Return pump has been shutoff.
if (bitRead(ReefAngel.Relay.RelayMaskOff,ReturnBit)==0) {
bitClear(ReefAngel.Relay.RelayMaskOff,SkimmerBit);
}

I have ReturnBit and SkimmerBit #defined so keep in mind the actual value is port# minus 1.

So lets say your skimmer is on port 1 and your return is on port 2 - then skimmerbit=1 and returnbit=2 ? Are they just variables to represent the port?

These are my declarations:
#define Heater Port1
#define Topoff Port2
#define Reactor Port3
#define Skimmer Port4
#define Return Port5
#define Wave Port6
#define Fugelight Port8
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Set wave speed based on feeding mode?

Post by Smotz »

lnevo wrote:Here's how to define the ports:

Code: Select all


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

#define Heater Port1

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

And I added the if statement if your in feeding mode to set the wp40 to 35%

Code: Select all


void loop()
{
    ReefAngel.StandardHeater( Port1 );
    ReefAngel.StandardATO( Port2 );
    ////// Place your custom code below here
 
    If (ReefAngel.DisplayedMenu==FEEDING_MODE) {
       ReefAngel.PWM.SetDaylight(35); 
       ReefAngel.PWM.SetActinic(35);       
    } else {
       ReefAngel.PWM.SetDaylight( LongPulseMode(35,60,5,false)); 
       ReefAngel.PWM.SetActinic( LongPulseMode(40,75,4,false));  
    }
    ////// Place your custom code above here

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


I am getting this error when using the above code - any thoughts?

Display_Tank_adjusted_ino.cpp: In function 'void loop()':
Display_Tank_adjusted_ino:99: error: 'If' was not declared in this scope
Display_Tank_adjusted_ino:99: error: expected `;' before '{' token
Display_Tank_adjusted_ino:102: error: 'else' without a previous 'if'
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Set wave speed based on feeding mode?

Post by lnevo »

The If somehow got capitalized...

As far as the SkimmerBit and the ReturnBit
So lets say your skimmer is on port 1 and your return is on port 2 - then skimmerbit=1 and returnbit=2 ? Are they just variables to represent the port?
No, SkimmerBit = 0 and ReturnBit = 1... Since the Port #'s are 1-8 and the bit that represents them are 0-7..

So...
#define Skimmer Port4
#define Return Port5
For you I would use:

Code: Select all

#define Skimmer 3
#define Return 4
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Set wave speed based on feeding mode?

Post by lnevo »

Also, don't you only have one WP40? If so then you don't have to run the functions for Actinic and for Daylight, you can remove the one you aren't using... unless you want them both for future :)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Set wave speed based on feeding mode?

Post by rimai »

The error code tells a lot about what it is wrong...
Display_Tank_adjusted_ino:99: error: 'If' was not declared in this scope
The error is on line 99, which is show on green above.
It's complaining about "If", which is in red above. The reason it is complaining is because everything is case sensitive, which means If is difference than if.
Try changing it to if (all lowercase) instead.
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Set wave speed based on feeding mode?

Post by Smotz »

Thank you all!
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Set wave speed based on feeding mode?

Post by Smotz »

lnevo wrote:Also, don't you only have one WP40? If so then you don't have to run the functions for Actinic and for Daylight, you can remove the one you aren't using... unless you want them both for future :)
I actually changed the code to leave 1 on 100% for testing purposes
Post Reply