LED Flicker

Share you PDE file with our community
Post Reply
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

LED Flicker

Post by dpitalo »

I came home today after updating libraries last night and the LED's weren't acting quite right. They were much dimmer than they should have been. I double checked my code and noticed that the slope function had changed a little bit. I'm not sure what the proper syntax is for the PWM Expansion module now. Everything is compiling fine, but the LED's that are on the expansion have a slight flicker that they didn't have before the update. What do I need to change to make it stop?

Here's the PDE. (NOTE: there are a few things commented out right now as I work my way through the coding)

Code: Select all

#include <Salinity.h>
#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 <RF.h>
#include <IO.h>
#include <ORP.h>
#include <AI.h>
#include <ReefAngel.h>

/*
Ports assignment:

Port1 - Standard ATO 
Port2 - Skimmer
Port3 - Always On
Port4 - Heater 
Port5 - Wavemaker 1
Port6 - Wavemaker 2
Port7 - SeaSwirl
Port8 - Return
*/

#define PWMRB1            0
#define PWMRB2            1
#define PWMRB3            2
#define PWMWT1            3
#define PWMWT2            4
#define PWMHN             5


byte PWMChannel[]={
  0,0,0,0,0,0};

void setup()
{
  ReefAngel.Init(); 
  ReefAngel.FeedingModePorts = Port2Bit | Port5Bit | Port6Bit | Port8Bit; // Turn off Port6 and Port8 when feeding mode is activated
  ReefAngel.WaterChangePorts = Port2Bit | Port4Bit | Port8Bit; // Turn off Port5, Port6, Port7 and Port8 when water change mode is activated
  ReefAngel.Relay.On(Port2); // Turn on Skimmer
  ReefAngel.Relay.On(Port3); // Turn on Always On port
  ReefAngel.Relay.On(Port7); // Turn on SeaSwirl
  ReefAngel.Relay.On(Port8); // Turn on return
}

void loop()
{
  ReefAngel.StandardATO(Port1, 60); // ATO with 60 seconds timeout
  ReefAngel.StandardHeater(Port4,770,780); //Standard heater comes on at 77 degrees and off at 78 degrees
  ReefAngel.WavemakerRandom1(Port5,15,60);//Turn on/off Wavemaker 1 random cycles from 15 to 60 seconds
  ReefAngel.WavemakerRandom2(Port6,15,60);//Turn on/off Wavemaker 1 random cycles from 15 to 60 seconds
  //** Moonphase Code Start Here
    if (hour ()>=21 || hour ()<10)
    {
      ReefAngel.PWM.SetActinic(MoonPhase());
    }
    else
    {
      ReefAngel.PWM.SetActinic(0);
    }
  //** Moonphase Code Ends Here
  
  //** Daylight PWM Channel Code Starts Here
    if (hour()>=21 || hour()<12)
    {
      ReefAngel.PWM.SetDaylight(0);
    }
    else
    {
      ReefAngel.PWM.SetDaylight(PWMSlope(12,00,20,30,13,95,120,13));   //XP-G Cool Whites - Right Side
    }
    //** Daylight PWM Channel Code Ends Here
    
    //** PWM Expansion Module Code Starts Here
    
      PWMChannel[PWMRB2]=PWMSlope(9,30,21,20,10,95,60,PWMChannel[PWMRB2]);                          //Royal Blue - Left Bank
      //PWMChannel[PWMRB3]=PWMSlope(9,50,21,40,0,95,60,PWMChannel[PWMRB3]);                          //Royal Blue - Middle Bank
      //PWMChannel[PWMRB1]=PWMSlope(10,10,22,00,0,95,60,PWMChannel[PWMRB1]);                          //Royal Blue - Right Bank

      //PWMChannel[PWMWT2]=PWMSlope(11,00,21,00,0,95,80,PWMChannel[PWMWT2]);                          //XP-E Cool Whites - Left Side  
      //PWMChannel[PWMWT1]=PWMSlope(11,10,21,30,0,95,80,PWMChannel[PWMWT1]);                          //XP-E Cool Whites - Right Side

      //PWMChannel[PWMHN]=PWMSlope(12,00,20,00,0,95,120,PWMChannel[PWMHN]);                           //XP-G Cool Whites - Left Side
     
      for (int a=0;a<6;a++)
  {
    ReefAngel.PWM.Expansion(a,int(2.55*PWMChannel[a])); 
  }
    //** PWM Expansion Module Code Ends Here
  
  
  ReefAngel.ShowInterface(); //Draw the Standard Interface
  
}


Thanks!
Dave
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: LED Flicker

Post by rimai »

I don't think it has nothing to do with the update.
Your code looks fine.
I think the problem is the driver cutoff.
Maybe you can do the start % at 15% instead of 10%.

Code: Select all

PWMChannel[PWMRB2]=PWMSlope(9,30,21,20,15,95,60,PWMChannel[PWMRB2]); 
Roberto.
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

Re: LED Flicker

Post by dpitalo »

It's doing it throughout the slope function. More so at the higher values.

Any ideas why it would start now after running with a slope starting at 0% and going to 95% for the past couple of months. Right now it looks like a dance club in my living room.

The two channels coming off the relay box are fine. One is controller a moonlight and the other a channel for daylight LEDs.

Is there something I can do with the PWM expansion to test that it's working properly??

Thanks.
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

Re: LED Flicker

Post by dpitalo »

Just did a quick test of the PWM Expansion. If I reset the time on the controller, the LEDs go to what appears to be the proper value...flickering. Then if I change the time back to the current time (LED's should be off) nothing happens.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: LED Flicker

Post by rimai »

Ok, change this:

Code: Select all

    ReefAngel.PWM.Expansion(a,int(2.55*PWMChannel[a])); 
To this:

Code: Select all

    ReefAngel.PWM.SetChannel(a,PWMChannel[a]); 
Roberto.
dpitalo
Posts: 39
Joined: Mon Dec 12, 2011 6:45 pm

Re: LED Flicker

Post by dpitalo »

Ahhh, no more strobe lights in the living room. You, sir, get the award for best tech/customer support ever.

I'll let you know tomorrow how everything goes.

Thanks....yet again for solving my problems.

Dave
Post Reply