Here it is, no more having to adjust your photo period to acclimate corals if you have dimmable LED drivers.
This code is setup currently for PWM signal. I am using 3 channels because I couldn't get both my Blue driver wires into the same channel.
This code can be easily edited to add additional channels for drivers running different colors White/Blue or if you have split your colors up into more drivers... Cool White/Warm White/Royal Blue/Cool Blue/UV/Red/Green etc...
To view and write the hard coded values for the locations defined in the global variables use the following wifi commands in your web browser
http://IPAddressOfYourWifiAttachment:2000/mbx
- read memory location (byte size) where
x=memory location
Example to read the value of Mem_B_AcclDuration:
http://192.168.0.60:2000/mb101
http://IPAddressOfYourWifiAttachment:2000/mbx,y
- write memory location (byte size) where
x=memory location
y=value to be written
Example to set the value for Mem_B_AcclDuration so you have a 30 day acclimation cycle:
http://192.168.0.60:2000/mb101,30
You will need to set ALL OF the global variable values below to what ever you want by using the wifi commands above.
////// Place global variable code below here
Code: Select all
////// Memory Locations used by all formulas
#define Mem_B_AcclDay 100
// Note - 100 represents the hard coded Memory location used for this variable
// not the value for the variable.
// This variable represents the current day in Acclimation Cycle. Set this value to the same
// number of days as your AcclDuration to begin the acclimation cycle or set it to 0 to use
// your normal dimming end% values.
#define Mem_B_AcclDuration 101
// Set this value to how many days you want your acclimation cycle to take.
#define Mem_B_SlopeStart 102
// Set this to your desired starting acclimation end%.
/////// Memory Locations used by Blue Formula
#define Mem_B_AcclStartEndBlue 105 // Acclimation starting Slope end%
#define Mem_B_SlopeEndBlue 106 // slope End%
////// Memory Locations used by White Formula
#define Mem_B_AcclStartEndWhite 110 // Acclimation starting Slope end%
#define Mem_B_SlopeEndWhite 111 // Slope End%
////// Place your custom code below here
Code: Select all
/////// LED Dimming Acclimation Cycle and your standard LED schedule
////////// Variables used for all channels
byte acclDay = InternalMemory.read(Mem_B_AcclDay);
// What day in the acclimation cycle it is
byte acclDuration = InternalMemory.read(Mem_B_AcclDuration);
// Acclimation Duration in days
byte startPercent = InternalMemory.read(Mem_B_SlopeStart);
// Normal start% being used by all 3 channels
////////// Blue Channel Variables
byte acclStartEndBlue = InternalMemory.read(Mem_B_AcclStartEndBlue);
// Starting End% for Acclimation cycle
float acclendPercentBlue = InternalMemory.read(Mem_B_SlopeEndBlue);
// Your target Blue end% once acclimation is complete
////////// Blue Channel Formula
float acclPercentPerDayBlue = (acclendPercentBlue - acclStartEndBlue) / acclDuration;
// How much your Blue end% rises per acclimation day
float acclFactorBlue = acclDay * acclPercentPerDayBlue;
// endPercentBlue will be offset by this much. If acclDay = 0 then this value will be 0
byte endPercentBlue = acclendPercentBlue - acclFactorBlue;
// Your final Blue end% for the day
////////// White Channel Variables
byte acclStartEndWhite = InternalMemory.read(Mem_B_AcclStartEndWhite);
// Starting End% for Acclimation cycle
float acclEndPercentWhite = InternalMemory.read(Mem_B_SlopeEndWhite);
// Your target White end% once acclimation is complete
////////// White Channel Formula
float acclPercentPerDayWhite= (acclEndPercentWhite - acclStartEndWhite) / acclDuration;
// How much your White end% rises per acclimation day
float acclFactorWhite = acclDay * acclPercentPerDayWhite;
// endPercentWhite will be offset by this much. If acclDay = 0 then this value will be 0
byte endPercentWhite = acclEndPercentWhite - acclFactorWhite;
// Your standard PWM Dimming code using the variables above to determine start% and end%
ReefAngel.PWM.SetChannel( 0, PWMSlope(13,0,21,0,startPercent,endPercentWhite,90,20) );
ReefAngel.PWM.SetChannel( 1, PWMSlope(12,0,22,0,startPercent,endPercentBlue,90,20) );
ReefAngel.PWM.SetChannel( 2, PWMSlope(12,0,22,0,startPercent,endPercentBlue,90,20) );
// At the end of the day, we need to decrement the acclimation counter.
static boolean acclCounterReady=false; // We need a boolean so we only do this once per day
if (now()%SECS_PER_DAY!=0) acclCounterReady=true; // If it's not midnight we'll get the boolean ready
if (now()%SECS_PER_DAY==0 && acclCounterReady && acclDay>0) { // It's midnight, our bool is true and acclDay is more than 0
acclDay--; // Reduce the counter
acclCounterReady=false; // Reset the boolean flag
InternalMemory.write(Mem_B_AcclDay,acclDay); // Update memory
}