Could you take a glance at this? (Code help)

Do you have a question on how to do something.
Ask in here.
Post Reply
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Could you take a glance at this? (Code help)

Post by Dctrojan »

Im having problems with my lights . I want my daylight lights (port3) to gradually dim on in the mornings starting at say 11 AM and eventually dim completely off around 8 pm. Everyday my lights both daylight and actinic channels are completely off until around noon everyday. Here is what i want to happen but i cant seem to figure out what im doing wrong.

Everyday:
Actinic channel (port4)
on : 7:30 AM
off : 10:35 pm

daylight (port3)
start coming on at 11 AM @ 5% gradually brighten up to 75% peak (parabola) and then gradually go back down throughout the day to 0% at 8:00pm

Moonlight(port2)
On: 10:30 PM
Off : 7:35 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>

////// Place global variable code below here


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


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


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

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

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

void loop()
{
    ReefAngel.StandardLights( Port2,22,30,11,0 );
    ReefAngel.StandardLights( Port3,12,0,20,30 );
    ReefAngel.StandardLights( Port4,11,0,22,35 );
    ReefAngel.WavemakerRandom( Port5,5,60 );
    ReefAngel.WavemakerRandom( Port6,19,37 );
    ReefAngel.SingleATO( false,Port7,66,0 );
    ReefAngel.StandardHeater( Port8,770,791 );
    ReefAngel.PWM.SetDaylight( PWMParabola(12,0,20,0,0,70,0) );
    ////// Place your custom code below here
    pinMode(lowATOPin,OUTPUT);
    if (InternalMemory.LEDPWMActinic_read()<=100)
    analogWrite(lowATOPin,InternalMemory.LEDPWMActinic_read()*2.55);
    else
    analogWrite(lowATOPin,MoonPhase()*2.55);


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

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 20, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

    // pH Expansion
    ReefAngel.LCD.DrawText( COLOR_MEDIUMSEAGREEN,DefaultBGColor,15,66, "PHE:" );
    ReefAngel.LCD.DrawSingleMonitor( ReefAngel.Params.PHExp,COLOR_MEDIUMSEAGREEN,39,66, 100 );    
    pingSerial();

    // Main Relay Box
    byte TempRelay = ReefAngel.Relay.RelayData;
    TempRelay &= ReefAngel.Relay.RelayMaskOff;
    TempRelay |= ReefAngel.Relay.RelayMaskOn;
    ReefAngel.LCD.DrawOutletBox( 12, 92, TempRelay );
    pingSerial();

    // Date and Time
    ReefAngel.LCD.DrawDate( 6, 122 );
    pingSerial();
}

void DrawCustomGraph()
{
}
/code]
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Could you take a glance at this? (Code help)

Post by rimai »

If only meanwell drivers could dim to 0% :(
They are known to cutoff at 15 to 20%, so anything lower than that will be off.
I would suggest you start at 15 to 20%.
Roberto.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Could you take a glance at this? (Code help)

Post by binder »

i start mine at like 20% and goto 100% over an hour period.


Sent from my iPad mini
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Could you take a glance at this? (Code help)

Post by Dctrojan »

Yes they are meanwell and your correct they do cut off around 15. I cant figure whats up with my code. It seems like my lights port3 doesnt dim on, they appear full blast at around noon but at 11 am the tank is totally dark. Can someone verify this for me and point me in the right direction to change this and to adjust the brightness on the dimmers without using the setup wizard

Sent from my SAMSUNG-SGH-I337 using Tapatalk
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Could you take a glance at this? (Code help)

Post by rimai »

15% is already pretty bright in my opinion.
The human eye can't really distinguish very well. I think anything over 50% is very hard to tell.
Is the DP changing accordingly in the screen?
Try using the ControllerTester code to see if you can see any difference when you increase the % of DP.
Roberto.
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Could you take a glance at this? (Code help)

Post by Dctrojan »

binder wrote:i start mine at like 20% and goto 100% over an hour period.
This is approximately what I want to do. I have new corals and I wanted to lower the lights and gradually raise them throught the week or so.

Where in my code is the line for dimming them over a period of time say start at 20 % and go up to 70% at a gradual increase then when it reaches 70% it gradually starts to dim back down to 20%

Im sorry for asking so many questions.
Thanks

Sent from my iPad mini
Sent from my SAMSUNG-SGH-I337 using Tapatalk
User avatar
Dctrojan
Posts: 96
Joined: Wed Oct 16, 2013 9:50 am

Re: Could you take a glance at this? (Code help)

Post by Dctrojan »

Found it I think.
this is it : PWMParabola(12,0,20,0,0,70,0)
Correct?
12,0 means it comes on at noon?
The 20 and 70 are the analog values right? What are the other 0's for?

Sent from my SAMSUNG-SGH-I337 using Tapatalk
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Could you take a glance at this? (Code help)

Post by rimai »

Roberto.
Post Reply