coding to memory for jebao pumps

Do you have a question on how to do something.
Ask in here.
Post Reply
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

coding to memory for jebao pumps

Post by Civics14 »

How do I code to memory so I can test out different modes, but at the same time be able to revert back to my custom schedule?

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 <PAR.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.PHMin=511;
    ReefAngel.PHMax=760;
    InternalMemory.DCPumpThreshold_write(15);
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit | Port8Bit;
    // Use T3 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 835 );

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


    // Ports that are always on
    ReefAngel.Relay.On( Port2 ); //Dimming Module
    ReefAngel.Relay.On( Port4 ); //Jebao DP4
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1,780,790 );
    ReefAngel.StandardLights( Port3,12,00,22,00 ); // Secondary Pump
    ReefAngel.StandardLights( Port7,0,30,10,30 ); // Fuge Lamp
    ReefAngel.DCPump.ExpansionChannel[0] = None;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = None;
    ReefAngel.DCPump.ExpansionChannel[5] = None;
    ////// Place your custom code below here
    
    ////// Light Schedule Below
          //Set Channel 0 LED RED
          if (PWMSlope(13,15,22,45,5,85,120,5)<=6) 
          {
            ReefAngel.PWM.SetChannel( 0, 0);
            ReefAngel.PWM.SetChannel( 3, 0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 0, PWMSlope(13,15,22,45,5,85,120,5) );
            ReefAngel.PWM.SetChannel( 3, PWMSlope(13,15,22,45,5,85,120,5) );
          }
          
          //Set Channel 1 LED WHITE
          if (PWMSlope(13,30,22,30,5,80,120,5)<=6)
          {
            ReefAngel.PWM.SetChannel( 1, 0);
            ReefAngel.PWM.SetChannel( 4, 0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 1, PWMSlope(13,30,22,30,5,80,120,5) );
            ReefAngel.PWM.SetChannel( 4, PWMSlope(13,30,22,30,5,80,120,5) );
          }
          
          //Set Channel 2 LED BLUE
          if (PWMSlope(13,0,23,0,5,100,120,5)<=6)
          {
            ReefAngel.PWM.SetChannel( 2,0);
            ReefAngel.PWM.SetChannel( 5,0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 2, PWMSlope(13,0,23,0,5,100,120,5) );
            ReefAngel.PWM.SetChannel( 5, PWMSlope(13,0,23,0,5,100,120,5) );
          }
   ////// End of Light Schedule
      
  //Setting Jebao Pump Wave Patterns
  if (hour()>=12 && hour()<13 ) // Morning mode between 12pm and 1pm
  {
    ReefAngel.DCPump.SetMode(ReefCrest,40,20 );
  }
     else if (hour()>=13 && hour()<15) // Day mode between 1m and 3pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,50,25 );  
  }
     else if (hour()>=15 && hour()<20) // Day mode between 3pm and 8pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,75,25 );  
  }
     else if (hour()>=20 && hour()<21) // Evening mode between 8pm and 9pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,60,15 );
  }
     else if (hour()>=21 && hour()<23) //Calming beween 9pm and 11pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,40,20 );  
  }
     else
  {
    ReefAngel.DCPump.SetMode( ReefCrest,40,10 );  // Night Mode between 11pm and l2pm
  }
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync; //use None when inactivated
    
    ////// Place your custom code above here

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

Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

Try this. Go to the portal and set it to "Custom" to run your schedule. Otherwise, it will run whatever mode you select.

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 <PAR.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.PHMin=511;
    ReefAngel.PHMax=760;
    InternalMemory.DCPumpThreshold_write(15);
    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port4Bit | Port5Bit | Port6Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port3Bit | Port4Bit | Port5Bit | Port6Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port2Bit | Port3Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port1Bit | Port2Bit | Port3Bit | Port4Bit | Port7Bit | Port8Bit;
    // Use T3 probe as temperature and overheat functions
    ReefAngel.TempProbe = T2_PROBE;
    ReefAngel.OverheatProbe = T2_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 835 );

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


    // Ports that are always on
    ReefAngel.Relay.On( Port2 ); //Dimming Module
    ReefAngel.Relay.On( Port4 ); //Jebao DP4
    ReefAngel.Relay.On( Port5 );
    ReefAngel.Relay.On( Port6 );

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

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

void loop()
{
    ReefAngel.StandardHeater( Port1,780,790 );
    ReefAngel.StandardLights( Port3,12,00,22,00 ); // Secondary Pump
    ReefAngel.StandardLights( Port7,0,30,10,30 ); // Fuge Lamp
    ReefAngel.DCPump.ExpansionChannel[0] = None;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = None;
    ReefAngel.DCPump.ExpansionChannel[5] = None;
    ////// Place your custom code below here
    
    ////// Light Schedule Below
          //Set Channel 0 LED RED
          if (PWMSlope(13,15,22,45,5,85,120,5)<=6) 
          {
            ReefAngel.PWM.SetChannel( 0, 0);
            ReefAngel.PWM.SetChannel( 3, 0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 0, PWMSlope(13,15,22,45,5,85,120,5) );
            ReefAngel.PWM.SetChannel( 3, PWMSlope(13,15,22,45,5,85,120,5) );
          }
          
          //Set Channel 1 LED WHITE
          if (PWMSlope(13,30,22,30,5,80,120,5)<=6)
          {
            ReefAngel.PWM.SetChannel( 1, 0);
            ReefAngel.PWM.SetChannel( 4, 0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 1, PWMSlope(13,30,22,30,5,80,120,5) );
            ReefAngel.PWM.SetChannel( 4, PWMSlope(13,30,22,30,5,80,120,5) );
          }
          
          //Set Channel 2 LED BLUE
          if (PWMSlope(13,0,23,0,5,100,120,5)<=6)
          {
            ReefAngel.PWM.SetChannel( 2,0);
            ReefAngel.PWM.SetChannel( 5,0);
          }
          else
          {
            ReefAngel.PWM.SetChannel( 2, PWMSlope(13,0,23,0,5,100,120,5) );
            ReefAngel.PWM.SetChannel( 5, PWMSlope(13,0,23,0,5,100,120,5) );
          }
   ////// End of Light Schedule
      
  //Setting Jebao Pump Wave Patterns
  if (InternalMemory.DCPumpMode_read()==11)   // If custom mode on Portal
{
  ReefAngel.DCPump.UseMemory = false;
  if (hour()>=12 && hour()<13 ) // Morning mode between 12pm and 1pm
  {
    ReefAngel.DCPump.SetMode(ReefCrest,40,20 );
  }
     else if (hour()>=13 && hour()<15) // Day mode between 1m and 3pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,50,25 );  
  }
     else if (hour()>=15 && hour()<20) // Day mode between 3pm and 8pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,75,25 );  
  }
     else if (hour()>=20 && hour()<21) // Evening mode between 8pm and 9pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,60,15 );
  }
     else if (hour()>=21 && hour()<23) //Calming beween 9pm and 11pm
  {
    ReefAngel.DCPump.SetMode( ReefCrest,40,20 );  
  }
     else
  {
    ReefAngel.DCPump.SetMode( ReefCrest,40,10 );  // Night Mode between 11pm and l2pm
  }
}  
  else ReefAngel.DCPump.UseMemory = true;    //  If it's not custom mode on the portal, then do what mode the portal says.

    ReefAngel.DCPump.DaylightChannel = Sync;
    ReefAngel.DCPump.ActinicChannel = AntiSync; //use None when inactivated
    
    ////// Place your custom code above here

    // This should always be the last line
    ReefAngel.Portal( "civics14" );
    ReefAngel.ShowInterface();
}
Last edited by cosmith71 on Sat Apr 30, 2016 5:56 am, edited 1 time in total.
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: coding to memory for jebao pumps

Post by Civics14 »

I'll try when I get home. Thanks as always.
Image
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: coding to memory for jebao pumps

Post by Civics14 »

That didn't work, any other suggestions? It stayed on internal memory
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

Oops, forgot a line. I edited the post above. It should work now.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

Here's the exact code I use, for future reference.

Code: Select all

void PumpControl()
{
  // *******************  Pump Control *******************

  if (InternalMemory.DCPumpMode_read()==11)   // If custom mode on Portal
  {
    ReefAngel.DCPump.UseMemory = false;    // Turn off memory control
    ReefAngel.DCPump.SetMode(Else,60,30);  // If nothing changes it in the next few lines, this is what runs.
    ReefAngel.DCPump.Threshold=20;  
    if (hour()>=22 || hour()<9) ReefAngel.DCPump.SetMode(Gyre,80,30,50);  // Gyre max, duration, minimum
    if (hour()>=9 && hour()<10) ReefAngel.DCPump.SetMode(Gyre,90,30,60);  // Gyre max, duration, minimum
    if (hour()>=10 && hour()<11)
    {
      ReefAngel.DCPump.Threshold=20;
      ReefAngel.DCPump.SetMode(Else,40,20);    // Else mode from 1000 to 1100.  Wake up!
    }
  }
  else ReefAngel.DCPump.UseMemory = true;    //  If it's not custom mode on the portal, then do what mode the portal says.
}
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: coding to memory for jebao pumps

Post by Civics14 »

i think that did the trick. just to confirm, when i select custom, i'm assuming after it goes through the loop, it changes the selection based on the programming and it no longer is "custom" per say.
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

It will run whatever mode is selected on the portal. If you set it to "custom" on the portal then it will run what is programmed in your code. So, for everyday use, leave it on custom. If you want to try a different waveform, then set it to whatever wave you want.
Civics14
Posts: 95
Joined: Fri Nov 14, 2014 8:27 am

Re: coding to memory for jebao pumps

Post by Civics14 »

Thank you very much. Every thing works!!
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

You're welcome!
saf1
Posts: 111
Joined: Thu Jun 28, 2012 1:46 pm

Re: coding to memory for jebao pumps

Post by saf1 »

Cosmith71 - Is that a standard feature of using ReefAngel.DCPump.UseMemory = true or your custom code block?

If that is a feature of setting use memory to true that is slick.
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: coding to memory for jebao pumps

Post by cosmith71 »

Yep, assuming you have your ports set to sync or antisync, then setting UseMemory to true will do what the portal (or the app) tells it to.
Post Reply