Pages: [1]   Go Down
Author Topic: Led Dimming help.. (editing the program)  (Read 814 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

"The old Europe"
Offline Offline
Edison Member
*
Karma: 1
Posts: 2005
Bootloaders suck!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

• 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!

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33415
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33415
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats the problem smiley-grin

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.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Code:
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;
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33415
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
How can i add an led min like the led max?
Like this:-
Code:
if (val < ledMin)  {val = ledMin;}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How would i set the value of minimum?

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

Code:
// 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:
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:
/****** 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:
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;




Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 603
Posts: 33415
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int ledMin = 23; // or what ever value you want
Logged

SF Bay Area
Offline Offline
Edison Member
*
Karma: 11
Posts: 1244
Arduino Ninja
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Unique RGB LED Modules and Arduino shields: http://www.macetech.com/store

Pages: [1]   Go Up
Jump to: