Individual Control of 6 RGB LED's

Discussion in 'The Projects Forum' started by Pawel19, Sep 1, 2012.

  1. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    DISCLAIMER: I have multiple questions spanning varied topics from microcontroller selection and circuit design to programming a user interface. Feel free to answer any of my questions or give advice on any part without answering everything. Thank you in advance for any help, it is very well appreciated!



    I am starting a project and although I've taken electricity classes in college, I have very little practical knowledge as far as the project I have in mind. I will need to control 6 RGB LED's individually with a microcontroller. They will be operated by a rechargeable Lithium Ion battery most likely (3.3V). I need USB interface between the computer and the microcontroller. Finally, I will need to implement a user interface allowing simple color input scheme based on RGB component colors on three single axis (one red, one green, on blue) as opposed to a "color map" on multiple axis. Not sure if I'm using the correct terminology, but this is what I'm referring to, on the right as opposed to what's on the left:

    http://www.flashandmath.com/intermediate/rgbs/

    I will also want very simple control of (overall) brightness for the combination of three colors on a single slider of the same fashion.



    I am looking for suggestions or resources which will help me in the following areas:

    1) Picking a microcontroller. I've basically listed all the features I currently require. I've looked at Arduino and Teensy++ a bit and I just received a Stamp Basic microcontroller. I am open to any suggestions, but require USB as stated and definitely want to keep the price under ~$40. Ease of use and documentation are paramount as I am pretty much starting from scratch.

    2) I am a bit confused about PWM and whether I could even use PWM unless I had 6*3 PWM ports (or whatever the word is for them) on the microcontroller. For instance, the Teensy++ has 9 PWM listed, would this only be sufficient for 3 RGB LED's with individual control? Can I connect the LED's to something other than the 9 PWM connects and still have the same control? Would the coding be different?

    3) BAM Vs. PWM: would BAM be better for my needs? With PWM can you in general set the frequency to any value? I need there to be no noticeable strobing effect even at decent velocities. Would BAM make my coding much more difficult? Would it more effectively accomplish the lack of noticeable strobing artifacts?

    4) How do I go about tying a user interface for color selection to the microcontroller? I'd like the program to be accessable solely on a website (as well as my home computer) where I would be able to save my different sets of color selections.

    For instance:
    Setting1 = 6 LED's RED
    Setting2 = Rainbow Fade
    Setting3 = Each LED displays a unique color
    etc. for a multitude of settings.

    Would this be difficult to implement? What programming language would be best for this goal? Can I use any language regardless of the microcontroller for the user interface/web program? I expect this to be where the bulk of my time is sunk. I'd like the option to refine and aesthetically design this with time, but initially all I require is functionality. I realize this question is probably the most open-ended, but any help would be greatly appreciated!



    Ideally, I'd like to complete this project in ~50-80 hours but I realize this might be completely unrealistic. If you think it is (starting from square 1 as I basically am), please tell me so and give me a range you think would be more realistic. I realize it could possibly be well in excess of 100 hours. Thank you again, and please point out any areas where I am clearly misguided and point me in the right direction. Cheers!
     
  2. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Just realized some follow ups:
    5) what is the difference in using PWM vs analog for RGB LED's as I described? Is one preferable? Seems PWM is used in most of the programs I'm finding.

    6) Would I possibly need something of this sort to increase my PWM slots? http://www.arduino.cc/playground/Learning/TLC5940
     
  3. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Sorry! Additional stuff.

    A) I'm open to a discussion on battery choice. If there is a reason I should not use a 3.3V Li Ion battery please let me know. If you have good suggestions let me know.

    B) What is the difference between analog and PWM for the uses I described? Seems PWM is preferred. Could I used both?

    C) Would I require something of this sort possible? Would it make things simpler? http://www.arduino.cc/playground/Learning/TLC5940

    Thanks again!
     
  4. wayneh

    Expert

    Sep 9, 2010
    12,120
    3,046
    Let's start at the beginning. Do I understand that you want to precisely control each of 6 individual RGB LEDs, to manipulate the balance of RGB, effectively creating a 6-pixel color TV?

    PWM is definitely the technology you want for this, but I'm wondering how accurately you need to relate the pulse duty cycle to light intensity. Without calibration, that will be a bit of a black box. I mean I doubt it will be something you can predict from datasheets unless your LEDs are very well documented.

    To use that LiOn battery voltage, you'll need a voltage boost circuit to get you up over the Vf of the LEDs.

    If you want to save time at the expense of cost, I'd use a LabJack (I have the U3HV). For about $120 it'll give you an easy USB interface to your computer and can implement the PWM control directly. (I'm not sure I could do 6 channels of PWM with my U3.) You can program it using Excel (VBA) or pretty much any language you're happy with. I've played with mine enough to send a PWM, simulated sine wave to slowly pulse an LED. Worked great!
     
  5. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Yes, I want to effectively design a 6 pixel TV, with 2 red, 2 green and 2 blue pixels I suppose.

    Your second paragraph about relating pulse duty cycle to light intensity is not something I can really address without having actually experimented with the setup a bit. I'm fine with tinkering with the intensity a bit to create decently accurate colors for each LED, but I was assuming there would be some decently simple way of doing this if I could simply tie the variables R, G, and B from triple slider UI to the pulse duty cycle for the related R, G, and B diodes.

    I accidentally stated the incorrect voltage. The battery I was looking at would be similar to one of these, running at 3.7V: https://www.sparkfun.com/search/results?term=battery&what=products&page=1

    Would that be sufficient? How big of a voltage drop do I want across my resistors? The RGB LED's I've looked at have a Vf of 3.2V for the blue and green diodes.


    Thank you for your labjack suggestion, but unfortunately everything stated here combined has to cost much less than that. The number I'd like to aim for is ~$40. Last night I was up very late and not thinking straight when I wrote $40 for the microcontroller itself, I'll edit it. With ~$10 for the battery, $10 for the LED's, this leaves about $20 for the microcontroller.

    Could any of the other I/O ports be used aside from PWM ones? I've seen people hook up LED's to analog ports. What are the dis/advantages of this method?

    Finally, I forgot to mention I want a simple button or perhaps two to cycle through the banks of saved LED settings. Perhaps one button for moving forward through a bank and a second for moving backwards.

    Thanks!
     
    Last edited: Sep 1, 2012
  6. wayneh

    Expert

    Sep 9, 2010
    12,120
    3,046
    Oh, so you have just 2 RGB LEDs for a total of 6 LEDs? I thought you meant 6 RGB, or 18 individual LEDs.
    Well, it's borderline. I think it will work until the voltage sags as the battery drains. If you use PWM, you don't need a resistor to limit current. You may want to limit the maximum duty cycle of the PWM though, so you don't exceed the average current limit for the LED.
    Fair enough. Others here will have to help you with the µC stuff - not my wheelhouse.
    You can. The advantage is simplicity. With my LabJack I can send, for instance, 1.8V to one of the output pins and light a red LED there. One disadvantage is that the range for an LED, from dark to destroyed, might be from 1.6V to 1.9V. Another disadvantage is that this range will vary across LEDs and is not predictable. And finally, a given LED will take different current levels (and thus be at varied brightness) depending on temperature and other factors.
    That sounds like simple programming of the µC.
     
  7. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Ugh...I need to not write right when I wake up or when I stay up til 4AM. Especially when I'm painkillers for my wisdom teeth :/

    Sorry for confusing, I definitely meant 6 RBG LED's, for 18 pixels total.

    Yeah, I understand what you're saying with 3.7V sagging and not being enough. I'll probably be looking for a battery that can do 5V at least.

    So it seems PWM would definitely be the preferred method to use. I guess I need to find a microcontroller with18 PWM outputs. Can I set the frequency on PWM slots to an arbitrarily high frequency? I need there to be no noticeable strobing artifacts even when shaking the LED's.

    Finally, all the tutorials I've seen include resistors even when the LED's are connected to the PWM. Your'e saying this isn't necessary at all? Would I need any device to control the current/voltage? Transistors or anything of the sort? Sorry, I'm really pretty new to all of this.

    Thanks for the reply! Gonna probably post a video of a similar project here in a bit.
     
  8. wayneh

    Expert

    Sep 9, 2010
    12,120
    3,046
    We all have our moments. ;)
    It seems that way to me, but I'd like to have the opinion of somebody that knows for sure.

    I think you'll be able to get high enough (1kHz or more is probably fine to eliminate most visual effects) without much trouble. I don't think it will be "arbitrary" though, and may depend on your µC's clock, divided down by a factor.
    I'm reluctant to say "at all", but basically it shouldn't be needed and would defeat the purpose of efficient PWM. They may use resistors to cover the event of PWM failure or setting the knob at 100% duty cycle. But again, that introduces a linear loss that PWM is there to solve.
     
  9. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Here is something similar to what I would like to design:

    http://www.youtube.com/watch?feature=player_embedded&v=Fqt0mbUJ5sI



    Edited: Wouldn't I still need to regulate the current initially to not destroy the LED? For instance, if we focus on one Red diode then I'd want it to be at full brightness which would equate to being completely on -- no pulse. If the current were not controlled this would destroy the LED. If I was mixing colours to create white for instance this wouldn't matter, because the R, G, and B diode could each have a 30% pulse.

    Trying to figure out a schematic for how to organize the circuit also as originally I thought everything could be run in parallel but now I see information stating that running LED's in parallel is dangerous. Would this still apply if PWM is used? Wouldn't I NEED to run them in parallel for individual control? I'm starting to confuse myself :/

    Also found this which seems to describe how to have PWM control without PWM ports: http://www.best-microcontroller-projects.com/rgb-led.html
     
    Last edited: Sep 1, 2012
  10. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    So I've found some more info. Basically I need someone to help me deciding which of these routes would be the easiest. Not actually sure I could do what I need to do with each of these, but I believe that is the case.

    1) 18 PWM chip. This seems unreasonable and the cost seems high. An unlikely solution.

    2) Use an LED driver. Could someone help explain why some are listed as "RGB?" This seems like a possibly good option, but I also don't understand if I could get the required current, as I think most of these are listed below the possibly 20mA*18 LED=360mA I require. http://www.ti.com/paramsearch/docs/...log&familyId=480&uiTemplateId=NODE_STRY_PGE_T

    3) Shift registers. This seems like a viable option. I believe the above LED drivers use a similar process plus some added features. Can anyone help explain the difference and what would be best for my project? http://bildr.org/2011/08/74hc595-breakout-arduino/

    4) Soft PWM. From what I understand I can simply do some extra coding on any I/O to achieve PWM functionality. Is this true? If so, would I simply have to find a board with 18 I/Os?

    Thanks again for any help!
     
  11. wayneh

    Expert

    Sep 9, 2010
    12,120
    3,046
    I'm not qualified to address your questions 1 thru 3 and not really #4 either. But regarding soft PWM, this is a possibility in theory but I'm not sure you could achieve the speed you need. You need audio frequencies or above to avoid visible flashes and I just don't think you can achieve that thru software. But, I could be totally wrong Not sure why I bothered to demonstrate my ignorance. :rolleyes: .
     
  12. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    I think you could use 18 manual PWMs on a faster micro, especially if you cheated a bit and put a cap across each LED, coupled with the resistor on each LED that will reduce any flickering by a great factor and allow you to use a much lower PWM frequency, which simplifies software and allows use of a slower and cheaper micro.

    The first thing to do would be to grab your favourite micro and try some manual PWM, and try a cap on a LED and see the result when fading or moving it etc. If that all works out ok then go to driving all 18 LEDs. :)
     
  13. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Thanks for the help.

    I'm probably going to pick up an Arduino or Teensy, simply because after much research that seems like a good starting point. From there for small scale production (<100 units) it seems I could go to an atmega chip and design a circuit on pcb myself using free software or Eagle. Obviously cost is an important factor which I'm trying to take into account early in the design, so I don't have to scrap everything later.

    Do you think I would need something faster than an Arduino? To get the number of PWM's I need I'm pretty sure I would use 3 TLC5916 as described here: http://www.elcojacobs.com/using-shiftpwm-to-control-rgb-leds-with-arduino/

    Would I still need the capacitors in this case? What are they used for, decoupling (just learning about that from this resource: http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html)?

    It seems like the schematic I posted from elcojacobs would be exactly the setup I need. Do you agree?
     
  14. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Any Arduino with 18 output pins should do it. Yes you need the caps as they reduce the current ripple in each LED so the LEDs are constant and not flashing at the PWm frequency.

    You could use less pins on the Arduino but then need add external shift register ICs, which is probably going to be a worse solution if you final goal is a small cheap device. Less chips are better. :)
     
  15. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    If I used the external shift registers, couldn't I switch to a much simpler cheaper chip for production? All I would need is the minimum number of PWM outputs and that's basically it, correct? That seems like it would be much cheaper.

    Also, from I've read, going with software PWM is not an ideal solution as it takes much more processing power.
     
  16. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    I guess I'm still confused a bit on the difference of hardware vs. software PWM. I've read that hardware is better because it doesn't use processing power.

    But I've also read BAM is better than PWM because it uses much less processing power. I'm assuming when this is stated that it's referring to software PWM.

    When you say manual PWM are you referring to soft or hard PWM? Can anyone point me to a good link explaining the difference between the two, because I've been unable to find good info on it?


    Think I finally found a bit of info. With an Atmega8 for instance I could have 3 PWM channels for a few bucks. Add 3 shift registers as linked above and the combo comes in at <$10

    http://www.societyofrobots.com/member_tutorials/node/228
     
    Last edited: Sep 4, 2012
  17. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Sorry I should have explained better. When I said "manual PWM" that was referring to doing the PWM via software, on any of the micro's output pins. That is a bit slower than using the micro's inbuilt hardware PWM modules but is still fine for 200Hz PWM which is plenty enough for LED dimming (especially with caps on the LEDs).

    If you want to use multiple chips then go for it. :)
     
  18. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Thank you! I found that info later after searching a bit. 200Hz might actually not be fast enough for my particular application, but I'll do some testing and see!

    Thank you for your help again!
     
  19. n1ist

    Active Member

    Mar 8, 2009
    171
    16
    You can certainly do it in software PWM. I have done 256 channels of PWM (a 16x16 matrix) on an ATMega328 at 20MHz. At 6 bits per channel, I started to see flicker. 54 channels of 8-bit dimming should be doable. I used PFETs as high-side drivers and TPIC6B595 shift registers as low-side; if I was doing it again, I would probably look at the TLC5916 constant current shift register for the low side, but would have to check to see if it would work fast enough for multiplexing.

    There are some 16-channel LED drivers out there that handle the PWM themselves; look at the TLC59116. Allegro probably has something similar to the TI parts if you prefer.

    /mike
     
  20. Pawel19

    Thread Starter New Member

    Sep 1, 2012
    25
    0
    Don't really know enough to prefer any brand over another. One question I do have is if the prices listed on TI's site are for single chips. Not sure what the 'ku' means.

    Could you possibly explain a bit more the difference between the TLC5916 and the TLC59116?

    I don't think multiplexing will work for me because my LEDs will be moving a decent velocity and I don't want there to be noticeable artifacts (I assume you used that in your matrix). Thanks for your help!
     
Loading...