Icecap Module


Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm
PostPosted: Mon Feb 29, 2016 4:01 pm
Great, thanks. Could you post your whole code?
Image

Posts: 43
Joined: Sat Nov 21, 2015 10:34 am
Location: Dallas
PostPosted: Mon Feb 29, 2016 4:22 pm
Here you go. Keep in mind I'm a RA newbie:

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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>

#define debug_flow 1
#define debug_lights 1

////// Place global variable code below here
#define Return 1
#define Skimmer 2
#define Heater 3
#define SumpLight 4
#define Unused 6
#define Scrubber 5
#define PowerStrip 7
#define ATO 8

#define SumpTemp T1_PROBE
#define DisplayTemp T2_PROBE

////// Place global variable code above here
Tide tide;
SunLocation sunLocation;

void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit;

    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit;

    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit;

    // 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 );
    ReefAngel.Relay.On( Port6 );


    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Return";
    ReefAngel.CustomLabels[1]="Skimmer";
    ReefAngel.CustomLabels[2]="Heater";
    ReefAngel.CustomLabels[3]="Fuge Light";
    ReefAngel.CustomLabels[4]="Unused";
    ReefAngel.CustomLabels[5]="Scrubber";
    ReefAngel.CustomLabels[6]="Power Strip";
    ReefAngel.CustomLabels[7]="ATO";

    tide.Init(40,10,30);
    tide.SetWaveLength(12+SECS_PER_HOUR);
    sunLocation.Init(25.7753,80.2089);
    sunLocation.SetOffset(8,0,8,0);
    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.Relay.DelayedOn( Port2 );
    ReefAngel.StandardHeater( Port3, 785, 805 );
    ReefAngel.StandardLights( Port4, 20,0,9,0);

    ////// Place your custom code below here
    //setVortech();
    //
    // turn the scrubber led on at 5pm and off at 5am
    ReefAngel.StandardLights(Port5,17,0,5,0);
    sunLocation.CheckAndUpdate();
   
    setLED();
    setMoon();
    setMaxspect();
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "oftheangels" );

    ReefAngel.ShowInterface();
}

void setLED()
{

#if debug_flow == 1
  Serial.print("Rise Hour: ");
  Serial.print(sunLocation.GetRiseHour());
  Serial.print(" Rise Minute: ");
  Serial.print(sunLocation.GetRiseMinute());
  Serial.print(" Set Hour: ");
  Serial.print(sunLocation.GetSetHour());
  Serial.print(" Set Minute: ");
  Serial.print(sunLocation.GetSetMinute());
  Serial.println();
#endif

    ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0));

    ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0));
}

void setMoon()
{
#ifdef debug_lights == 1
  Serial.print("Daylight: ");
  Serial.print(sunLocation.IsDaytime());
  Serial.print(" MoonPhase: ");
  Serial.print(MoonPhase());
  Serial.println();
#endif

  if (sunLocation.IsDaytime())
    ReefAngel.PWM.SetChannel(0, 0);
  else
    ReefAngel.PWM.SetChannel( 0, MoonPhase() );
}


void setVortech()
{
    // Pumps for night mode, start with lagoon, short pulse most of the day
  if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
  {
    if (hour() > 9 || hour() < 17)
      ReefAngel.RF.SetMode(ReefCrest,40,0);
    else
      ReefAngel.RF.SetMode(LongWave, 40, 0);
  }
}


void setMaxspect()
{
  int reverse_speed=0;
  int forward_speed=45;
 
 if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
   forward_speed = NutrientTransportMode(25,50,1500,false);
   reverse_speed = 0;
 } else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
   //
   // shut off maxspect during water changes.
   forward_speed = 0;
   reverse_speed = 0;
 } else {
   //
   // swap between forward and reverse every 10 seconds
#if 0
   reverse_speed = ShortPulseMode(0,100,10000,false);
   if (reverse_speed == 100)
     //
     // while we are going in reverse increase the speed to 45-60
     forward_speed = ShortPulseMode(30,60,5000,false);
   else
     //
     // while we are going forward set speed to 25-40 to keep
     // from blowing corals off the rocks
     forward_speed = ShortPulseMode(25,40,5000, false);
#endif
    forward_speed = tide.CalcTide();
  }
#if debug_flow == 1
  Serial.print("Forward Speed: ");
  Serial.print(forward_speed);
  Serial.print(" Reverse Speed: ");
  Serial.print(reverse_speed);
  Serial.println();
#endif

  ReefAngel.PWM.SetChannel(2,reverse_speed);  // set the pump direction
  ReefAngel.PWM.SetChannel(1,forward_speed);    // set the pump speed
}


Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm
PostPosted: Mon Feb 29, 2016 6:18 pm
rimai wrote:
Ismaclst wrote:I have the maxspect gyre and was thinking about purchasing the Icecap module to go with it. Has anyone else bought this? Does it come with the cable you need to connect to the RA? I'm assuming you can use any of the DC pump modes?

You should be able to use the DCPump modes.
The Kessil cable in the webstore should be able to be used with the Icecap module too :)


Will this cable allow forward and reverse?
Image

Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm
PostPosted: Mon Feb 29, 2016 6:28 pm
oftheangels wrote:Here you go. Keep in mind I'm a RA newbie:

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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>

#define debug_flow 1
#define debug_lights 1

////// Place global variable code below here
#define Return 1
#define Skimmer 2
#define Heater 3
#define SumpLight 4
#define Unused 6
#define Scrubber 5
#define PowerStrip 7
#define ATO 8

#define SumpTemp T1_PROBE
#define DisplayTemp T2_PROBE

////// Place global variable code above here
Tide tide;
SunLocation sunLocation;

void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit;

    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit;

    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit;

    // 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 );
    ReefAngel.Relay.On( Port6 );


    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Return";
    ReefAngel.CustomLabels[1]="Skimmer";
    ReefAngel.CustomLabels[2]="Heater";
    ReefAngel.CustomLabels[3]="Fuge Light";
    ReefAngel.CustomLabels[4]="Unused";
    ReefAngel.CustomLabels[5]="Scrubber";
    ReefAngel.CustomLabels[6]="Power Strip";
    ReefAngel.CustomLabels[7]="ATO";

    tide.Init(40,10,30);
    tide.SetWaveLength(12+SECS_PER_HOUR);
    sunLocation.Init(25.7753,80.2089);
    sunLocation.SetOffset(8,0,8,0);
    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.Relay.DelayedOn( Port2 );
    ReefAngel.StandardHeater( Port3, 785, 805 );
    ReefAngel.StandardLights( Port4, 20,0,9,0);

    ////// Place your custom code below here
    //setVortech();
    //
    // turn the scrubber led on at 5pm and off at 5am
    ReefAngel.StandardLights(Port5,17,0,5,0);
    sunLocation.CheckAndUpdate();
   
    setLED();
    setMoon();
    setMaxspect();
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "oftheangels" );

    ReefAngel.ShowInterface();
}

void setLED()
{

#if debug_flow == 1
  Serial.print("Rise Hour: ");
  Serial.print(sunLocation.GetRiseHour());
  Serial.print(" Rise Minute: ");
  Serial.print(sunLocation.GetRiseMinute());
  Serial.print(" Set Hour: ");
  Serial.print(sunLocation.GetSetHour());
  Serial.print(" Set Minute: ");
  Serial.print(sunLocation.GetSetMinute());
  Serial.println();
#endif

    ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0));

    ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0));
}

void setMoon()
{
#ifdef debug_lights == 1
  Serial.print("Daylight: ");
  Serial.print(sunLocation.IsDaytime());
  Serial.print(" MoonPhase: ");
  Serial.print(MoonPhase());
  Serial.println();
#endif

  if (sunLocation.IsDaytime())
    ReefAngel.PWM.SetChannel(0, 0);
  else
    ReefAngel.PWM.SetChannel( 0, MoonPhase() );
}


void setVortech()
{
    // Pumps for night mode, start with lagoon, short pulse most of the day
  if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
  {
    if (hour() > 9 || hour() < 17)
      ReefAngel.RF.SetMode(ReefCrest,40,0);
    else
      ReefAngel.RF.SetMode(LongWave, 40, 0);
  }
}


void setMaxspect()
{
  int reverse_speed=0;
  int forward_speed=45;
 
 if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
   forward_speed = NutrientTransportMode(25,50,1500,false);
   reverse_speed = 0;
 } else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
   //
   // shut off maxspect during water changes.
   forward_speed = 0;
   reverse_speed = 0;
 } else {
   //
   // swap between forward and reverse every 10 seconds
#if 0
   reverse_speed = ShortPulseMode(0,100,10000,false);
   if (reverse_speed == 100)
     //
     // while we are going in reverse increase the speed to 45-60
     forward_speed = ShortPulseMode(30,60,5000,false);
   else
     //
     // while we are going forward set speed to 25-40 to keep
     // from blowing corals off the rocks
     forward_speed = ShortPulseMode(25,40,5000, false);
#endif
    forward_speed = tide.CalcTide();
  }
#if debug_flow == 1
  Serial.print("Forward Speed: ");
  Serial.print(forward_speed);
  Serial.print(" Reverse Speed: ");
  Serial.print(reverse_speed);
  Serial.println();
#endif

  ReefAngel.PWM.SetChannel(2,reverse_speed);  // set the pump direction
  ReefAngel.PWM.SetChannel(1,forward_speed);    // set the pump speed
}



Thanks for your help. I was getting some errors when I added what you told me to. I figured out that I needed to add these, too.

Code: Select all
Tide tide;


Code: Select all
#include <Tide.h>
Image

Posts: 12171
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Feb 29, 2016 6:32 pm
Ismaclst wrote:
rimai wrote:
Ismaclst wrote:I have the maxspect gyre and was thinking about purchasing the Icecap module to go with it. Has anyone else bought this? Does it come with the cable you need to connect to the RA? I'm assuming you can use any of the DC pump modes?

You should be able to use the DCPump modes.
The Kessil cable in the webstore should be able to be used with the Icecap module too :)


Will this cable allow forward and reverse?

Yes
Roberto.

Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm
PostPosted: Mon Feb 29, 2016 6:34 pm
Great, thanks.
Image

Posts: 43
Joined: Sat Nov 21, 2015 10:34 am
Location: Dallas
PostPosted: Mon Feb 29, 2016 7:28 pm
Ismaclst wrote:
oftheangels wrote:Here you go. Keep in mind I'm a RA newbie:

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 <Tide.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 <PAR.h>
#include <ReefAngel.h>
#include <SunLocation.h>

#define debug_flow 1
#define debug_lights 1

////// Place global variable code below here
#define Return 1
#define Skimmer 2
#define Heater 3
#define SumpLight 4
#define Unused 6
#define Scrubber 5
#define PowerStrip 7
#define ATO 8

#define SumpTemp T1_PROBE
#define DisplayTemp T2_PROBE

////// Place global variable code above here
Tide tide;
SunLocation sunLocation;

void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen

    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port1Bit | Port2Bit;

    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port2Bit | Port8Bit;

    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;

    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port3Bit;

    // 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 );
    ReefAngel.Relay.On( Port6 );


    ////// Place additional initialization code below here
    ReefAngel.CustomLabels[0]="Return";
    ReefAngel.CustomLabels[1]="Skimmer";
    ReefAngel.CustomLabels[2]="Heater";
    ReefAngel.CustomLabels[3]="Fuge Light";
    ReefAngel.CustomLabels[4]="Unused";
    ReefAngel.CustomLabels[5]="Scrubber";
    ReefAngel.CustomLabels[6]="Power Strip";
    ReefAngel.CustomLabels[7]="ATO";

    tide.Init(40,10,30);
    tide.SetWaveLength(12+SECS_PER_HOUR);
    sunLocation.Init(25.7753,80.2089);
    sunLocation.SetOffset(8,0,8,0);
    ////// Place additional initialization code above here
}

void loop()
{
    ReefAngel.Relay.DelayedOn( Port2 );
    ReefAngel.StandardHeater( Port3, 785, 805 );
    ReefAngel.StandardLights( Port4, 20,0,9,0);

    ////// Place your custom code below here
    //setVortech();
    //
    // turn the scrubber led on at 5pm and off at 5am
    ReefAngel.StandardLights(Port5,17,0,5,0);
    sunLocation.CheckAndUpdate();
   
    setLED();
    setMoon();
    setMaxspect();
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "oftheangels" );

    ReefAngel.ShowInterface();
}

void setLED()
{

#if debug_flow == 1
  Serial.print("Rise Hour: ");
  Serial.print(sunLocation.GetRiseHour());
  Serial.print(" Rise Minute: ");
  Serial.print(sunLocation.GetRiseMinute());
  Serial.print(" Set Hour: ");
  Serial.print(sunLocation.GetSetHour());
  Serial.print(" Set Minute: ");
  Serial.print(sunLocation.GetSetMinute());
  Serial.println();
#endif

    ReefAngel.PWM.SetActinic(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour() ,sunLocation.GetSetMinute(),0,50,0));

    ReefAngel.PWM.SetDaylight(PWMParabola(sunLocation.GetRiseHour(),sunLocation.GetRiseMinute(),sunLocation.GetSetHour(),sunLocation.GetSetMinute(),10,60,0));
}

void setMoon()
{
#ifdef debug_lights == 1
  Serial.print("Daylight: ");
  Serial.print(sunLocation.IsDaytime());
  Serial.print(" MoonPhase: ");
  Serial.print(MoonPhase());
  Serial.println();
#endif

  if (sunLocation.IsDaytime())
    ReefAngel.PWM.SetChannel(0, 0);
  else
    ReefAngel.PWM.SetChannel( 0, MoonPhase() );
}


void setVortech()
{
    // Pumps for night mode, start with lagoon, short pulse most of the day
  if (ReefAngel.DisplayedMenu!=FEEDING_MODE || ReefAngel.DisplayedMenu!=WATERCHANGE_MODE)
  {
    if (hour() > 9 || hour() < 17)
      ReefAngel.RF.SetMode(ReefCrest,40,0);
    else
      ReefAngel.RF.SetMode(LongWave, 40, 0);
  }
}


void setMaxspect()
{
  int reverse_speed=0;
  int forward_speed=45;
 
 if (ReefAngel.DisplayedMenu==FEEDING_MODE) {
   forward_speed = NutrientTransportMode(25,50,1500,false);
   reverse_speed = 0;
 } else if (ReefAngel.DisplayedMenu==WATERCHANGE_MODE) {
   //
   // shut off maxspect during water changes.
   forward_speed = 0;
   reverse_speed = 0;
 } else {
   //
   // swap between forward and reverse every 10 seconds
#if 0
   reverse_speed = ShortPulseMode(0,100,10000,false);
   if (reverse_speed == 100)
     //
     // while we are going in reverse increase the speed to 45-60
     forward_speed = ShortPulseMode(30,60,5000,false);
   else
     //
     // while we are going forward set speed to 25-40 to keep
     // from blowing corals off the rocks
     forward_speed = ShortPulseMode(25,40,5000, false);
#endif
    forward_speed = tide.CalcTide();
  }
#if debug_flow == 1
  Serial.print("Forward Speed: ");
  Serial.print(forward_speed);
  Serial.print(" Reverse Speed: ");
  Serial.print(reverse_speed);
  Serial.println();
#endif

  ReefAngel.PWM.SetChannel(2,reverse_speed);  // set the pump direction
  ReefAngel.PWM.SetChannel(1,forward_speed);    // set the pump speed
}



Thanks for your help. I was getting some errors when I added what you told me to. I figured out that I needed to add these, too.

Code: Select all
Tide tide;


Code: Select all
#include <Tide.h>


Happy to help! That's what's great about this community and open source in general... RA ROCKS!

-LeoD
User avatar
Posts: 5339
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Feb 29, 2016 8:03 pm
I didnt look at your full code yet. But it would be nice to wrap this into a function and have it be used like a standard mode function. Then you could use the anti-sync speed as an output to control the direction.
User avatar
Posts: 5339
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Mon Feb 29, 2016 9:16 pm
Here, this should do nicely. The only thing I learned from here is that we need to add in the libraries either to let each function decide its speeds under different modes like feeding and waterchange OR we add a FeedingAntiSyncSpeed and WaterChangeAntiSyncSpeed variables. For now I took that part out of the function. You could always implement it manually if you like by not using those variables, or maybe we can just manage it in the libraries too, I'd have to look closer how that works.

The libraries do this:
Code: Select all
ReefAngel.cpp:          if (DCPump.FeedingSpeed < 100)
ReefAngel.cpp:                  SyncSpeed=DCPump.FeedingSpeed;
ReefAngel.cpp:                  AntiSyncSpeed=DCPump.FeedingSpeed;


Anyway, here's the function a little more simplified

Code: Select all
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync)
{
  int reverse_speed=0;
  int forward_speed=minSpeed;
 
   // swap between forward and reverse every X seconds
   reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true);
   if (reverse_speed == 100) {
     //
     // while we are going in reverse increase the speed by 10
     forward_speed = ShortPulseMode(minSpeed+10, maxSpeed+10,ReefAngel.DCPump.Duration,true);
   } else {
     //
     // while we are going forward set speed to 25-40 to keep
     // from blowing corals off the rocks
     forward_speed = ShortPulseMode(minSpeed,maxSpeed, ReefAngel.DCPump.Duration, true);
  }

  if (PulseSync) {
    return forward_speed;
  } else {
    return reverse_speed;
  }
}

Posts: 250
Joined: Wed Jan 28, 2015 5:17 pm
PostPosted: Tue Mar 01, 2016 2:20 pm
lnevo wrote:Here, this should do nicely. The only thing I learned from here is that we need to add in the libraries either to let each function decide its speeds under different modes like feeding and waterchange OR we add a FeedingAntiSyncSpeed and WaterChangeAntiSyncSpeed variables. For now I took that part out of the function. You could always implement it manually if you like by not using those variables, or maybe we can just manage it in the libraries too, I'd have to look closer how that works.

The libraries do this:
Code: Select all
ReefAngel.cpp:          if (DCPump.FeedingSpeed < 100)
ReefAngel.cpp:                  SyncSpeed=DCPump.FeedingSpeed;
ReefAngel.cpp:                  AntiSyncSpeed=DCPump.FeedingSpeed;


Anyway, here's the function a little more simplified

I like how you simplified it. This may be a stupid and obvious question, but how do you set the max and min speed for forward and reverse?

Code: Select all
byte setMaxspect(byte minSpeed, byte maxSpeed, boolean PulseSync)
{
  int reverse_speed=0;
  int forward_speed=minSpeed;
 
   // swap between forward and reverse every X seconds
   reverse_speed = ShortPulseMode(0,100,ReefAngel.DCPump.Duration*2,true);
   if (reverse_speed == 100) {
     //
     // while we are going in reverse increase the speed by 10
     forward_speed = ShortPulseMode(minSpeed+10, maxSpeed+10,ReefAngel.DCPump.Duration,true);
   } else {
     //
     // while we are going forward set speed to 25-40 to keep
     // from blowing corals off the rocks
     forward_speed = ShortPulseMode(minSpeed,maxSpeed, ReefAngel.DCPump.Duration, true);
  }

  if (PulseSync) {
    return forward_speed;
  } else {
    return reverse_speed;
  }
}
Image
PreviousNext

Return to Ask anything here

Who is online

Users browsing this forum: No registered users and 2 guests