I finally finished my new lighting yesterday and got it all set up. Channel 0 is moonlighting and channels 1,2 and 3 are royal blue, violet/blue/cyan and white. Everything ran well all day, the levels went up and down as they should all day. The glitch came when I checked on it after the lights should have been out, channel 3 was still at 1% instead of 0. My moonlight is already on the bright side, adding 10 white LEDs, even at just 1%, made it more dusk than night.
I double checked, the 3 channels are all set to "start" at 0 and peak at 35 to 55 (varies by channel). Why didn't this channel shut down and how do I fix it?
While I'm asking questions about this expansion, is therer a way to use the moonlight program but reduce the brightness? I won't know for certain untill I get the white channel sorted but I suspect that 4 3w LEDs at 150mA will be a little bright, is there a command for "moonlight=PWM level/2."
Why didn't PWM dimming go to zero?
Re: Why didn't PWM dimming go to zero?
It's been a while, I hope this works correctly...
Created with the wizard.
Created with the wizard.
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 <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 = 0;
// Ports toggled in Water Change Mode
ReefAngel.WaterChangePorts = Port1Bit | Port6Bit | Port8Bit;
// Ports toggled when Lights On / Off menu entry selected
ReefAngel.LightsOnPorts = Port2Bit | Port3Bit | Port4Bit | Port5Bit;
// Ports turned off when Overheat temperature exceeded
ReefAngel.OverheatShutoffPorts = Port8Bit;
// 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( Port7 );
////// Place additional initialization code below here
////// Place additional initialization code above here
}
void loop()
{
ReefAngel.SingleATOLow( Port1 );
ReefAngel.MoonLights( Port2 );
ReefAngel.ActinicLights( Port3 );
ReefAngel.DayLights( Port4 );
ReefAngel.MoonLights( Port5 );
ReefAngel.StandardHeater( Port8 );
ReefAngel.PWM.DaylightPWMParabola();
ReefAngel.PWM.ActinicPWMParabola();
ReefAngel.PWM.SetChannel( 0, MoonPhase() );
ReefAngel.PWM.Channel1PWMParabola();
ReefAngel.PWM.Channel2PWMParabola();
ReefAngel.PWM.Channel3PWMParabola();
////// Place your custom code below here
////// Place your custom code above here
// This should always be the last line
ReefAngel.Portal( "dadriance" );
ReefAngel.ShowInterface();
}
void DrawCustomMain()
{
int x,y;
char text[10];
// Dimming Expansion
x = 15;
y = 2;
for ( int a=0;a<6;a++ )
{
if ( a>2 ) x = 75;
if ( a==3 ) y = 2;
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x,y,"Ch :" );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+12,y,a );
ReefAngel.LCD.DrawText( COLOR_DARKGOLDENROD,DefaultBGColor,x+24,y,ReefAngel.PWM.GetChannelValue(a) );
y += 10;
}
pingSerial();
// Parameters
#if defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, ReefAngel.Params,
ReefAngel.PWM.GetDaylightValue(), ReefAngel.PWM.GetActinicValue() );
#else // defined DisplayLEDPWM && ! defined RemoveAllLights
ReefAngel.LCD.DrawMonitor( 15, 43, 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, 84, TempRelay );
pingSerial();
// Date and Time
ReefAngel.LCD.DrawDate( 6, 122 );
pingSerial();
}
void DrawCustomGraph()
{
}
Re: Why didn't PWM dimming go to zero?
I wonder if the parabola is not going to zero because of the floating point math calculations.
Let's try this.... Change this:
With this:
Let's try this.... Change this:
Code: Select all
ReefAngel.PWM.Channel3PWMParabola();
Code: Select all
ReefAngel.PWM.SetChannel( 3, PWMParabola(
InternalMemory.StdLightsOnHour_read(),
InternalMemory.StdLightsOnMinute_read(),
InternalMemory.StdLightsOffHour_read(),
InternalMemory.StdLightsOffMinute_read(),
InternalMemory.PWMSlopeStart3_read(),
InternalMemory.PWMSlopeEnd3_read(),
0));
Roberto.
Re: Why didn't PWM dimming go to zero?
Thanks Roberto! I'll give that a try after lunch and see how it goes tonight.
I did find that I have another anomoly that is probably related. As I was reading the code you posted, my white lights suddenly dimmed, it had seemed brighter than expected until then but I thought it was because I had lowered the fixture. after a little troubleshooting I noticed that the display showed my white channel at "102." This channel is set to start at 0 and go up to 55, 102 couldnt be right and it's way too dim to be at >100%. I increased the max to 60 and the lights instantly came on again, the portal dropped from 106 (by then) to 21 so I think it's working correctly again but the control display has continued to climb, it seems to be displaying the correct reading but with the extra "tenths" digit showing. Currently it's up to 306, i'm sure the portal will show 30 when I go there after posting.
Any thoughts?
Should I also mention that I've been getting "Error 23: XML SAX Parser" almost all the time from the Android app for the last day or so. Related?
Edit; Yup, channel 3 is reading 314 on the display and 31 on the portal. Channels 0,1 and 2 are reading normally.
Edit 2; I've modified the code and the controler is now reading "34" for channel 3.
I did find that I have another anomoly that is probably related. As I was reading the code you posted, my white lights suddenly dimmed, it had seemed brighter than expected until then but I thought it was because I had lowered the fixture. after a little troubleshooting I noticed that the display showed my white channel at "102." This channel is set to start at 0 and go up to 55, 102 couldnt be right and it's way too dim to be at >100%. I increased the max to 60 and the lights instantly came on again, the portal dropped from 106 (by then) to 21 so I think it's working correctly again but the control display has continued to climb, it seems to be displaying the correct reading but with the extra "tenths" digit showing. Currently it's up to 306, i'm sure the portal will show 30 when I go there after posting.
Any thoughts?
Should I also mention that I've been getting "Error 23: XML SAX Parser" almost all the time from the Android app for the last day or so. Related?
Edit; Yup, channel 3 is reading 314 on the display and 31 on the portal. Channels 0,1 and 2 are reading normally.
Edit 2; I've modified the code and the controler is now reading "34" for channel 3.
Re: Why didn't PWM dimming go to zero?
My whites shut off correctly last night. Thanks again for the help.
Re: Why didn't PWM dimming go to zero?
Here we go again...
My white channel is still fine, but for t last few nights my other 2 channels have stayed at 1%. Obviously I could add the same code for those 2 channels (if I have enough memory) but I was wondering if there were something I could put in place to take care of all channels at once, instead of adding code for each channel.
My white channel is still fine, but for t last few nights my other 2 channels have stayed at 1%. Obviously I could add the same code for those 2 channels (if I have enough memory) but I was wondering if there were something I could put in place to take care of all channels at once, instead of adding code for each channel.
Re: Why didn't PWM dimming go to zero?
I don't think the code increases.
The short version Channel3PWMParabola is just the same as the bigger version except the latter is forcing the channels to go to zero instead of the parabola calculation.
I think the last 1% is rounding off from the mcu we use can't really do floating point math calculations and it just rounds off to the wrong value.
If you want to force to zero, you would need to hard code that last zero value on the bigger version.
The short version Channel3PWMParabola is just the same as the bigger version except the latter is forcing the channels to go to zero instead of the parabola calculation.
I think the last 1% is rounding off from the mcu we use can't really do floating point math calculations and it just rounds off to the wrong value.
If you want to force to zero, you would need to hard code that last zero value on the bigger version.
Roberto.