control two jabeo with different speeds

Do you have a question on how to do something.
Ask in here.

Posts: 15
Joined: Sat Jun 14, 2014 8:30 pm
Location: Key Largo, FL
PostPosted: Tue Sep 16, 2014 7:14 pm
i am trying to use else mode that i stole from another user on here, cant remember who. The two pumps operate at the same speeds as each other or on anti sync just the opposite of each other. I want one tank to have stronger flow than the other as shown below but they wont go at different speeds.

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
#define NUMBERS_8x16
void DrawCustomMain()
{
ReefAngel.LCD.DrawDate(6, 112);
ReefAngel.LCD.DrawText(COLOR_ORANGERED, COLOR_DEEPSKYBLUE,14,8, "Our Little Oceans");
pingSerial();

DrawStatus (20,80);
DrawParams (5,40);
DrawParamsa (0,10);
pingSerial();
byte TempRelay = ReefAngel.Relay.RelayData;
TempRelay &= ReefAngel.Relay.RelayMaskOff;
TempRelay |= ReefAngel.Relay.RelayMaskOn;
ReefAngel.LCD.DrawOutletBox(12, 93, TempRelay);
}

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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    ReefAngel.AddStandardMenu();  // Add Standard Menu
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port2Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port6Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port2Bit | Port7Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 820 );

    // Feeeding and Water Change mode speed
    ReefAngel.DCPump.FeedingSpeed=0;
    ReefAngel.DCPump.WaterChangeSpeed=0;


    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
         
    ////// Place additional initialization code below here
    //ReefAngel.CustomLabels[0]="ReturnPump"; 
    //ReefAngel.CustomLabels[1]="Skimmer"; 
    //ReefAngel.CustomLabels[2]="Kessil"; 
    //ReefAngel.CustomLabels[3]="Nick  ATO"; 
    //ReefAngel.CustomLabels[4]="Steph Fan"; 
    //ReefAngel.CustomLabels[5]="Steph ATO"; 
    //ReefAngel.CustomLabels[6]="Refugium"; 
    //ReefAngel.CustomLabels[7]="Nick  Fan"; 

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

void loop()
{
    ReefAngel.Relay.DelayedOn( Port2,20 );
    ReefAngel.MHLights( Port3,12,00,22,00,1 );
    ReefAngel.StandardFan( Port5,776,781 );
    ReefAngel.Relay.Set( Port7, !ReefAngel.Relay.Status( Port3 ) );
    ReefAngel.SingleATO( true,Port6,10,0 );   
    ReefAngel.SingleATO( false,Port4,10,0 );
    if (ReefAngel.Params.Temp[T2_PROBE] >= 781) ReefAngel.Relay.On(Port8);  // If sensor 1 temperature >= HighTemp - turn on fan
   if (ReefAngel.Params.Temp[T2_PROBE] <= 776) ReefAngel.Relay.Off(Port8);  // If sensor 1 temperature <= LowTemp - turn off fan
   
    ////// Place your custom code below here
    if (hour()>=12 && hour()<22)
{
    ReefAngel.PWM.SetDaylight( ElseMode(70,30,true) ); // Else Mode at 70% +/- 30% on sync mode
}
else if (hour()>=22 || hour()<2)
{
    ReefAngel.PWM.SetDaylight( NutrientTransportMode(40,80,200,true) ); // Nutrient Transport 40%minspeed - 80%maxspeed - 200ms
}   
    else if (hour()>=2 && hour()<12)
{
    ReefAngel.PWM.SetDaylight( ElseMode(45,15,true) ); // Else Mode at 45% +/- 15% on sync mode
}
if (hour()>=12 && hour()<22)
{
    ReefAngel.PWM.SetActinic( ElseMode(45,35,false) ); // Else Mode at 70% +/- 30% on anti-sync mode
}
else if (hour()>=22 || hour()<2)
{
    ReefAngel.PWM.SetActinic( NutrientTransportMode(25,65,200,false) ); // Nutrient Transport 40%minspeed - 80%maxspeed - 200ms
}   
    else if (hour()>=2 && hour()<12)
{
    ReefAngel.PWM.SetActinic( ElseMode(40,15,false) ); // Else Mode at 45% +/- 15% on anti-sync mode
}
    ////// Place your custom code above here

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

void DrawParamsa(int x, int y){
char buf[16];
  ReefAngel.LCD.DrawText(DPColor,DefaultBGColor,x+40,y+10,"Steph:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetDaylightValue(), DPColor, x+78, y+10,1);
ReefAngel.LCD.DrawText(APColor,DefaultBGColor,x+40,y+20,"Nick:");
ReefAngel.LCD.DrawSingleMonitor(ReefAngel.PWM.GetActinicValue(),APColor, x+78, y+20,1);

}

void DrawParams(int x, int y) {
  char buf[16];

  ReefAngel.LCD.DrawText(COLOR_INDIGO,DefaultBGColor,x+5,y,"Steph:");
  ReefAngel.LCD.DrawText(COLOR_INDIGO,DefaultBGColor,x+80, y, "Nick:");
  // Temp and PH
  y+=10;

  ConvertNumToString(buf, ReefAngel.Params.Temp[T1_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(T1TempColor, DefaultBGColor, x+5, y, buf, Num8x16);
  ConvertNumToString(buf, ReefAngel.Params.Temp[T2_PROBE], 10);
  ReefAngel.LCD.DrawLargeText(T2TempColor, DefaultBGColor, x+80, y, buf, Num8x16);
  y+=5;

}

void DrawStatus(int x, int y) {
  int t=x;
 
  ReefAngel.LCD.DrawLargeText(COLOR_INDIGO,DefaultBGColor,15,y,"Nick",Font8x16);
  ReefAngel.LCD.DrawLargeText(COLOR_ORANGERED,DefaultBGColor,85,y,"Steph",Font8x16);
 
  if (ReefAngel.HighATO.IsActive()) {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_ORANGERED);
  } else {
    ReefAngel.LCD.FillCircle(55,y+3,5,COLOR_INDIGO);
  }
 
  if (ReefAngel.LowATO.IsActive()) {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_ORANGERED);
  } else {
    ReefAngel.LCD.FillCircle(70,y+3,5,COLOR_INDIGO);
  }
}

void DrawCustomGraph()
{
}

byte ElseMode( byte MidPoint, byte Offset, boolean WaveSync )
{
  // Static's only initialize the first time they are called
  static unsigned long LastChange=millis();        // Set the inital time that the last change occurred
  static int Delay = random( 500, 3000);           // Set the initial delay
  static int NewSpeed = MidPoint;                  // Set the initial speed
  static int AntiSpeed = MidPoint;                 // Set the initial anti sync speed
  if ((millis()-LastChange) > Delay)               // Check if the delay has elapsed
  {
    Delay=random(500,5000);                        // If so, come up with a new delay
    int ChangeUp = random(Offset);                 // Amount to go up or down
    if (random(100)<50)                            // 50/50 chance of speed going up or going down
    {
      NewSpeed = MidPoint - ChangeUp;
      AntiSpeed = MidPoint + ChangeUp;
    }
    else
    {
      NewSpeed = MidPoint + ChangeUp;
      AntiSpeed = MidPoint - ChangeUp;
    }
    LastChange=millis();                           // Reset the time of the last change
  }
  if (WaveSync)
  {
    return NewSpeed;
  }
  else
  {
    return AntiSpeed;
  }
}


anyone see anything wrong?

Thanks,
Nick
User avatar
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL
PostPosted: Wed Sep 17, 2014 8:28 am
That is the way it is.
You can't set different speeds for the pumps with the current 1.1.0 libraries.
The new developmental libraries 1.1.1 have and offset built into them.

The latest Dev branch can be located here. https://github.com/reefangel/Libraries/archive/dev.zip

Here is the thread.
viewtopic.php?f=9&t=3801

lnevo wrote: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
Posts: 1833
Joined: Sun Apr 21, 2013 6:25 am
Location: Davie, FL
PostPosted: Wed Sep 17, 2014 8:30 am
Also with the dev code the code you have for "Else Mode" is not needed. It's been added into the new libraries along with Sine and Gyre.
User avatar
Posts: 5364
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Sep 17, 2014 8:32 am
I don't think that's his issue Steven.

He's not using DCPump, he's using the same ElseMode with two different speeds being called. I think it's because ElseMode tracks the speed setting for each iteration. If you keep changing it, it's going to affect both channels.

Posts: 263
Joined: Wed Jan 01, 2014 7:26 am
PostPosted: Wed Sep 17, 2014 1:15 pm
He could ElseMode to call it Else1 and duplicate it to Else2 and do different pumps totally independently with different variables if he wanted.
User avatar
Posts: 5364
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Wed Sep 17, 2014 1:54 pm
That was my thought, but I wasnt 100% sure the issue...but I think that would be the answer

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 2 guests

cron