My code with RANet

Share you PDE file with our community

Posts: 98
Joined: Sun Jul 21, 2013 8:18 am
PostPosted: Sun Feb 01, 2015 7:02 am
#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>U
#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>
#include <SoftwareSerial.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.SetTemperatureUnit( Celsius ); // set to Celsius Temperature
    ReefAngel.Use2014Screen();
    ReefAngel.AddRANet();
    // Ports toggled when relay looses communication
    ReefAngel.Relay.RANetFallBackE[0] = Port1Bit | Port5Bit | Port8Bit;
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port5Bit | Port6Bit;
    ReefAngel.FeedingModePortsE[0] = Port5Bit;
    // Feeding Mode speeds
    ReefAngel.DCPump.FeedingSpeed=0;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;


    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Box1_Port5 );
    ReefAngel.Relay.On( Box1_Port8 );

    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.StandardLights( Port1, 13, 0, 23, 00);
    ReefAngel.StandardLights( Port3, 13, 0, 23, 05);
    ReefAngel.StandardLights( Port7, 23, 0, 7, 05);
    ReefAngel.StandardLights( Port8, 23, 0, 7, 05);
    ReefAngel.StandardLights( Box1_Port1, 7, 0, 1, 00);
    ReefAngel.StandardLights( Box1_Port2, 22, 0, 7, 00);
    ReefAngel.StandardLights( Box1_Port7, 19, 0, 23, 00);
    
    if (hour()>=7 && hour()<23) // Turn Moonlights on/off
  {
    ReefAngel.PWM.SetChannel( 0, (0));
  }
  else
  {
    ReefAngel.PWM.SetChannel( 0, MoonPhase()/4);
  }
    ////// Place your custom code below here
if (hour()>=4 && hour()<8)
{  
  ReefAngel.PWM.SetDaylight(SineMode(32,40,30,true) ); //SineMode from 30% to 40% for 30 seconds on sync mode
  ReefAngel.PWM.SetActinic(SineMode(32,40,30,false) ); //SineMode from 30% to 40% for 30 seconds on anti-sync mode
}
else if (hour()>=8 && hour()<12)
{  
  ReefAngel.PWM.SetDaylight( TidalSwellMode(55,true) ); // TidalSwell at 40% on sync mode
  ReefAngel.PWM.SetActinic( TidalSwellMode(55,false) ); // TidalSwell at 40% on sync mode
}
else if (hour()>=12 && hour()<16)
{
  ReefAngel.PWM.SetDaylight(millis()%1200>750?50:0);
  ReefAngel.PWM.SetActinic(millis()%1200<750?0:50);
}
else if (hour()>=16 && hour()<19)
{
  ReefAngel.PWM.SetDaylight( LongPulseMode(0,50,10,true) ); // Long pulse at 0% to 50% with 10s pulse on sync mode
  ReefAngel.PWM.SetActinic( LongPulseMode(0,50,10,false) ); // Long pulse at 0% to 50% with 10s pulse on on anti-sync mode
 
}
else if (hour()>=19 && hour()<23)
{
  ReefAngel.PWM.SetDaylight( ElseMode(42,10,true )); // ElseMode on sync mode, 40 +/- 10%
  ReefAngel.PWM.SetActinic( ElseMode(42,10,false )); // ElseMode on anti-sync mode, 40 +/- 10%
}
else
{
  ReefAngel.PWM.SetDaylight(GyreMode(32,50,10,true) ); //GyreMode from 30% to 50% for 10 minutes on sync mode
  ReefAngel.PWM.SetActinic(GyreMode(32,50,10,false) ); //GyreMode from 30% to 50% for 10 minutess on anti-sync mode
}

    ////// Place your custom code above here

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


Image

Posts: 98
Joined: Sun Jul 21, 2013 8:18 am
PostPosted: Mon Feb 02, 2015 10:23 pm
Used this code for feeding mode with ReefAngel battery backup for wavemakers.
This part of code does not work well. One wavemaker runs at full speed:

ReefAngel.DCPump.Mode =millis();
ReefAngel.DCPump.Speed = 1200, 750?50:0;


By the way is this how one codes for DCPump class?


#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>
#include <SoftwareSerial.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.SetTemperatureUnit( Celsius ); // set to Celsius Temperature
    ReefAngel.Use2014Screen();
    ReefAngel.AddRANet();
    // Ports toggled when relay looses communication
    ReefAngel.Relay.RANetFallBackE[0] = Port1Bit | Port5Bit | Port8Bit;
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePortsE[0] = Port5Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    
    // Feeding Mode speed
    ReefAngel.DCPump.FeedingSpeed=0;

    // Ports that are always on
    ReefAngel.Relay.On( Port2 );
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Box1_Port5 );
    ReefAngel.Relay.On( Box1_Port8 );

    ////// Place additional initialization code below here
    

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

void loop()
{
    ReefAngel.StandardLights( Port1, 13, 0, 23, 00);
    ReefAngel.StandardLights( Port3, 13, 0, 23, 05);
    ReefAngel.StandardLights( Port7, 23, 0, 7, 05);
    ReefAngel.StandardLights( Port8, 23, 0, 7, 05);
    ReefAngel.StandardLights( Box1_Port1, 7, 0, 1, 00);
    ReefAngel.StandardLights( Box1_Port2, 22, 0, 7, 00);
    ReefAngel.StandardLights( Box1_Port7, 19, 0, 23, 00);
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
    
    if (hour()>=7 && hour()<23) // Turn Moonlights on/off
  {
    ReefAngel.PWM.SetChannel( 0, (0));
  }
  else
  {
    ReefAngel.PWM.SetChannel( 0, MoonPhase()/4);
  }
    ////// Place your custom code below here
    
if (hour()>=4 && hour()<8)
{  
  ReefAngel.DCPump.Mode = Sine;
  ReefAngel.DCPump.Speed = 30, 40;
}
else if (hour()>=8 && hour()<12)
{  
  ReefAngel.DCPump.Mode = TidalSwell; // TidalSwell at 55% on sync mode
  ReefAngel.DCPump.Speed = 55;
}
else if (hour()>=12 && hour()<16)
{
  ReefAngel.DCPump.Mode =millis();
  ReefAngel.DCPump.Speed = 1200, 750?50:0;
}
else if (hour()>=16 && hour()<19)
{
  ReefAngel.DCPump.Mode=LongPulse; // Long pulse at 0% to 50% with 10s pulse on sync mode
  ReefAngel.DCPump.Speed =0,50,10;
}
else if (hour()>=19 && hour()<23)
{
  ReefAngel.DCPump.Mode=Else; // ElseMode on sync mode, 40 +/- 10%
  ReefAngel.DCPump.Speed =40, 10;
}
else
{
  ReefAngel.DCPump.Mode=Gyre; //GyreMode from 30% to 50% for 10 minutes on sync mode
  ReefAngel.DCPump.Speed = 32, 50, 10;
}

    ////// Place your custom code above here

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


Image
User avatar
Posts: 5343
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Feb 03, 2015 5:09 am
davaraj wrote:Used this code for feeding mode with ReefAngel battery backup for wavemakers.
This part of code does not work well. One wavemaker runs at full speed:

ReefAngel.DCPump.Mode =millis();
ReefAngel.DCPump.Speed = 1200, 750?50:0;

By the way is this how one codes for DCPump class?


Close. For Mode, you need to pick a valid mode or. Using millis() is not going to work. This would also cause the mode to change every iteration of loop() which would never keep the mode constant for more than a few milliseconds.

ReefAngel.DCPump.Mode=5;
ReefAngel.DCPump.Speed=60;

Second for Speed, the number needs to be between 0-100. I'm not even sure how the above would compile. 750?50:0 is valid, but not the 1200, part. And that code would always return 50 fro the speed.

Posts: 98
Joined: Sun Jul 21, 2013 8:18 am
PostPosted: Tue Feb 03, 2015 6:45 am
lnevo wrote:
davaraj wrote:Used this code for feeding mode with ReefAngel battery backup for wavemakers.
This part of code does not work well. One wavemaker runs at full speed:

ReefAngel.DCPump.Mode =millis();
ReefAngel.DCPump.Speed = 1200, 750?50:0;

By the way is this how one codes for DCPump class?


Close. For Mode, you need to pick a valid mode or. Using millis() is not going to work. This would also cause the mode to change every iteration of loop() which would never keep the mode constant for more than a few milliseconds.

ReefAngel.DCPump.Mode=5;
ReefAngel.DCPump.Speed=60;

Second for Speed, the number needs to be between 0-100. I'm not even sure how the above would compile. 750?50:0 is valid, but not the 1200, part. And that code would always return 50 fro the speed.


This was my original code that worked well.

////// Place your custom code below here
if (hour()>=4 && hour()<8)
{
ReefAngel.PWM.SetDaylight(SineMode(32,40,30,true) ); //SineMode from 30% to 40% for 30 seconds on sync mode
ReefAngel.PWM.SetActinic(SineMode(32,40,30,false) ); //SineMode from 30% to 40% for 30 seconds on anti-sync mode
}
else if (hour()>=8 && hour()<12)
{
ReefAngel.PWM.SetDaylight( TidalSwellMode(55,true) ); // TidalSwell at 40% on sync mode
ReefAngel.PWM.SetActinic( TidalSwellMode(55,false) ); // TidalSwell at 40% on sync mode
}
else if (hour()>=12 && hour()<16)
{
ReefAngel.PWM.SetDaylight(millis()%1200>750?50:0);
ReefAngel.PWM.SetActinic(millis()%1200<750?0:50);
}
else if (hour()>=16 && hour()<19)
{
ReefAngel.PWM.SetDaylight( LongPulseMode(0,50,10,true) ); // Long pulse at 0% to 50% with 10s pulse on sync mode
ReefAngel.PWM.SetActinic( LongPulseMode(0,50,10,false) ); // Long pulse at 0% to 50% with 10s pulse on on anti-sync mode

}
else if (hour()>=19 && hour()<23)
{
ReefAngel.PWM.SetDaylight( ElseMode(42,10,true )); // ElseMode on sync mode, 40 +/- 10%
ReefAngel.PWM.SetActinic( ElseMode(42,10,false )); // ElseMode on anti-sync mode, 40 +/- 10%
}
else
{
ReefAngel.PWM.SetDaylight(GyreMode(32,50,10,true) ); //GyreMode from 30% to 50% for 10 minutes on sync mode
ReefAngel.PWM.SetActinic(GyreMode(32,50,10,false) ); //GyreMode from 30% to 50% for 10 minutess on anti-sync mode
}

////// Place your custom code above here

I changed it to this:

////// Place your custom code below here

if (hour()>=4 && hour()<8)
{
ReefAngel.DCPump.Mode = Sine;
ReefAngel.DCPump.Speed = 30, 40;
}
else if (hour()>=8 && hour()<12)
{
ReefAngel.DCPump.Mode = TidalSwell; // TidalSwell at 55% on sync mode
ReefAngel.DCPump.Speed = 55;
}
else if (hour()>=12 && hour()<16)
{
ReefAngel.DCPump.Mode =millis();
ReefAngel.DCPump.Speed = 1200, 750?50:0;
}
else if (hour()>=16 && hour()<19)
{
ReefAngel.DCPump.Mode=LongPulse; // Long pulse at 0% to 50% with 10s pulse on sync mode
ReefAngel.DCPump.Speed =0,50,10;
}
else if (hour()>=19 && hour()<23)
{
ReefAngel.DCPump.Mode=Else; // ElseMode on sync mode, 40 +/- 10%
ReefAngel.DCPump.Speed =40, 10;
}
else
{
ReefAngel.DCPump.Mode=Gyre; //GyreMode from 30% to 50% for 10 minutes on sync mode
ReefAngel.DCPump.Speed = 32, 50, 10;
}

////// Place your custom code above here


Will the 2nd set of codes work? i know that 'millis' will not work as you have mentioned above.
Image
User avatar
Posts: 5343
Joined: Fri Jul 20, 2012 9:42 am
PostPosted: Tue Feb 03, 2015 7:02 am
No it won't work. When you use the DCPump class the Modes have built in parameters for duration and ranges. You can't pass multiple values to Speed.

ReefAngel.DCPump.Speed = 32, 50, 10;

You can only set one number.

Posts: 98
Joined: Sun Jul 21, 2013 8:18 am
PostPosted: Sun Feb 22, 2015 2:57 am
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>
#include <SoftwareSerial.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.SetTemperatureUnit( Celsius );  // set to Celsius Temperature
    ReefAngel.Use2014Screen();
    ReefAngel.AddRANet();
    // Ports toggled when relay looses communication
    ReefAngel.Relay.RANetFallBackE[0] = Port1Bit | Port5Bit | Port8Bit;
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePortsE[0] = Port5Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = 0;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = 0;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
   
    // Feeding Mode speed
    ReefAngel.DCPump.FeedingSpeed=0;

    // Ports that are always on
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Box1_Port5 );
    ReefAngel.Relay.On( Box1_Port8 );

    ////// Place additional initialization code below here
   

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

void loop()
{
    ReefAngel.StandardLights( Port1, 13, 0, 23, 00);
    ReefAngel.StandardLights( Port3, 13, 0, 23, 05);
    ReefAngel.StandardLights( Port7, 23, 0, 7, 05);
    ReefAngel.StandardLights( Port8, 23, 0, 7, 05);
    ReefAngel.StandardLights( Box1_Port1, 7, 0, 1, 00);
    ReefAngel.StandardLights( Box1_Port2, 22, 0, 7, 00);
    ReefAngel.StandardFan( Box1_Port6, 262,273);
    ReefAngel.StandardLights( Box1_Port7, 19, 0, 23, 00);
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync;
   
    if (hour()>=7 && hour()<23) // Turn Moonlights on/off
  {
    ReefAngel.PWM.SetChannel( 0, (0));
  }
  else
  {
    ReefAngel.PWM.SetChannel( 0, MoonPhase()/4);
  }
    ////// Place your custom code below here
   
if (hour()>=4 && hour()<8)

  ReefAngel.DCPump.SetMode(Sine,50,30,30) ;
}
else if (hour()>=8 && hour()<12)

  ReefAngel.DCPump.SetMode(TidalSwell,55,0); // TidalSwell at 55% on sync/antisync mode
}
else if (hour()>=12 && hour()<16)
{
  ReefAngel.DCPump.SetMode(Constant, millis()%1200>750?50:0,0);
}
else if (hour()>=16 && hour()<19)
{
  ReefAngel.DCPump.SetMode(LongPulse,50,10,0); // Long pulse at 0% to 50% with 10s pulse on sync/antisync mode
}
else if (hour()>=19 && hour()<23)
{
  ReefAngel.DCPump.SetMode(Else,40,20);           // ElseMode sync/antisync, 40 +/- 20%
}
else
{
  ReefAngel.DCPump.SetMode(Gyre,50,05,30); //GyreMode from 30% to 50% for 10 minutes on sync/antisync mode
}

    ////// Place your custom code above here

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

Return to My PDE/INO file

Who is online

Users browsing this forum: No registered users and 1 guest

cron