Moonlights

Do you have a question on how to do something.
Ask in here.
Post Reply
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Moonlights

Post by ecam »

I was using this code to control my moonlights in my Ai sols

Code: Select all

// ReefAngel.AI.SetChannel( RoyalBlue, PWMParabola(9,0,20,0,15,100,(MoonPhase()/5)<3 ? 3:MoonPhase()/5) );

I am now using the

Daylight dimming module for the dimming port and an LED stunner. How can i incorprate that code into this from the Reef Angel set-up tool


ReefAngel.PWM.SetDaylight( MoonPhase() );
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Moonlights

Post by rimai »

That works, but how did you get the LED stunner to dim with RA?
Roberto.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

I did some reseacrh and found out that they could be dimmed on the APEX. And i figured anything that controler can do it RA can do andthen some.... So i purchased this
http://www.amazon.com/gp/product/B006G0 ... UTF8&psc=1
striped the power sure and ran the connections to the dimmer port....
(*please note: this driver will not work without a 0-10V controller (such as Apex w/ VDM, or ReefKeeper w/ ALC).) which is 0-10. I tested it last night and it lights up just fine. Tonight I will find out how well it dims it.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

My question previously is that I want to but the same parameters in this code

ReefAngel.PWM.SetDaylight( MoonPhase() );

that i used for the AI sol RB.. is that possible
where does this part code in within the moonphase COMMAND
// ReefAngel.AI.SetChannel( RoyalBlue, PWMParabola(9,0,20,0,15,100,(MoonPhase()/5)<3 ? 3:MoonPhase()/5) );
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Moonlights

Post by rimai »

Ahh, you got a meanwell driver :)
Yes, the code you posted works, but it will just do moonphase. Do you also want to do the parabola?
Roberto.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

Yes. I do.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Moonlights

Post by lnevo »

ReefAngel.PWM.SetDaylight( PWMParabola(9,0,20,0,15, MoonPhase(),0 );

I think that should do it. I left the 15 because i think thats the lowest the meanwells go before turning off..
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

Where do i put that code for the moonlights? i keep gettin exepcted ) token when compliing

Code: Select all

#include <RA_ATO.h>
#include <RF.h>
#include <ReefAngel_Features.h>
#include <Globals.h>
#include <RA_Wifi.h>
#include <Wire.h>
#include <OneWire.h>
#include <Time.h>
#include <DS1307RTC.h>fafa
#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>fa
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <PH.h>
#include <WaterLevel.h>
#include <ReefAngel.h>

////// Place global variable code below here
  byte myRFMode=0;
    byte myRFDuration=0;
    byte myRFSpeed=0;


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


void setup()
{
    // This must be the first line
    ReefAngel.Init();  //Initialize controller
    // Ports toggled in Feeding Mode
ReefAngel.WaterChangePorts = Port1Bit | Port8Bit; // Turn off Ports 5 and 6 when Feeding Mode is activated
  ReefAngel.FeedingModePorts = Port1Bit | Port6Bit | Port8Bit; // Turn off Ports 1, 6, 7 and 8 when Water Change Mode is activated
  ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit| Port5Bit;
  ReefAngel.OverheatShutoffPorts = Port2Bit |Port3Bit | Port4Bit | Port5Bit | Port7Bit; // Turn off Ports 3,
    ReefAngel.TempProbe = T3_PROBE;
    ReefAngel.OverheatProbe = T3_PROBE;
    // Set the Overheat temperature setting
    InternalMemory.OverheatTemp_write( 825 );

    // Setup ATO Port for AI communication
    ReefAngel.AI.SetPort( lowATOPin );



    // Ports that are always on
    ReefAngel.Relay.On( Port1 );
    ReefAngel.Relay.On( Box1_Port2 );  // Razor Led
    ReefAngel.Relay.On( Box1_Port4 ); // Sump Equipment - UV, Pump
    ReefAngel.Relay.On( Box1_Port5 ); // MP40s    
    ReefAngel.Relay.On( Box1_Port6 ); // JBJ
    ////// Place additional initialization code below here
    

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

void loop()
{ 
  //  Port1 Return pump...  on all the time!!!
      ReefAngel.Relay.Set( Port2, !ReefAngel.Relay.Status( Port4 ) ); //Refuge
  //  Port3 Return pump...  not used
      ReefAngel.StandardLights( Port4,10,0,20,0 ); //ATI Actinic
      ReefAngel.StandardLights( Port5,11,0,19,0 );  //ATI Daylight
      ReefAngel.StandardLights( Port6,10,0,20,0 );  //ATI Fan
      ReefAngel.StandardHeater( Port7,778,790 ); //Heater
      ReefAngel.Relay.DelayedOn( Port8,2 ); //Skimmer
      ReefAngel.Relay.Off( Box1_Port7); // Lunar Hub          Port #9
 //   Box1_Port2 Razor_LED (Sump)...  on all the time!!!      Port #10
      ReefAngel.Relay.Off( Box1_Port3); // Start with the relay off
              if (hour()>=5 && hour()<10) ReefAngel.Relay.On(Box1_Port3); // Moonlight Between 5-10am turn the relay on
              if (hour()>=20 && hour()<=23) ReefAngel.Relay.On(Box1_Port3); // From 8pm-Midnight turn the relay on

 //   Box1_Port4 Ecotech MP_40 Pumps  on all the time!!!      Port #12
 //   Box1_Port5 Razor_LED (Sump)...  on all the time!!!      Port #13
 //   Box1_Port6 JBJ ATO ...          on all the time!!!      Port #14
     ReefAngel.Relay.Off( Box1_Port7);  // ALK Doser ...      Port #15
     ReefAngel.Relay.Off( Box1_Port8);  // Calc Doser ...     Port #16

 ReefAngel.PWM.SetDaylight(PWMParabola(9,0,20,0,15, MoonPhase(),0 );

 
//    ReefAngel.AI.SetChannel( White, PWMParabola(11,0,17,0,0,75,0) );
//    ReefAngel.AI.SetChannel( Blue, PWMParabola(9,0,20,0,15,100,0) );
//    ReefAngel.AI.SetChannel( RoyalBlue, PWMParabola(9,0,20,0,15,100,(MoonPhase()/5)<3 ? 3:MoonPhase()/5) );
    ReefAngel.RF.UseMemory = false;
    ReefAngel.RF.SetMode( ReefCrest,85,10 );

  //  ReefAngel.RF.SetChannel( Radion_White, PWMParabola(9,0,20,0,0,60,0) );
  //  ReefAngel.RF.SetChannel( Radion_RoyalBlue, MoonPhase() );
  //  ReefAngel.RF.SetChannel( Radion_Red, PWMParabola(9,0,20,0,15,65,15) );
  //  ReefAngel.RF.SetChannel( Radion_Green, PWMParabola(9,0,20,0,15,50,15) );
  //  ReefAngel.RF.SetChannel( Radion_Blue, MoonPhase() );
 //   ReefAngel.RF.SetChannel( Radion_Intensity, PWMParabola(9,0,20,0,15,94,15) );
  //  if ( second()==0 ) ReefAngel.RF.RadionWrite();







    ////// Place your custom code below here
    
    
      ReefAngel.RF.UseMemory = false;
      if (hour()>=6 && hour()<11)
        myRFSetMode(ReefCrest,85,10);
      else if (hour()>=11 && hour()<13)
        myRFSetMode(ReefCrest,85,10);
      else if (hour()>=13 && hour()<16)
        myRFSetMode(Smart_NTM,85,15);
      else if (hour()>=16 && hour()<19)
        myRFSetMode(ReefCrest,65,10);
      else
        myRFSetMode(Lagoon,40,10);
         
     
        
    // Hardcode PH calibrations
     //ReefAngel.PHMin=544; // PH7.0
     //ReefAngel.PHMax=830; // PH10.0

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

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

void DrawCustomMain()
{
    int x,y;
    char text[10];
    // Aqua Illumination
    x = 10;
    y = 20;
    ReefAngel.LCD.DrawText( COLOR_DODGERBLUE,DefaultBGColor,x,y,"WH:" );
    ReefAngel.LCD.DrawText( COLOR_DODGERBLUE,DefaultBGColor,x+38,y,"BL:" );
    ReefAngel.LCD.DrawText( COLOR_DODGERBLUE,DefaultBGColor,x+76,y,"RB:" );
    for ( int a=0;a<3;a++ )
    {
      ReefAngel.LCD.DrawText( COLOR_DODGERBLUE,DefaultBGColor,x+18,y,ReefAngel.AI.GetChannel(a) );
      x += 38;
    }
    pingSerial();

    // Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 48, ReefAngel.Params,
    ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
    ReefAngel.LCD.DrawMonitor( 15, 48, ReefAngel.Params );
#endif // defined DisplayLEDPWM && ! defined RemoveAllLights
    pingSerial();

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

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

    void DrawCustomGraph()
    {
    }

    void myRFSetMode(byte m, byte s, byte d)
    {
      if (m!=myRFMode || s!=myRFSpeed || d!=myRFDuration || millis()<5000)
      {
        myRFMode=m;
        myRFSpeed=s;
        myRFDuration=d;
        ReefAngel.RF.SetMode(m,s,d);
      }
    }
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Moonlights

Post by lnevo »

I missed a ) before the ;
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

Just rememebered that might first box is analog dimming....

ReefAngel.PWM.SetDaylight(PWMParabola(20,0,23,0,0, MoonPhase(),0 ));


assuming this wont work....

Can i change it to analog?

Here are the specs.....
http://www.meanwell.com/search/eln-60/ELN-60-spec.pdf
is it digital or analog?

Also roberto, since i recently brought a new relay. does that mean that all i hav eto do is switch my boxes (assuming the new default is pwm) in the the head unit and then i will have PWM?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Moonlights

Post by lnevo »

It makes no difference pwm or analog. Same code.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

I tried 0 , 10 , 20, and 100. They all look the same. It's not getting the dimming signal
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Moonlights

Post by lnevo »

If you just put the moonphase() function does it work?

Are you in the daylight port or actinic?
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

Daylight port
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

Just switch to moon phase. No change
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Moonlights

Post by rimai »

Can you measure the voltage in the dimming ports?
Roberto.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

rimai wrote:Can you measure the voltage in the dimming ports?

Ok... ill put my volt meter on it when i get home.
ecam
Posts: 229
Joined: Thu Nov 15, 2012 11:27 am

Re: Moonlights

Post by ecam »

These are still not dimming. Im goign to convert to memory and send different signals to see if i can get it to work.

How do I take the dimming channel current?
Post Reply