Go Down

Topic: Led Dimming help.. (editing the program) (Read 954 times) previous topic - next topic

sounduser


Hiya. i hope someone can help me.

Ive brought this led controller to dimmer 2 sets of leds on 2 x ELN6048 meanwells.

http://www.boostled.com/products/typhon-led-controller-kit

The problem that im having is that the leds flash when the they're at 10%. (9% no light, 10% they flash and 11% is fine)So i was wondering if there is a way to edit the program so they start up and turn off at around 15%. (instead of starting at 0%)

Code:
http://www.boostled.com/pages/typhon-pre-programmed-sketch


Any help would be amazing.

Thank you

Jimmy

madworm

You need to load a library. I think it's called "brain.h" or similar.

Seriously... locate where the brightness is dealt with and play with it. We don't spoon-feed here.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

sounduser


You need to load a library. I think it's called "brain.h" or similar.

Seriously... locate where the brightness is dealt with and play with it. We don't spoon-feed here.


If i connect the usb and download the Arduino Software from this site. will i be able to download the software from the board? so i can attempt to edit it?

Grumpy_Mike

No, you download the file into your computer. You then edit it and upload it to your board.

sounduser

could someone have a look at the code and point me in the right direction?  :smiley-red:

Grumpy_Mike

Well how about posting the code you are trying to change (use the # icon). That link was to lots of functions so we have no idea what bits you are using.


sounduser

Thats the problem :D

It goes up from 0 to 100 for sunrise. stays at 100% all day. then 100% to 0 for sunset. The problem is that the leds are flashing at 10%
so i want to have it go

off.. 15% to 100%, 100% all day then 100% to 15% then off.

Is this going to be too hard for me? Some of it makes sense but i dont know what im looking for as i dont know what bits of code control the pwm percentages.


sounduser

How can i add an led min like the led max? so it could be zero is off. min = ?? and max =100?


Code: [Select]
int   setLed(int mins,         // current time in minutes
            int ledPin,        // pin for this channel of LEDs
            int start,         // start time for this channel of LEDs
            int period,        // photoperiod for this channel of LEDs
            int fade,          // fade duration for this channel of LEDs
            int ledMax,        // max value for this channel
            boolean inverted   // true if the channel is inverted
            )  {
  int val = 0;
     
      //fade up
      if (mins > start || mins <= start + fade)  {
        val = map(mins - start, 0, fade, 0, ledMax);
      }
      //fade down
      if (mins > start + period - fade && mins <= start + period)  {
        val = map(mins - (start + period - fade), 0, fade, ledMax, 0);
      }
      //off or post-midnight run.
      if (mins <= start || mins > start + period)  {
        if((start+period)%1440 < start && (start + period)%1440 > mins )
          {
            val=map((start+period-mins)%1440,0,fade,0,ledMax);
          }
        else 
        val = 0;
      }
   
   
    if (val > ledMax)  {val = ledMax;}
    if (val < 0) {val = 0; }
   
  if (inverted) {analogWrite(ledPin, map(val, 0, 100, 255, 0));}
  else {analogWrite(ledPin, map(val, 0, 100, 0, 255));}
  if(override){val=overpercent;}
  return val;

Grumpy_Mike

Quote
How can i add an led min like the led max?

Like this:-
Code: [Select]
if (val < ledMin)  {val = ledMin;}

sounduser

How would i set the value of minimum?

These are the parts that have the max value. would i just add minimum too?

Code: [Select]
// Variables making use of EEPROM memory:
EEPROMVar<int> oneStartMins = 750;     // minute to start this channel.
EEPROMVar<int> onePhotoPeriod = 720;   // photoperiod in minutes for this channel.
EEPROMVar<int> oneMax = 100;           // max intensity for this channel, as a percentage
EEPROMVar<int> oneFadeDuration = 60;   // duration of the fade on and off for sunrise and sunset for
                                       //    this channel.
EEPROMVar<int> twoStartMins = 810;
EEPROMVar<int> twoPhotoPeriod = 600;
EEPROMVar<int> twoMax = 100;
EEPROMVar<int> twoFadeDuration = 60;



Code: [Select]
int oneStartMins = 1380;      // minute to start this channel.
int onePhotoPeriod = 120;   // photoperiod in minutes for this channel.
int oneMax = 100;           // max intensity for this channel, as a percentage
int oneFadeDuration = 60;   // duration of the fade on and off for sunrise and sunset for
                                       //    this channel.                                   
int twoStartMins = 800;
int twoPhotoPeriod = 60;
int twoMax = 100;
int twoFadeDuration = 15;



Code: [Select]
/****** LED Functions ******/
/***************************/
//function to set LED brightness according to time of day
//function has three equal phases - ramp up, hold, and ramp down

int   setLed(int mins,    // current time in minutes
            int ledPin,  // pin for this channel of LEDs
            int start,   // start time for this channel of LEDs
            int period,  // photoperiod for this channel of LEDs
            int fade,    // fade duration for this channel of LEDs
            int ledMax   // max value for this channel
            )  {
  int val = 0;
     
      //fade up
      if (mins > start || mins <= start + fade)  {
        val = map(mins - start, 0, fade, 0, ledMax);
      }
      //fade down
      if (mins > start + period - fade && mins <= start + period)  {
        val = map(mins - (start + period - fade), 0, fade, ledMax, 0);
      }
      //off or post-midnight run.
      if (mins <= start || mins > start + period)  {
        if((start+period)%1440 < start && (start + period)%1440 > mins )
          {
            val=map((start+period-mins)%1440,0,fade,0,ledMax);
          }
        else 
        val = 0;
      }
   
   
    if (val > ledMax)  {val = ledMax;}
    if (val < 0) {val = 0; }
   
  analogWrite(ledPin, map(val, 0, 100, 0, 255));
  if(override){val=overpercent;}
  return val;
}



Code: [Select]
void setup() {
 
  // Initialize channel variables. Set LED channel pin and retrieve values from EEPROM
  channel[0].Led = 9;
  channel[0].StartMins = oneStartMins;
  channel[0].PhotoPeriod = onePhotoPeriod;
  channel[0].Max = oneMax;
  channel[0].FadeDuration = oneFadeDuration;

  channel[1].Led = 10;
  channel[1].StartMins = twoStartMins;
  channel[1].PhotoPeriod = twoPhotoPeriod;
  channel[1].Max = twoMax;
  channel[1].FadeDuration = twoFadeDuration;






Grumpy_Mike

Quote
How would i set the value of minimum?

Oh come on!!!!
Do please put a tiny bit of effort into trying to understand what we are telling you, define it as a global variable:-
Code: [Select]
int ledMin = 23; // or what ever value you want

macegr

In OP's defense, they did try to buy a sort of canned solution, and didn't ask to learn microcontroller programming to get their lights working. I'd suggest contacting the manufacturer directly if there's some kind of problem with the system, though.
Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Go Up