led dimming to led on/off ports

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

Posts: 214
Joined: Sat Oct 10, 2015 9:17 pm
PostPosted: Fri May 18, 2018 6:30 pm
i want to add update led code i tryed my self from code from lnevo but it dont do anything i moved controller to my moms tank so none of my old code works with this when i remove parts i dont want

what do i need to add/remove to have port 3 turn on when dimming add-on channel 0 is grater then 0% and and off if at 0%
what do i need to add/remove to have port 4 turn on when dimming add-on channel 1 is grater then 0% and and off if at 0%

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
        // Define Custom Memory Locations
        #define Mem_B_AtoHourInterval     101

void init_memory() {
          // Initialize Custom Memory Locations
         
          InternalMemory.write(Mem_B_AtoHourInterval,1);       //mb101
        }

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


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 | Port5Bit | Port6Bit | Port8Bit;
    // Ports toggled in Water Change Mode
    ReefAngel.WaterChangePorts = Port1Bit | Port5Bit | Port6Bit | Port8Bit;
    // Ports toggled when Lights On / Off menu entry selected
    ReefAngel.LightsOnPorts = Port3Bit | Port4Bit;
    // Ports turned off when Overheat temperature exceeded
    ReefAngel.OverheatShutoffPorts = Port5Bit;
    // Use T1 probe as temperature and overheat functions
    ReefAngel.TempProbe = T1_PROBE;
    ReefAngel.OverheatProbe = T1_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 800 );

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


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

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

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

void loop()
{
    ReefAngel.SingleATO(true, Port1 , InternalMemory.ATOExtendedTimeout_read(), InternalMemory.read(Mem_B_AtoHourInterval));
    ReefAngel.StandardLights( Port3,9,0,19,0 );
    ReefAngel.StandardLights( Port4,9,0,19,0 );
    ReefAngel.StandardHeater( Port5,775,785 );
    ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,0,65,0) );
    ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,0,45,0) );
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( NutrientTransport,70,10 );
    ReefAngel.DCPump.DaylightChannel = None;
    ReefAngel.DCPump.ActinicChannel = None;
    ReefAngel.DCPump.ExpansionChannel[0] = None;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = Sync;
    ReefAngel.DCPump.ExpansionChannel[5] = AntiSync;
    ////// Place your custom code below here
   

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

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

Image
User avatar
Posts: 2747
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sun May 20, 2018 12:25 pm
troylong45 wrote:what do i need to add/remove to have port 3 turn on when dimming add-on channel 0 is grater then 0% and and off if at 0%

This should work for the standard PWM expansion device (with 6 channels)
You would need something like this inside your loop() section:
Code: Select all
if (ReefAngel.PWM.GetChannelValue(0) > 0) {
   // Value over 0%
   ReefAngel.Relay.On(Port3);
} else {
   // otherwise, value IS 0 or less (which should never happen)
   ReefAngel.Relay.Off(Port3);
}

troylong45 wrote:what do i need to add/remove to have port 4 turn on when dimming add-on channel 1 is grater then 0% and and off if at 0%

And for this one...
Code: Select all
if (ReefAngel.PWM.GetChannelValue(1) > 0) {
   // Value over 0%
   ReefAngel.Relay.On(Port4);
} else {
   // otherwise, value IS 0 or less (which should never happen)
   ReefAngel.Relay.Off(Port4);
}


Then, I would also remove these lines too:
Code: Select all
    ReefAngel.StandardLights( Port3,9,0,19,0 );
    ReefAngel.StandardLights( Port4,9,0,19,0 );

Because they will override the port status from the PWM channels.

So, your loop section would look like this:
Code: Select all
void loop()
{
    ReefAngel.SingleATO(true, Port1 , InternalMemory.ATOExtendedTimeout_read(), InternalMemory.read(Mem_B_AtoHourInterval));
    ReefAngel.StandardHeater( Port5,775,785 );
    ReefAngel.PWM.SetChannel( 0, PWMParabola(9,0,20,0,0,65,0) );
    ReefAngel.PWM.SetChannel( 1, PWMParabola(9,0,20,0,0,45,0) );
    ReefAngel.DCPump.UseMemory = false;
    ReefAngel.DCPump.SetMode( NutrientTransport,70,10 );
    ReefAngel.DCPump.DaylightChannel = None;
    ReefAngel.DCPump.ActinicChannel = None;
    ReefAngel.DCPump.ExpansionChannel[0] = None;
    ReefAngel.DCPump.ExpansionChannel[1] = None;
    ReefAngel.DCPump.ExpansionChannel[2] = None;
    ReefAngel.DCPump.ExpansionChannel[3] = None;
    ReefAngel.DCPump.ExpansionChannel[4] = Sync;
    ReefAngel.DCPump.ExpansionChannel[5] = AntiSync;
    ////// Place your custom code below here

if (ReefAngel.PWM.GetChannelValue(0) > 0) {
   // Value over 0%
   ReefAngel.Relay.On(Port3);
} else {
   // otherwise, value IS 0 or less (which should never happen)
   ReefAngel.Relay.Off(Port3);
}

if (ReefAngel.PWM.GetChannelValue(1) > 0) {
   // Value over 0%
   ReefAngel.Relay.On(Port4);
} else {
   // otherwise, value IS 0 or less (which should never happen)
   ReefAngel.Relay.Off(Port4);
}

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

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

Posts: 214
Joined: Sat Oct 10, 2015 9:17 pm
PostPosted: Wed May 23, 2018 9:29 am
Thanks ill try that i think the code I was trying was missing some of These symbols }{ or actually I think there was a { be for the "if" command. That might be why so it never was reading the if or maybe else reading , cus it would force the lights on no matter % or relay overuse setting I would set
Ill be back if i get no where

Is there a code for dummies section like what call outs are and mean and commands
Image
User avatar
Posts: 2747
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Wed May 23, 2018 7:23 pm
There's not really a section or manual that spells out what all the functions are and how to use them or what they mean. The data is scattered throughout the forum and it ultimately lies inside the libraries. I think there was an effort to do this a while back but I do not know off hand if anything was finished or worked on.

Posts: 214
Joined: Sat Oct 10, 2015 9:17 pm
PostPosted: Sat May 26, 2018 3:18 pm
it worked great thanks

libraries would help me understand more on my own?
Image
User avatar
Posts: 2747
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sun May 27, 2018 6:17 am
troylong45 wrote:it worked great thanks

libraries would help me understand more on my own?
yes, looking at the libraries will (or should) help you understand better. if you can understand the code and how things function, it could benefit you.

Sent from my XT1585 using Tapatalk

Posts: 214
Joined: Sat Oct 10, 2015 9:17 pm
PostPosted: Sun May 27, 2018 12:35 pm
get the if ,else deal .

Like what maybe "if(X LOCATION(X VALUE) = X VALUE"
it is looking for the location to be = to value

And will make "{X LOCATION (X COMMAND) ; }else{X LOCATION (X COMMAND) ; }

So maybe
Code: Select all
if (reefangel.pwm.daylights) = 50 { reefangle.relay.on(port6) ; }else{reefangle.relay.off(port6) ; }

If spelled correct+correct location and capitalized correctly then that make
Relay box main port 6 on only if daylights is 50% and off if not
Image
User avatar
Posts: 2747
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Sun May 27, 2018 6:00 pm
yeah, you got the right idea (and yes, if you use proper capitalization and formatting)

Sent from my XT1585 using Tapatalk

Posts: 214
Joined: Sat Oct 10, 2015 9:17 pm
PostPosted: Sun May 27, 2018 9:48 pm
Then the rest is just kinda math and calling out What's already been created.
I realize there is way more behind the scenes when I opened lib. On dropbox Lol

Is the wave pattern topic up todate I was trying to find that info on drop box but must have missed it I wanna try to take a crack at adapting the dcpump mode to my liking and pumps and to find sync and antisync off sets (plus or minus value)
Image
User avatar
Posts: 2747
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
PostPosted: Mon May 28, 2018 10:13 am
troylong45 wrote:Then the rest is just kinda math and calling out What's already been created.
I realize there is way more behind the scenes when I opened lib. On dropbox Lol

Is the wave pattern topic up todate I was trying to find that info on drop box but must have missed it I wanna try to take a crack at adapting the dcpump mode to my liking and pumps and to find sync and antisync off sets (plus or minus value)
yes, that topic is up-to-date, however there is some additional information that is in a post towards the end of the thread. not sure how critical it is but I'm pretty sure it is important (something like saying the wave forms are built in the libraries or something like that). just make sure you read through the entire thread and not just the first post.

one thing to note is that you may have to experiment with the settings and modes. I have some gyres that won't do some of the modes and I found out during testing.

Sent from my XT1585 using Tapatalk

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 3 guests