Question on LED dimming

Do you have a question on how to do something.
Ask in here.
Post Reply
Amos Poh
Posts: 107
Joined: Sun Jul 22, 2012 4:51 am
Location: Singapore

Question on LED dimming

Post by Amos Poh »

Hi all i currently has a light set which has 3 channels,
Channel 1: white
Channel 2: Blue
Channel 3: red, green, uv

i am using the Analog Dimming expansion will be using 3 channels to control the light set.

Question 1) how to code it to run turn on gradually for the 3 channels during the day for example:
before 11 am: channel 2(blue on 5%) act as moonlight
from 11 am onwards slowing and gradually ram up channel 2 (blue to 30%) at the same time ram up channel 3 slowly and gradually to 50% and also Channel 1 concurrently ram up to 70%- Maybe the whole set rise process will take 30-45mins
then throughout the day all channel 1 and 2 gradually ram up to max 80% at 5pm.
after 5pm it gradually tone down to sunset at 11pm leaving channel 2 on at 5%(moonlight)

Question 2) how to create a lightning storm effect whereby the white (channel 1) blinks at 90% Blue (channel2) blinks at 50% and red (channel 3)at 70%

I am just using my imagination to mimic the colors of the nature not sure if it will turn out nice :lol:
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Question on LED dimming

Post by rimai »

Did you try the wizard?

Sent from my SPH-L710 using Tapatalk 4
Roberto.
Amos Poh
Posts: 107
Joined: Sun Jul 22, 2012 4:51 am
Location: Singapore

Re: Question on LED dimming

Post by Amos Poh »

rimai wrote:Did you try the wizard?

Sent from my SPH-L710 using Tapatalk 4

Just walk thru the wizard. Guess that will solve most of my codes.

How do I add lightning modes? Question 2.

Thanks Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Question on LED dimming

Post by rimai »

Roberto.
Amos Poh
Posts: 107
Joined: Sun Jul 22, 2012 4:51 am
Location: Singapore

Re: Question on LED dimming

Post by Amos Poh »


After reading thru i still have no idea how to include a lightning or storm mode in my code( too complex for me :o )
Sorry for being a pain in the xxx.

below are my codes appreciate if anyone can assist me in this :)

#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 <ReefAngel.h>

////// Place global variable code below here
byte WCstatus=0;

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


void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.AddWifi();//Setup Wifi
ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature

// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = 0;
ReefAngel.FeedingModePortsE[0] = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = 0;
ReefAngel.WaterChangePortsE[0] = 0;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = 0;
ReefAngel.LightsOnPortsE[0] = 0;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = 0;
ReefAngel.OverheatShutoffPortsE[0] = 0;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Set the Overheat temperature setting
InternalMemory.OverheatTemp_write( 300 );


// Ports that are always on
ReefAngel.Relay.On( Port1 ); //skimmer
ReefAngel.Relay.On( Port3 ); //MP40
ReefAngel.Relay.On( Port4 ); //Cabinet Light
ReefAngel.Relay.On( Port5 ); //WP40 Right
ReefAngel.Relay.On( Port6 ); //BM Doser
ReefAngel.Relay.On( Port7 ); // DC10000
ReefAngel.Relay.On( Port8 ); // Always On
ReefAngel.Relay.On( Box1_Port2 ); //WP40 Left
ReefAngel.Relay.On( Box1_Port5 ); //LED
ReefAngel.Relay.On( Box1_Port6 ); //Salt Mix Pump
ReefAngel.Relay.On( Box1_Port7 ); //Always On PWM
ReefAngel.Relay.On( Box1_Port8 ); //LED


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


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

void loop()
{
ReefAngel.DosingPumpRepeat( Port2,0,60,35 );
ReefAngel.StandardLights( Box1_Port1,14,0,23,0 );
ReefAngel.RF.UseMemory = true;
ReefAngel.RF.SetMode( NutrientTransport,30,10 );
ReefAngel.PWM.SetChannel(0,100); // Sets channel 0 to 100%
ReefAngel.PWM.SetChannel( 1, NutrientTransportMode(77,90,3000,true) ); // Nutrient Transport on sync mode
ReefAngel.PWM.SetChannel( 2, NutrientTransportMode(77,90,3000,false) ); // Nutrient Transport on anti-sync mode
ReefAngel.PWM.SetChannel( 3, PWMParabola(15,0,23,0,0,30,0) ); // (White)Set channel 3 to start 3pm at 10% to top 30% then end at 8pm at 10%
ReefAngel.PWM.SetChannel( 4, PWMParabola(10,0,23,59,0,40,0) ); // (Blue)
ReefAngel.PWM.SetChannel( 5, PWMParabola(15,0,23,0,0,20,0) ); // (Red)
//ReefAngel.PWM.SetDaylight( TidalSwellMode(80,true) ); // Tidal Swell at 40% on sync mode
//ReefAngel.PWM.SetActinic( TidalSwellMode(80,false) ); // Tidal Swell at 40% on anti-sync mode
//ReefAngel.PWM.SetDaylight( LongPulseMode(50,80,20,true)); // long pulse minimum power at 50% max at 80 lasting for 20 sec Sync
//ReefAngel.PWM.SetActinic( LongPulseMode(50,80,20,false)); // long pulse minimum power at 50% max at 80 lasting for 20 sec AntiSync
//ReefAngel.PWM.SetDaylight( ReefCrestMode(80,40,true) ); // ReefCrest at 80%max +-40% on sync mode
//ReefAngel.PWM.SetActinic( ReefCrestMode(80,40,false) ); // ReefCrest at 80%max +-40% on anti sync

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


if (ReefAngel.WaterLevel.GetLevel()>=80) //Turn off skimmer if waterlevel exceed 80%
{
ReefAngel.Relay.Off(Port1);
}
else
{
ReefAngel.Relay.On(Port1);
}

if (ReefAngel.DisplayedMenu==FEEDING_MODE)
{
ReefAngel.RF.UseMemory=false;
ReefAngel.RF.SetMode(Constant,0,0);
ReefAngel.PWM.SetChannel(1,30);
ReefAngel.PWM.SetChannel(2,30);
ReefAngel.PWM.SetChannel(0,75);

}
else
{
ReefAngel.Relay.On( Port3 );
ReefAngel.Relay.On( Box1_Port8 );
}

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

// This should always be the last line
ReefAngel.Portal( "Amos%20Poh" );
ReefAngel.ShowInterface();
}

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

// Salinity
ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,15,46, "SAL:" );
ReefAngel.LCD.DrawText( COLOR_DARKKHAKI,DefaultBGColor,39,46, ReefAngel.Params.Salinity );
pingSerial();

// Water Level
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,75,63, "WL:" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,99,63, ReefAngel.WaterLevel.GetLevel() );
pingSerial();

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

// Relay Expansion
TempRelay = ReefAngel.Relay.RelayDataE[0];
TempRelay &= ReefAngel.Relay.RelayMaskOffE[0];
TempRelay |= ReefAngel.Relay.RelayMaskOnE[0];
ReefAngel.LCD.DrawOutletBox( 12, 98, TempRelay );
pingSerial();

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

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

Re: Question on LED dimming

Post by rimai »

Curt is working on something:
http://forum.reefangel.com/viewtopic.php?p=31968#p31968
Make sure you follow that thread.
Roberto.
Post Reply