Code: Select all
ReefAngel.PWM.SetChannelRaw(0, PMSmoothRampHighRes(13, 00, 22, 0, 2129, 120, 0));
Code: Select all
ReefAngel.PWM.SetChannelRaw(0, PMSmoothRampHighRes(13, 00, 22, 0, 2129, 120, 0));
Code: Select all
ReefAngel.PWM.SetChannelRaw(0, PWMSmoothRampHighRes(13, 00, 22, 00, 0, 52, 120, 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 <ReefAngel.h>
////// DON'T USE MEMORY LOCATION 199 - IT IS CORRUPT!
////// Place global variable code below here
#define Mem_B_LedOverride 100
#define Mem_B_Led100Percent 101
/////// Regular slope End%
#define Mem_B_SlopeEndCh0 259
#define Mem_B_SlopeEndCh1 262
#define Mem_B_SlopeEndCh2 265
#define Mem_B_SlopeEndCh3 268
////// Place global variable code above here
void setup()
{
// This must be the first line
ReefAngel.Init(); //Initialize controller
ReefAngel.SetTemperatureUnit( Celsius ); // set to Celsius Temperature
ReefAngel.Use2014Screen(); // Let's use 2014 Screen
// Ports toggled in Feeding Mode
ReefAngel.FeedingModePorts = Port3Bit | Port5Bit | Port6Bit | Port8Bit;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port3Bit | Port5Bit | Port6Bit | Port7Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port4Bit;
ReefAngel.LightsOnPortsE[0] = Port1Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port7Bit;
// Use T1 probe as temperature and overheat functions
ReefAngel.TempProbe = T1_PROBE;
ReefAngel.OverheatProbe = T1_PROBE;
// Ports that are always on
ReefAngel.Relay.On( Port6 );
ReefAngel.Relay.On( Port8 );
ReefAngel.Relay.On( Box1_Port8 );
////// Place additional initialization code below here
InternalMemory.write(Mem_B_LedOverride, 0); //sets the controller to non masked LED mode upon boot.
InternalMemory.write(Mem_B_Led100Percent, 0);
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.ActinicLights( Port2 );
ReefAngel.ActinicLights( Port4 );
//ReefAngel.SingleATO( true,Port5,10,1 ); <----------------------------Untested Change---------------See ATO Delay
ReefAngel.StandardHeater( Port7 );
////// Place your custom code below here
////// Delay ATO after Waterchange or Feeding Mode<---------------------------------------------UNTESTED!
static time_t wcTimer;
if ((ReefAngel.DisplayedMenu == FEEDING_MODE) || (ReefAngel.DisplayedMenu == WATERCHANGE_MODE)) wcTimer=now();
if (now()-wcTimer > 0 && now()-wcTimer < 600)
{
ReefAngel.Relay.Off(Port5);
}
else if (bitRead(ReefAngel.Relay.RelayMaskOnE[0],2))
{
ReefAngel.Relay.Off(Port5);
}
else
{
ReefAngel.SingleATO( true,Port5,10,1 );
}
////// Clear Overheat Flag after feeding or waterchange mode
if (now()-wcTimer == 600)
{
if (ReefAngel.isOverheat())
{
if (ReefAngel.Params.Temp[T1_PROBE] <= 266)
{
ReefAngel.OverheatClear();
}
}
}
////// Turn On LED Fan & PSU whenever any LEDs are on
if (ReefAngel.PWM.GetChannelValue(0) > 0 || ReefAngel.PWM.GetChannelValue(1) > 0 || ReefAngel.PWM.GetChannelValue(2) > 0 || ReefAngel.PWM.GetChannelValue(3) > 0){
ReefAngel.Relay.On(Port2);
ReefAngel.Relay.On(Port4);
}
////// ---------------Override PWM Light Channels--------------------
// Custom Memory Location To Store Overide State for Regular Light End Values
if (bitRead(ReefAngel.Relay.RelayMaskOnE[0],0)) {
if (InternalMemory.read(Mem_B_LedOverride)!=1){
InternalMemory.write(Mem_B_LedOverride, 1);
}
}
else if (InternalMemory.read(Mem_B_LedOverride)!=0){
InternalMemory.write(Mem_B_LedOverride, 0);
}
// Custom Memory Location To Store Overide State for 100% Light values
if (bitRead(ReefAngel.Relay.RelayMaskOnE[0],1)) {
if (InternalMemory.read(Mem_B_Led100Percent)!=1){
InternalMemory.write(Mem_B_Led100Percent, 1);
}
}
else if (InternalMemory.read(Mem_B_Led100Percent)!=0){
InternalMemory.write(Mem_B_Led100Percent, 0);
}
// Removes LED's from a Overridden State
if ( InternalMemory.read(Mem_B_LedOverride) == 0){
if (InternalMemory.read(Mem_B_Led100Percent) == 0)
{
/*
////////PWMSlopeHighRes Working
ReefAngel.PWM.SetChannelRaw( 0, PWMSlopeHighRes(13,00,22,00,0,28,120,0)); //Set Channel 0 to PWMSlope using internal memory settings for Channel 0
ReefAngel.PWM.SetChannelRaw( 1, PWMSlopeHighRes(13,00,22,00,0,23,120,0)); //Set Channel 1 to PWMSlope using internal memory settings for Channel 1
ReefAngel.PWM.SetChannelRaw( 2, PWMSlopeHighRes(13,00,22,00,0,28,120,0)); //Set Channel 2 to PWMSlope using internal memory settings for Channel 2
ReefAngel.PWM.SetChannelRaw( 3, PWMSlopeHighRes(13,00,22,00,0,32,120,0)); //Set Channel 3 to PWMSlope using internal memory settings for Channel 3
*/
ReefAngel.PWM.SetChannelRaw( 0, PWMSmoothRampHighRes(13,00,22,00,0,28,120,0)); //Set Channel 0 to PWMSlope using internal memory settings for Channel 0
ReefAngel.PWM.SetChannelRaw( 1, PWMSmoothRampHighRes(13,00,22,00,0,23,120,0)); //Set Channel 1 to PWMSlope using internal memory settings for Channel 1
ReefAngel.PWM.SetChannelRaw( 2, PWMSmoothRampHighRes(13,00,22,00,0,28,120,0)); //Set Channel 2 to PWMSlope using internal memory settings for Channel 2
ReefAngel.PWM.SetChannelRaw( 3, PWMSmoothRampHighRes(13,00,22,00,0,32,120,0)); //Set Channel 3 to PWMSlope using internal memory settings for Channel 3
}
}
// Override LED's to End% Intensity for each Channel
if (( InternalMemory.read(Mem_B_LedOverride) == 1) && (Mem_B_Led100Percent == 0 ))
{
ReefAngel.PWM.SetChannel( 0, Mem_B_SlopeEndCh0 ); //Set channel 0 to channel 0 end%
ReefAngel.PWM.SetChannel( 1, Mem_B_SlopeEndCh1 ); //Set channel 1 to channel 1 end%
ReefAngel.PWM.SetChannel( 2, Mem_B_SlopeEndCh2 ); //Set channel 2 to channel 2 end%
ReefAngel.PWM.SetChannel( 3, Mem_B_SlopeEndCh3 ); //Set channel 3 to channel 3 end%
}
// Override LED's to 100% Intensity for each Channel
if (Mem_B_Led100Percent == 1 )
{
ReefAngel.PWM.SetChannel( 0, 100 ); //Set channel 0 to channel 0 100%
ReefAngel.PWM.SetChannel( 1, 100 ); //Set channel 1 to channel 1 100%
ReefAngel.PWM.SetChannel( 2, 100 ); //Set channel 2 to channel 2 100%
ReefAngel.PWM.SetChannel( 3, 100 ); //Set channel 3 to channel 3 100%
}
////// Prevent Filling ATO past float switch even if overridden
if (bitRead(ReefAngel.Relay.RelayMaskOn,4)){
if (!ReefAngel.LowATO.IsActive()){
ReefAngel.Relay.Off(Port5);
bitClear(ReefAngel.Relay.RelayMaskOn,4);
}
}
////// Override Float Switch for Waterchange Drum
if (bitRead(ReefAngel.Relay.RelayMaskOnE[0],3)) {
ReefAngel.Relay.On(Port1);
}
else {
ReefAngel.Relay.Off(Port1);
}
/////// Refill (Salt Water) after water change to ATO height Relay Port 1
if (ReefAngel.DisplayedMenu != WATERCHANGE_MODE){
if (bitRead(ReefAngel.Relay.RelayMaskOn,0)){
if (!ReefAngel.LowATO.IsActive()){
ReefAngel.Relay.Off(Port1);
bitClear(ReefAngel.Relay.RelayMaskOn,0);
}
}
}
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "tanked_kiwi" );
ReefAngel.ShowInterface();
Colin, what code were you using on the PWMSmoothRampHighRes calls? Can you post up a snippet? I have a unit that I can run tests on and would like to try to see what's going on with it.cosmith71 wrote:So I've had this running for several days. It's unpredictable. Some days the whites would dim really fast at the end of the cycle. Last night they were at about half brightness near the end and then instantly 0. Not sure why.
I'm going back to PWMSlopeHighRes instead.
--Colin
Code: Select all
ReefAngel.PWM.SetChannelRaw(0,PWMSmoothRampHighRes(9,30,22,30,0,70,60,0));
Actually, it's intended to be flat in the middle with a half-period of a Cosine function at the beginning and the end which is shifted up and divided by 2 so that it goes from 0 to 1 instead of from -1 to 1. The intent is to have a tail at the beginning of the day and the end of the day rather than an immediate slope upwards in the morning.cosmith71 wrote:Yup.
What shape is SmoothRamp? Is it a parabolic beginning and end?
Code: Select all
ReefAngel.PWM.SIXTEENChannelPWMSigmoid(2,0,InternalMemory.PWMSlopeEnd0_read()); // RB channel, startpwm, endpwm, offsets
Code: Select all
// Cloud/lightning lighting control
FireInTheHole=false;
ReefAngel.PWM.SetChannelRaw(0,PWMSmoothRampHighRes(9,30,22,30,0,InternalMemory.read(Mem_B_SlopeEndBlue),60,0));
DaylightPWMValue=PWMSmoothRampHighRes(10,30,22,0,0,InternalMemory.read(Mem_B_SlopeEndWhite),60,0);
//if (!powerOutage) CheckCloud();
if (!FireInTheHole) ReefAngel.PWM.SetChannelRaw(1,DaylightPWMValue);
Code: Select all
ReefAngel.PWM.SetChannelRaw(0,PWMSmoothRampHighRes(9,30,22,30,0,70,60,0));
ReefAngel.PWM.SetChannelRaw(1,PWMSmoothRampHighRes(10,30,22,0,0,75,60,0));