Page 1 of 1

inserting custom code

Posted: Sun Nov 29, 2015 8:09 pm
by slm222
hello, I have a question. im really inexperienced at coding, which is a reason I went with a reef angel ( im wanting to learn more coding). I have a vague memory of html back in college days. Well... on to the question.

I saw the coding id like to try with my jebaos.

Code: Select all

if (hour()>=8 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(60,20,true) ); // ReefCrest at 60% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(60,20,false) ); // ReefCrest at 60% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
  ReefAngel.PWM.SetDaylight( ShortPulseMode(0,60,200,true) ); // Short pulse at 60% with 200ms pulse on sync mode
  ReefAngel.PWM.SetActinic( ShortPulseMode(0,60,200,false) ); // Short pulse at 60% with 200ms pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( LongPulseMode(0,60,10,true) ); // Long pulse at 60% with 10s pulse on sync mode
  ReefAngel.PWM.SetActinic( LongPulseMode(0,60,10,false) ); // Long pulse at 60% with 10s pulse on anti-sync mode
}
if I wanted to put that code in what would I need to change in my current code?


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


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

void loop()
{
ReefAngel.MHLights( Port1,12,30,14,30,5 );
ReefAngel.MHLights( Port2,5,0,22,0,10 );
ReefAngel.StandardLights( Port3,18,0,10,0 );
ReefAngel.StandardHeater( Port4,770,788 );
ReefAngel.StandardLights( Port5,18,0,10,0 );
ReefAngel.SingleATO( true,Port8,180,0 );
ReefAngel.PWM.SetDaylight( PWMSlope(8,0,20,0,5,100,120,5) );
ReefAngel.PWM.SetActinic( PWMSlope(8,0,20,0,5,100,120,5) );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( LongPulse,100,180 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here


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

Re: inserting custom code

Posted: Sun Nov 29, 2015 8:22 pm
by Lionfan
slm222 wrote:hello, I have a question. im really inexperienced at coding, which is a reason I went with a reef angel ( im wanting to learn more coding). I have a vague memory of html back in college days. Well... on to the question.

I saw the coding id like to try with my jebaos.

Code: Select all

if (hour()>=8 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(60,20,true) ); // ReefCrest at 60% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(60,20,false) ); // ReefCrest at 60% +/- 20% on anti-sync mode
}
else if (hour()>=12 && hour()<18)
{
  ReefAngel.PWM.SetDaylight( ShortPulseMode(0,60,200,true) ); // Short pulse at 60% with 200ms pulse on sync mode
  ReefAngel.PWM.SetActinic( ShortPulseMode(0,60,200,false) ); // Short pulse at 60% with 200ms pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( LongPulseMode(0,60,10,true) ); // Long pulse at 60% with 10s pulse on sync mode
  ReefAngel.PWM.SetActinic( LongPulseMode(0,60,10,false) ); // Long pulse at 60% with 10s pulse on anti-sync mode
}
if I wanted to put that code in what would I need to change in my current code?


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


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

void loop()
{
ReefAngel.MHLights( Port1,12,30,14,30,5 );
ReefAngel.MHLights( Port2,5,0,22,0,10 );
ReefAngel.StandardLights( Port3,18,0,10,0 );
ReefAngel.StandardHeater( Port4,770,788 );
ReefAngel.StandardLights( Port5,18,0,10,0 );
ReefAngel.SingleATO( true,Port8,180,0 );
ReefAngel.PWM.SetDaylight( PWMSlope(8,0,20,0,5,100,120,5) );
ReefAngel.PWM.SetActinic( PWMSlope(8,0,20,0,5,100,120,5) );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( LongPulse,100,180 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;
////// Place your custom code below here


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




I'm gonna say delete "ReefAngel.DCPump.SetMode( LongPulse,100,180 );"
and replace it with your new code.

Uhh.. just kind of browsing thru your code, do you realize your Daylight and Actnic Ports are set to be both for your lights, and DC pump?



ReefAngel.PWM.SetActinic( PWMSlope(8,0,20,0,5,100,120,5) );
ReefAngel.DCPump.UseMemory = false;
ReefAngel.DCPump.SetMode( LongPulse,100,180 );
ReefAngel.DCPump.DaylightChannel = Sync;
ReefAngel.DCPump.ActinicChannel = AntiSync;

Re: inserting custom code

Posted: Sun Nov 29, 2015 8:41 pm
by slm222
Im sure about that part. Everything on there so far is via the wizard. I am using the director for some Ai hydras I have.

Re: inserting custom code

Posted: Mon Nov 30, 2015 6:18 am
by cosmith71
So your lights aren't plugged into the daylight and actinic ports? You should take out the lighting code then. The way it's written now, the SetDayLight and SetActinic functions are being immediately over-written by the DCPump.SetMode function.

Otherwise, as stated above, put all that pump code in place of the ReefAngel.DCPump.SetMode line. In fact, you can take out all four of the current DCPump lines as the new code handles all that.

--Colin

Re: inserting custom code

Posted: Mon Nov 30, 2015 1:01 pm
by slm222
Ok I got it to work. seems to be working well, here is what I ended up with. Lionfan and cosmith71, thank you for the above corrections and steering me in the right course.

Code: Select all

if (hour()>=7 && hour()<10)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,250,true) ); // Long pulse at 100% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,250,false) ); // Long pulse at 100% with 300s pulse on anti-sync mode
}
else if (hour()>=10 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,180,true) ); // Sine Wave at 100% with 180s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,180,false) ); // Sine Wave at 100% with 180s pulse on anti-sync mode
}
else if (hour()>=12 && hour()<15)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(80,20,true) ); // ReefCrest at 80% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(80,20,false) ); // ReefCrest at 80% +/- 20% on anti-sync mode
}
else if (hour()>=15 && hour()<17)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,180,true) ); // Sine Wave at 100% with 180s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,180,false) ); // Sine Wave at 100% with 180s pulse on anti-sync mode
}
else if (hour()>=17 && hour()<20)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,250,true) ); // Long pulse at 100% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,250,false) ); // Long pulse at 100% with 300s pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( SineMode(0,35,400,true) ); // Sine Wave at 35% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,35,400,false) ); // Sine Wave at 35% with 300s pulse on anti-sync mode
} 
I removed all the extra DC stuff do I leave this or remove it?

Code: Select all

    ReefAngel.DCPump.UseMemory = false;

Re: inserting custom code

Posted: Tue Dec 01, 2015 6:13 am
by cosmith71
You can leave that out. You're setting the PWM ports directly instead of using the PWM.SetMode stuff so you don't need it.

Re: inserting custom code

Posted: Tue Dec 01, 2015 7:53 am
by slm222
I ran into a problem once removing the dc pump code and setting everything to the PWM directly. My feed mode and water change mode no longer turn off the pumps.

Re: inserting custom code

Posted: Tue Dec 01, 2015 1:57 pm
by Lionfan
slm222 wrote:I ran into a problem once removing the dc pump code and setting everything to the PWM directly. My feed mode and water change mode no longer turn off the pumps.
Repost you're code.
I think maybe you bypassed the DCpumpFeedingspeed

Re: inserting custom code

Posted: Tue Dec 01, 2015 2:31 pm
by slm222

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.AddStandardMenu();  // Add Standard Menu

    ReefAngel.Use2014Screen();  // Let's use 2014 Screen 
    // Ports toggled in Feeding Mode
    ReefAngel.FeedingModePorts = Port2Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port2Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = 0;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port4Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 830 );

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


    // Ports that are always on
    ReefAngel.Relay.On( Port6 );
    ReefAngel.Relay.On( Port7 );

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

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

void loop()
{
    ReefAngel.MHLights( Port1,12,30,14,30,5 ); //t5ho
    ReefAngel.MHLights( Port2,5,0,22,0,5 ); //skimmer
    ReefAngel.StandardLights( Port3,18,0,10,0 ); //fugelight
    ReefAngel.StandardHeater( Port4,780,788 ); //heater
    ReefAngel.StandardLights( Port5,18,0,10,0 ); //scrubber light
    ReefAngel.SingleATO( true,Port8,300,0 ); // ato

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

// Wave Makers
if (hour()>=7 && hour()<10)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,300,true) ); // Long pulse at 100% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,300,false) ); // Long pulse at 100% with 300s pulse on anti-sync mode
}
else if (hour()>=10 && hour()<12)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,180,true) ); // Sine Wave at 100% with 180s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,180,false) ); // Sine Wave at 100% with 180s pulse on anti-sync mode
}
else if (hour()>=12 && hour()<15)
{
  ReefAngel.PWM.SetDaylight( ReefCrestMode(80,20,true) ); // ReefCrest at 80% +/- 20% on sync mode
  ReefAngel.PWM.SetActinic( ReefCrestMode(80,20,false) ); // ReefCrest at 80% +/- 20% on anti-sync mode
}
else if (hour()>=15 && hour()<17)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,180,true) ); // Sine Wave at 100% with 180s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,180,false) ); // Sine Wave at 100% with 180s pulse on anti-sync mode
}
else if (hour()>=17 && hour()<20)
{
  ReefAngel.PWM.SetDaylight( SineMode(0,100,300,true) ); // Long pulse at 100% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,100,300,false) ); // Long pulse at 100% with 300s pulse on anti-sync mode
}
else
{
  ReefAngel.PWM.SetDaylight( SineMode(0,35,400,true) ); // Sine Wave at 35% with 300s pulse on sync mode
  ReefAngel.PWM.SetActinic( SineMode(0,35,400,false) ); // Sine Wave at 35% with 300s pulse on anti-sync mode
}
    

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

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