Shop OBEX P1 Docs P2 Docs Learn Events
Powering LED's — Parallax Forums

Powering LED's

shanebatyshanebaty Posts: 30
edited 2010-10-07 17:36 in BASIC Stamp
Okay I am new to this, sorry if this is not the right place. A basic stamp is used in this project, so this is the first place I thought to ask.

I am working on a project that has 216 LED's. I am using the basic stamp to control them to make designs. My plan is to use a transistor to power 9 LED's at a time, and 3 transistors to one IO pin on the stamp. So 1 pin turns on 3 transistors which turn on 9 LED's. So 27 LED's total to 1 IO pin.

My Question is, would the 2N3904 NPN Transistor be able to handle the current from 9 LED's? I just wanted to hear a second opinion before I started Burning up transistors.

Thank You :-)

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-07 07:42
    Figure it out ...

    Assume you completely turn the transistor on (saturate it - provide enough base current so it's completely on - see here).

    You didn't say how much current your LEDs take - assume 20mA each (for a standard LED - find the datasheet for your LEDs)

    Look up the datasheet for your 2N3904 transistors (here). You want to know the maximum collector current (200mA for Fairchild's).

    There's still the question of heat dissipation. A transistor isn't a perfect switch. There's still a voltage drop across it even when saturated. Usually this is 0.3V. At 200mA, this is a power loss of 200mA x 0.3V = 600mW. You'll have to look at the ambient temperature and how the transistor is mounted to figure out whether it can get rid of that amount of heat continuously.

    Then there's the question of maintaining saturation. You'll have to look at the gain (hFE) curves for the transistor to see how much base current is needed to put the transistor into saturation at 200mA collector current. This usually varies widely from transistor to transistor, so you have to use the minimum gain for a "worst case" situation. They don't give the values you need directly, but it looks like around 100, so you'd need at least 2mA base current, maybe 5mA to play it safe. If this isn't enough, the transistor will get hotter faster. The base resistor sets the amount of base current.

    If you want to drive 3 transistors, you'll need 3x that amount of current from the Stamp pin. You look at the Microchip 16F57 datasheet because that's the microprocessor used in the BS2 (here - page 57). There are current limits for each individual I/O pin, for groups of 8, and for the whole device.
  • Spiral_72Spiral_72 Posts: 791
    edited 2010-10-07 10:05
    Without running the numbers I'd say you need to look at Darlington transistors or MOSFETs, so no, the 2N3904 won't do it (Unless you use tiny LEDs @3-5mA each)

    You are going to need a fairly healthy supply as well: 4.3A @ 20mA / LED plus losses due to heat and your more than 6A probably.
  • shanebatyshanebaty Posts: 30
    edited 2010-10-07 12:33
    Thank you for your help and fast response.

    You were right. They are 20mA each, i forgot to put that in the first post. I wasn't planning on having 20mA of current for them, 7mA is at about the lowest brightness I need. So if i have 5v and put around a 700ohm resistor in series with each LED , then i should get at about the 7mA that i want. Is that correct? So then would i would just be using around 63mA per transistor?

    And i looked at the data sheet but its been a while since i have looked at those graphs so I am still a little confused about them. Am i supposed to be looking at the " Base Emitter Voltage vs Collector current"?
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-07 14:41
    Also important is the color since that determines the voltage drop of the LED and therefore the size of the current limiting resistor needed. If you put several LEDs in series with a resistor per series string and put several strings in parallel driven by one transistor, you could reduce the number of resistors, transistors, and I/O pins needed. You could also run the transistor / LED strings off Vin (6V to 7V would be good). If you run off 6V, you could put 3 LEDs in series. In any case, you figure the resistor as follows:

    Rseries = (Vin - Vf - 0.3V) / 7mA
    Where Vin is the voltage applied across the LED / resistor / transistor string.
    Vf is the forward voltage of the LED (or the total of several in series)
    The 0.3V is the presumed saturation voltage of the transistor.

    For 3 red LEDs in series with a 6V Vin, you'd have R = (6 - 3x1.7 - 0.3)/0.007 = 0.6/0.007 = 84 Ohms
    You'd usually pick the next highest standard value like 91. You could also use 82 Ohms with a slight increase in current.
  • shanebatyshanebaty Posts: 30
    edited 2010-10-07 16:57
    Okay, so tell me if this is right. Because i need 9 LED's per pin i would connect 3 sets of 3 LED's in series, in parallel? hope that makes since. and use the formula you gave to figure out the resistor i need for each set.

    and as far as the colors, that is the reason i was going to have 3 transistors per pin. one transistor for red another for blue and a third for green
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-07 17:31
    You'll need a different resistor for each color chain because the Vf is different for the different colors. Red is usually 1.7V. Green is commonly 2.1V although that can be different for different LEDs. Yellow is 2.1V or 2.3V, again depending on the manufacturer. Blue and white are often over 3V, sometimes 3.1V, sometimes 3.3v, occasionally 3.6V. The datasheet for the LED will tell you.

    You can use a red, a green, and a blue in series for 1.7V + 2.1V + 3.3V = 7.1V and run the strings off a 7.5V R/C battery with an appropriate resistor. You could also use a 9V battery pack. Don't use a 9V radio battery. They don't store enough energy for significant use.

    You put the strings in parallel, driven by one transistor. Each string of LEDs (plus its resistor) should work off the same voltage so you can put them in parallel.

    You might want to keep the LEDs together that have the same color with each I/O pin controlling a different color. That way you can change the color of the display by switching one or combinations of colors on and off.
  • shanebatyshanebaty Posts: 30
    edited 2010-10-07 17:36
    Okay. I think i got it. thanks for the help!
Sign In or Register to comment.