1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics control of rgb leds by computer

Discussion in 'Modding' started by Scaranhybrid, 1 May 2004.

  1. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    a bit confused about some details

    I plan or embedding them in pieces of sanded plastic so that the plastic milky edges are illuminated, 6 horizontal strips and 2 cylinders behind that ( 2 a piece for the horizontals and 9 a piece for the cylinders, 6 - 2 rgb led arrays and 2 9 led arrays and the 2 -9s will be surrounded by the ir leds)

    my design is a little wierd here , I have a mechanical mechanism that is going to move the ir and 9 led arrays back and forth in the head behind a fresnel lens giving the robot the ability to widen and narrow its beam, this same mechanism is going to move the angle of the cameras subtilly such that ( and by the camera mounts turning a geared pot) use trig functions to figure out by the position of its cameras trained on an object ( with in a certain distance) how far away it is and within its field of view.

    Ok that was just a fyi

    about the electrical problem here,

    the darlington driver would go across the grounds of the leds right? I know that for the 2 rows of 15 leds ( think the way its in the schematic in the array.)in parallel I will just need one resister per row to get the voltage right, would the sinking through the darlington still fry the pic? is the alternative having the ground come off the darlington and only be able to control the rows and not the individual rgb led s?

    what I think you mean is this,

    I would add resistors to the positive pins of each row of leds in parallel so the voltage is correct and no leds go boom, and 1 darlington driver pin ( per horizontal row. like so >-----resistor-----led-----darlington in ---darlington out ----sinking pin of pic or ground or both ????


    I am going to design a 40 mhz circuit here , I did some thinking and on the rgh leds this would give me the ability if I divided the duty cycle down for each row by 8 different evenly divided pulse widths adjusted for the brightness of each color of led ( with the resistor) this would give me for each led 8 variations of blue brightness, 8 varations of green and 8 variations of red for a total of 512 colors ( I know i might not be "AILEN" enough to tell the difference between some of the colors) I was wanting to program the chip such that the serial port sends in a word that tells the chip what flashing pattern to use ( a visably perceptable flashing pattern , like solid or knight rider flashing pattern) and each pattern would have a number of slots that describe what colors are where within the pattern. a dialog might be like (solid)which would have one color associated( hex#describing color) so the display would seem all lit up one color and the program would loop till another pattern was triggered. it could get like (fade)-(ammount of time for transition)-(color1)(color2)-(loop yes/no)

    correct me if im wrong but if I keep the ammount of time for blinks that are meant to be inperceptable above 30x per second for a complete run through of the pattern of blues reds and greens then it would magically appear to be a non pure red green or blue color and all the leds would seem lit ? another pattern I though of that might look cool would be top to bottom scans of color that would be at the edge of the eyes ability to percieve so it would appear to scan ( like the holograms in starwars)

    I dont know if all that is possible , right now I just dont want the circuit to blow up in my face, if all that is possible is that I have 256 solid colors and can turn on and off the ir for the ir cameras , then I guess that is good for starters, before I even touch the first wire though I want to have considered all this. sorry for this being so wordy , any thoughts comments?


    scaranhybrid
     
    Last edited: 19 Jun 2004
  2. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    Ok I see what you mean about needing resistors and im seeing that this aspect may make what Im wanting to do impossible.

    1 the resistor values for the voltages of the 3 colors is different as is the brightnesses of the rgb leds. ( I was experimenting and the red in the leds are very delicate ( can only take about 2 volts or it frys) the blue and green are higher and have higher brightness.

    so If I want to be able to calculate white i need 3 different pwm waves going through each respective led. I dont see how I can do this If I wanted to light red and green together to get another color I would see that even though I dident go over the ammout for green or red I could still end up with a fried led

    am I right about this or are the reds in the led just really fragile and not very bright?



    I had assumed that I should be able to put a single resistor value in front of each color row and the darlington array on the ground row and then should be able to pwm away but aparently I could end up in a situation where I try to do something in the programming and end up frying diodes...

    what im asking is since there is a voltage drop for each individual led here would I not need a changing resistor value for each color that I tried to generate?

    if i tryed to make white would my resistance need to be greater than if I tryed to make purple with red and blue or if I just needed red? in each instance the power going through the led would be different. or did I miss something? :duh:
     
  3. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    when you have LEDs in series, its not that hard to model.


    ----|____|----|<-----|<------
    220 ohm 1.4v 1.4v
    lazy ascii, thats a resistor and two LEDs, say each LED has a voltage drop of 1.4v

    thats the same as.

    ---|____|-------|<--
    220 2.8v

    so ohms says.
    V/R=I

    As such the current been used gets smaller, so the chance of an LED frying gets less.

    Important.

    Enless you want a large amount of dead pic's you MUST set a pin to either output high, or input (output high impedance).

    otherwise you will end up trying to drive an LED high, and LOW.

    Of course once you have a transistor driver in the way that shouldn't matter anyway (as your either driving the transistor to low impedance or high impedance).

    Alex.
     
  4. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Obtaining pure white is a little difficult as setting the R G and B to 100% will usually be slightly tinted towards a pastel colour, so this would normally be corrected with using different resistor values. However, how you do this depends on how you plan to multiplex the LED's.

    If you scan through each LED individually, then there is no need for the darlington driver and you can simply place the resistors on the left of your diagram where the LED's feed back into porta and RB1 & 2. IMO this would be rather more code consuming and generally much longer winded.

    If you scan through the LED's as I suggested, you'd need a darlington driver where the resistors would be as a described above. The ULN2003 has low current inputs with darlington transistors between the ground pin of the IC and the output. However, you'd need resistors on each of the outputs of the PIC (the ones mainly on the right hand side of the PIC). But this would mean that you'd need to change the diagram into columns of red LED's, columns of green and columns of blue...
    [​IMG]

    It all depends how you plan on doing everything. You may find it easier to breadboard it first and test out both methods to see which way will work out best for you.
     
  5. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    ok your diagram makes sense,

    IM going to do some math to try to determine how to set the resistors up so that I have the max red brightness matched to the max green and max blue, from there I assume I will divide ( using the pwm) into 9 discrete pulse widths so that I get (using blue as an example)
    width 1:1 full blue unit
    width 2:7/8 full blue
    width 3:3/4 full blue
    width 4:5/8 full blue
    width 5:1/2 full blue
    width 6:3/8 full blue
    width 7:1/4 full blue
    width 8:1/8 full blue
    width 9:0/8 no pulse on blue

    I do want to do the resistors and darlington driver so that I can get rows of color going if I want to , I want the code to be simple so that I can get elaborate with visual patterns and colors (as the keypad will be a variation on this circuit) if Im able to light several at a time ( in the case of red) I will get brighter results right?

    also im going to make it such that the ir leds are grounded through the rows.

    Im not sure what animus means about me needing a high pin and a low pin or my pic will burn up. Im assuming that this will be taken care of by the darlington , by your diagram it goes to ground and shunts off the extra current that would otherwise kill the pic right? so the way you have modified my pic circuit I will be able to ( assuming I get the resistor values right) get white if I do a full length pulse of blue red and green filling 100% of the duty cycle. this is the way I want to go as I believe this will give the brightest and safest results ( safest to the equipment)

    one question does the pic outputs put out 5 volts at 25 ma?
    by the way the values for the leds are as follows:

    color-----brightness---voltage----amperage -----------volts to get 550 mcd

    green----2400 mcd----3.2 v-----35 ma----------------------0.733333333..
    blue-----550 mcd------3.6 v----~ whatever that means------3.6
    red------650 mcd------2.05-----~ whatever that means------1.181818181..

    I assume the ~ means equivalent or approximately 35 like it does in math notation

    like youre saying though looking at the brightness of blue and then looking at the brightness of red and then the voltages, In mathematical terms if the brightness of each color is a function of its voltage , to get white I need to get 550 mcd blue 550 mcd red and 550 mcd green and this would be the voltages above.
    it takes a lot of volts to get blue up to 550 mcd it takes signifigantly less to get red up ther and a hell of a lot less to get green there. ( blue is the least efficient color on voltage.) I need to figure out how to set it up so that a full pulse width from the pic outputs gives me 550 mcd across the board ( or higher maybee as I see the max voltages are different ( I assume this means part failure sooner though I may figure on adding half of the difference to max voltages to the values above) even though I have 550 mcd across the board I could like you said previously have up to 15 rgb led elements going at the same time so I assume 550 X 15 = 8250 mcd output total for each color if Im trying to just light up the array 1 solid color and then pwming the display to create a color 8250 mcd ( If im not mistaken simply maxing out a blue led I have here ) is generally enough to light up my appartment.

    I have the remaining rgb leds lined up on a breadboard like storm troopers

    (have 53 of them left )

    Ill be redoing my schematics here soon for the 18 series pic.

    scaranhybrid
     
    Last edited: 21 Jun 2004
  6. TheAnimus

    TheAnimus Banned

    Joined:
    25 Dec 2003
    Posts:
    3,214
    Likes Received:
    8
    reading it back i can't see what i was thinking about now, i have a horrible fealing i had been looking at someone's schematic from another forum, oops! :duh:
     
  7. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    its all good man I have moments like that all the time . :confused:

    so do you think i got the voltage values right for the mcds being equal or will i need to pwm to get the steps and adjust in the programming ?

    Scaranhybrid
     
  8. SteveyG

    SteveyG Electromodder

    Joined:
    23 Nov 2002
    Posts:
    3,049
    Likes Received:
    8
    Are you using those RGB led's from ebay? If so I'll experiment with resistor values for you until I get white. Since the light output isn't linear, so your calculation won't work.
     
  9. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    the ones I have are off of LSdiodes.com

    wow so it is a function of the pwm I have to get , so it is important though that the brightnesses in the hardware be even , hence white , so youre saying the the initial brightness matters so the initial 100% duty cycle on all 3 elements in the diode yields white .

    thanks for helping if you can do it .

    Ok out of the madness at work and can add this little bit :
    the specs of my leds is here

    http://www.lsdiodes.com/5mm/5mmfullspectrum.htm

    and on top of that I got to thinking that since you say voltage is not a linear function of brightness, I am assuming you mean it is a curve so

    I took the values in the above url and made a crude graph

    correct me if im wrong ( Im going to whip out some math kungfu tonight to get the specifics here :wallbash: )

    I am aiming to get 1000 mcd out of all the colors:

    for a 5 v supply with diodes rated at 35ma

    for red to get 1000 mcd it needs to have 2.3 v
    for blue to get 1000 mcd it needs to have 4.3v
    for green to get 1000 mcd it needs to have 2.55 v

    these are approximate , I am going to come back with a bigger graph and more accurate values here shortly and show my math work given the points that I know , I just need to review my functions and throw down some more graphs and check my work .

    as far as I can tell the green and red can take the same resistors as i will be limiting the red to not blow up and the green way way down ( underclocking green severely ) and will be running blue near but a bit below its max .

    I dont know if this will be practical and I may need to sub in lower values to make my leds live long and prosper.




    scaranhybrid
     
    Last edited: 22 Jun 2004
  10. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    Ok I did some kung fu figuring out the exponential curves for each color and the above numbers are accurate as is practical for the resistors available , the led calculators I have tryed suggest the same resistors unless im doing something wrong. there are 3 points ( 3 voltages) showing a low and a curve that represents approximate rate ( a bezier curve) whos rate of increase nearly doubles at the 2nd line segment in most cases here. like for red starting out in the low voltage it moves up approx 60 mcd for every .1 volts applied above 1.6v abd below 2.05v, in the upper segment( between 2.05v and 2.5v this rate of change doubles and is nearly 120mcd for every .1 volts . there are similar ( but much wider curves ) for blue and green , the green is completely off the scale ( ran out of paper)



    maybe testing the leds with some resistors would be easier but I dont currently have any resistors on hand ( I will be fixing this tomorow)

    Stevey G, If you got the leds off of ebay from telltronic123 the specs look very similar to the ones I have ( probably the same part ) the specs he quotes are withing the tolerances of the data sheet I have so

    I am predicting you will find that the resistors needed are:
    figuring on a 5 volt 35 ma source:

    blue - a 22 ohm resistor
    green - 82 ohm resistor
    red - 82 ohm resistor

    this is assuming youre using the same voltage and that you are getting ~1000 mcd per color but I dont think we have a way of knowing the actual mcd in practical reality , but if you did use 5 volts and the same resistors listed above and lit all 3 dies you probably got a pretty nice white color.

    please let me know if I was right , Im not trying to be arrogant or anything but just testing my math kung fu , did i get kicked in the head? :duh: or did i come off like NEO? :cooldude:
     
  11. Scaranhybrid

    Scaranhybrid What's a Dremel?

    Joined:
    1 May 2004
    Posts:
    26
    Likes Received:
    0
    Stevey G did you find the resistor valuse needed for white ?

    Its been a while and Im back working on the robot again and I am hoping we found out what resistors I needed. Did you figure this out yet?

    thanks again for your efforts.
     
  12. theshadow27

    theshadow27 What's a Dremel?

    Joined:
    23 Sep 2004
    Posts:
    616
    Likes Received:
    2
    dude, instead of re-inveting the wheel... why dont you just get a Maxim led matrix driver. its a chip that you can tell it what to display over 2 wire I2C. the have worked out all the current draw issues.

    this one:
    http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4206/ln/
    has 17 outputs, and 8bit (255 step) pwm brightness control, and is controled with only 2 wires (I2C). you would need 5 of them... to do your whole array, but one I2C bus can have 127 chips on it.

    if you could put up less precice brightness control, you could use a 7 segment display driver, a 16 segment driver chip (http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3540/ln/) like the Maxim MAX6955, which also includes a 32key keypad reader, and is also controled over I2C. heres why you should order FREE SAMPLES of this chip and use it (right off there website):

    [*]400kbps 2-Wire Interface Compatible with I2C
    [*]2.7V to 5.5V Operation
    [*]Drives Up to 16 Digits 7-Segment, 8 Digits 14-Segment, 8 Digits 16-Segment, 128 Discrete LEDs, or a Combination of Digit Types
    [*]Drives Common-Cathode Monocolor and Bicolor LED Displays
    [*]Automatic Blinking Control for Each Segment
    [*]10µA (typ) Low-Power Shutdown (Data Retained)
    [*]16-Step Digit-by-Digit Digital Brightness Control
    [*]Five GPIO Port Pins Can Be Configured as Key-Switch Reader to Scan and
    [*]40-Pin DIP Package

    and they will send you this chip FOR FREE. now you would want to spend weeks in assembler why? :wallbash:

    this chip is going to make your life easer. and its realy easy to use... you just send it "0110010011011011" to turn led 1 off, led 2 on, led 3 on, etc for each row. it also frees up your time for developing a more advanced robotic system, and lets you focus on things like design rather then how many Ma each led is drawing.

    best of luck
     

Share This Page