Pages: 1 ... 14 15 [16] 17 18 ... 20   Go Down
Author Topic: ShiftPWM support topic. Latest update: Schematics, high power LED's, LED strips  (Read 65602 times)
0 Members and 2 Guests are viewing this topic.
Kuala Lumpur, Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Absorbing knowledge! Will give it back :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot!
I think it's done.
I hope this code of mine will also be useful to others.
Or maybe someone would modify it to make it better.

Code:

fIn(1, 1000, 2000); //led1, trigger the fade in at 1st second (1000ms), for 2secs (2000ms)

fOut(1, 3000, 500); //led1, trigger the fade out at 3rd second (3000ms), for .5secs (500ms)

//it takes led1 2secs to get to maximum brightness, so the fade out trigger will start at the 3rd second.


void fIn(int ledN, int tStart, int period){
  //ledN - which LED?
  //tStart - start from when
  //period - for how long
  unsigned long elapsed=millis(); //timer
  int tEnd = tStart+period; //the end of the fading is after the period.
  int tEndX = tEnd+100; // give extra time to complete fading
  if(elapsed > tStart && elapsed <= tEndX){ //fade in for 'period'sec from tStart to tEndX.
    unsigned long h = tStart; // total time before trigger
    unsigned long p = tEnd-tStart; //fading period
    //or "unsigned long p = period;" will do.
    unsigned long eh = elapsed-h; //total time passed since triggered
    unsigned long j = maxBrightness*eh/p; //"eh/p" = time passed over fading period (percentage) then multiply by maxBrightness
    if (elapsed >= tEnd){
      j = maxBrightness;
    } //when ending, bring j to maximum brightness (to complete the fading) because millis(); is not perfect.
    ShiftPWM.SetOne(ledN ,j);
  }
}

void fOut(int ledN, int tStart, int period){
  unsigned long elapsed=millis();
  int tEnd = tStart+period;
  int tEndX = tEnd+100;
  if(elapsed > tStart && elapsed <= tEndX){
    unsigned long h = tStart;
    unsigned long p = tEnd-tStart;
    unsigned long eh = elapsed-h;
    unsigned long j = maxBrightness*eh/p;
    if (elapsed >= tEnd){
      j = maxBrightness;
    }
    unsigned long k = maxBrightness-j; // invert value of fade in to become fade out
    ShiftPWM.SetOne(ledN ,k);
  }
}



But this code will be quite different when it comes to RGB leds, right?
Is there a colour cross-fading (or morphing) effect in ShiftPWM for RGB leds?
-to change from blue to green smoothly.

Will my code work for RGB leds to simply set it's brightness without affecting it's current colour?
for example that led1 is set to keep on changing from green to blue then back to green, then with my code i just make its brightness dimmer without affecting the colour changing?
Or is there a function in SHiftPWM to do this?

 haven't any RGB led yet...
So, sorry if I might be asking this question for granted :/

Thank you very much smiley
Logged

Kuala Lumpur, Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Absorbing knowledge! Will give it back :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I need to shrink my project...
I'm using an Arduino Mega 2560 and it's size is too big for what I need.

I heard about the ATtiny :/

which ATtiny can I use for ShiftPWM?
What are the requirements for ShiftPWM to run

Or which other method do you recommend?

Can you also give me some tips on how to power many LEDs?
I know that you are selling powerful LED drivers but if it's in my budget and if it would be worth it to buy and works just fine for me, I would buy yours! smiley

More details:
My team will be performing something and we will be using LEDs.
Some effects to fade in and fade out, perhaps in some props we will need RGB leds.

I've bought  4 single coloured led strips, (600 leds in each strip - red, green, blue and white)
I've also bought 1 RGB led strip, 300 leds in that strip
I bought few EL wires of different colours (they need AC current)


The idea is to use the blue led strip one of the props, (just switch on)
one guy to use the red led strip and EL wire(use one ATtiny to run ShiftPWM? with shift registers?)
the other guy to use the green led strip or RGB led strip and EL wire (use one more ATtiny to run ShiftPWM? with shift registers again?)
one more prop will use about 5 leds, just fade in and fade out selected ones in a certain time (use one more ATtiny to run ShiftPWM? with shift registers again?)

So I need some recommendations how to power the LEDs...

I'm still a newbie specifically in this (circuitry) but not very newbie in stuffs like this (creating stuff).


Really grateful of any help that you can provide, I just need some tips to kick start what to do next...
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

is it possible to fade those Duo-LED with the shiftPWM Library (without the SPI)?

http://www.reichelt.de/DUO-LEDs-Blink-LEDs/LED-5-RG-3/3/index.html?;ACTION=3;LA=446;ARTICLE=6820;GROUPID=3022;artnr=LED+5+RG-3;SID=13Txfp1H8AAAIAAByzpaYc92665776fcaa200aa737138599d280f

-tsaG
Logged

Eindhoven
Offline Offline
Jr. Member
**
Karma: 1
Posts: 87
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a colour cross-fading (or morphing) effect in ShiftPWM for RGB leds?
-to change from blue to green smoothly.

Will my code work for RGB leds to simply set it's brightness without affecting it's current colour?
for example that led1 is set to keep on changing from green to blue then back to green, then with my code i just make its brightness dimmer without affecting the colour changing?
Or is there a function in SHiftPWM to do this?

There are functions to set HSV values. With the hue you can smoothly go from blue to green. With the value you can change the brightness.
Logged

Eindhoven
Offline Offline
Jr. Member
**
Karma: 1
Posts: 87
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

... stuff about shrinking and high power

I have not used ShiftPWM with an attiny. As far as I know there are no AtTiny arduino clones. The code uses some Arduino functions, so it will not be directly compatible. Maybe you could have a look at the teensy 2.0? www.prjc.com/teensy. It is really small and arduino compatible.

My high power led drivers are meant to drive high power, luxeon type, LED's without resistors. You are using LED strips, which have resistors on them. You are better off using transistors to switch them. I will design a transistor board for ShiftPWM, but it is not available now.
Logged

Eindhoven
Offline Offline
Jr. Member
**
Karma: 1
Posts: 87
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


They are basically two LED's in one case, so yes. They share a cathode or anode, but you would just tie that to ground/vcc and use PWM for the other pin.
Logged

Kuala Lumpur, Malaysia
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Absorbing knowledge! Will give it back :)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply smiley-grin

I bought some ULN2803 transistor that was intended for me to make RainBoard... but now still waiting for my shipment of RGB LED strips :/

The UL2803 transistor looks like a complicated transistor to me.
They do work well for me to switch the LED strip, right?

Thanks again smiley
« Last Edit: May 30, 2012, 01:44:00 am by NicksonYap » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 100
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you know what I have to change in the library to use it for Duo LED?

For example, if I want to light up LED 1 and 3 in yellow (wiring is RGRGRG) i have to use the following

  ShiftPWM.SetRGB(0, 255,255,0);
  ShiftPWM.SetRGB(1, 0,255,255);

Is there a way to edit the library so I can use it like this?:
  ShiftPWM.SetRGB(0, 255,255);
  ShiftPWM.SetRGB(2, 255,255);

Logged

Eindhoven
Offline Offline
Jr. Member
**
Karma: 1
Posts: 87
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Use SetGroupOf2(led, val1, val2) instead.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I came up with an idea last night. Couldn't you tie the data out pin of the last shift register back into the microcontroller to autodetect how many output pins you have? (by shifting out all 0's, then sending a single 1 and recording how many clock pin cycles it takes to get to the pin tied back into the microcontroller?
Logged

Eindhoven
Offline Offline
Jr. Member
**
Karma: 1
Posts: 87
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cool idea smiley
But I don't think many people want to use an additional input pin to auto detect something they already know. Or do you see a use case where the number of shift registers is variable?
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If one was to make this into a modular setup it would be easier since maxBrightness could be automatically calculated also
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And I also have a scrolling function for shiftmatrixPWM that I'm testing on the board that Paul sent us. The lowercase letters in my font need some work but it can display every ascii character. I am trying to get the flash usage down though but it could be hard since the font uses 480 bytes(96characters*5columns each)(After typing that end parentheses, i freaked out because it didn't make a box around the first parentheses. I need to get out more smiley) I just have a sketch with a function right now and it takes 12000 bytes of flash!
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 197
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Scratch that, the shiftMatrixPWM code and setup for it is 10000 bytes. So my code only takes 2000bytes. And can I use other spi devices while this library is running?
« Last Edit: June 14, 2012, 02:34:59 pm by ematson5897 » Logged

Liberal, Kansas
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess I am overlooking the link to the ShiftMatrixPWM files. I can find, and do have the ShiftPWM files. But I can not find anything dealing with the matrix end of it. Am I just missing something or what? Any input would be appreciated. And one other question. Will this work with TLC5940's or strictly for the 74HC595's?
Logged

Pages: 1 ... 14 15 [16] 17 18 ... 20   Go Up
Jump to: