Bias resistor 2n3904 ?

Discussion in 'The Projects Forum' started by HarveyH42, Mar 16, 2008.

  1. HarveyH42

    Thread Starter Active Member

    Jul 22, 2007
    Last week I through together an RGB fader for 12 volts, using 3 LEDs in series per color channel. Anyway, had a few problems, and had to cut a couple traces, solder some jumpers...

    A ATtiny13 does the fading work, and used the same set up many times for single LEDs. But trying to step it up to a bigger and brighter is turning out a little more complicated then expected. I'm using a 7805 regulator, already smoked the 100 mA version, so bumped it to the 1 amp, which still got uncomfortably hot, so put a heatsink on it.

    I origionally used a 2n3904s with a 10k base resistors for each color, but it would only light 2 out of 3 of the blue and green LEDs. After messing around with the LEDs to make sure the LEDs were fine (smoked a green in the process), thought the 10k was too high, so shorted the one for blue. Got all three to light, and bright like I wanted. Knowing its abusing the transistor, I replaced the 10k's with 1 ohm (have a bunch).

    It works, but it's not right, and probably not safe, or likely to live like this for long. The 7805 still is getting hot, the AVR is getting warm (never happened before). Before dumping this PCB and starting over, what would be the proper base resistor between the AVR and 2n3904? Guessing this is where the heat problem is coming from. If not, then it's a bad board, and better to just start from scratch.
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    Are you using PWM to fade the LED's? If so, the base resistor may be the problem. If not, you may need some extra caps at the 7805 output to ground, and more at the ATtiny Vcc input.

    I tend to use FET's for logic outputs. The VN10LP is not too expensive, and will handle about 100 ma @ 30 volts.

    If you want to determine the base resistor for the 2N3904's, set one up to pass current through a LED with the current limiting resistor in place. Use a pot from Vcc to control base current. Use an Ammeter to observe collector current. When an adjustment to the base current pot does not change the collector current, you are at saturation. The resistive value of the pot will give you the base resistor.
  3. gurudutt pai

    New Member

    Mar 16, 2008
    as you are using leds of 3 diff colors , please note that the opr voltage for red is approx. 1.6v green 2.0 v , blue or white 4.0 v each , as each has a diff. semicond. process. Multiply by 3 for yoy have 3 in series to get the min opr voltage.
    Blue works around 12 v. so if you have 12 dc supply , use approx. 47 ohms for blue. For green & red the voltage is 4.5 to 6 v. so use about 300 ohms for them. Also to save your time test the leds & resis. val. seperately directly with the 12 v supply with out any transistor, so you can balance the max intensity by trial.
    Then use a medium gain power transistor like BD139 . to drive the leds. use a 5 v. reg. to drive the base with approx. 1 k resis to see if the drive & transistor is ok. Once this is proper hook up to your uC which can give about 3 mA pull up driv for the transistor via 1 k resis. With a gain of 100 or more you will get led drive of at least 200 mA or more . If you require more driv use
    a BC 547 / BD 139 darlington to get upto 1 amp driv.
    With this cir. nothing shold get hot as there is no consumption worth the heat , unless you have messed / missed out something.
    Note if you are controlling the intensity by PWM etc. the switching losses
    will generate some heat in the power transistor.
  4. SgtWookie


    Jul 17, 2007
    You need to limit the maximum current for each LED, or string of LEDs.

    In order to do that, you need to start off by determining the actual Vf (forward voltage drop) of your particular LEDs at the current you wish to run them.

    I have a simple setup where I use LM317L's (100mA adjustable Vregs) with a 110 Ohm resistor connected between the OUT and ADJ terminals. This gives me right at 11mA constant current output from the ADJ terminal, and it stays there with the input voltage being anywhere from 7v to 30v. You can get whatever current you wish from 5mA-100mA by using the formula:
    R1 = 1.2/Iout, where 5mA <= Iout <= 100mA.

    If you wanted 20mA output, you would use 1.2/0.02 = 60 Ohms. The LM317L will adjust the output voltage up or down in order to maintain the desired current.

    I then connect my LEDs one at a time, anode to the ADJ terminal, cathode to the supply return, and measure the Vf of the LED directly using a DVM.

    You can then calculate the resistor needed to limit the current throught the LED:
    Rlimit = (Vcc - Vf) / Iled
    For multiple LEDs in a string:
    Rlimit = (Vcc - (VfLED1 + VfLED2 + ... VfLEDn) / Iled

    Let's say you wanted a maximum of 20mA flowing through your blue LED that you measured as having a Vf of 3.9v. You said that you're using 5V for Vcc.
    Rlimit = (5V - 3.9V) / 20mA
    Rlimit = 1.1/0.02
    Rlimit = 55 Ohms

    As far as a driver circuit - you may wish to look at the ULN2x03 series (x=0 or 8) of ICs. These are really handy ICs for all sorts of controls. The ULN2003 has seven Darlington transistor pair channels, the ULN2803 has eight Darlington transistor pair channels. The input resistor on each channel is 2.7K Ohms, ideal for TTL or CMOS control input when running 5v or less (if 6V or more, use ULN2x04 which has 10K input resistors). The outputs are open-collector, and each can sink up to 500mA of current. There are also protection diodes on each channel. These IC's are also very inexpensive; you can find them everywhere for under a buck apiece. They will save you a lot of time and fiddling around with discrete components, as they require comparatively few connections.
  5. HarveyH42

    Thread Starter Active Member

    Jul 22, 2007
    The attached, is the circuit as it is now. The MCU PWM fades the LEDs. I was planning on abusing the LEDs with 40 mA, since it's pulsed, figured wouldn't hurt them much.

    I drew this up, before reading the replies, figured I might as well post the diagram. I know the current limit resistors for the LEDs need to be different, wanted to adjust those later to where all three are at 100% duty, it actually looks white.

    Will breadboard the suggestion for using a pot to find the base resistor, seems like the quick and simple solution.
  6. SgtWookie


    Jul 17, 2007
    Ahh, wait a sec...

    You're going to fry some stuff if you're not careful.

    Pots have a very low wattage rating when you get near the ends of their adjustment.

    Your poor MCU is going to be hot enough to fry eggs on with those 1 Ohm resistors on the bases.

    I threw together a circuit (just the LEDs and driver portion) that should be a good bit safer than what you are currently proposing. Note that the current limiting resistor for the blue LED's is only 15 Ohms. This may not prove to be "real world" accurate enough, as it depends upon your LED's Vf. Two 2n3904's are used as Darlington pairs; this amplifies the small current that the MCU is capable of putting out.

    As it is, your LEDs are going to have a very bright and brief lifespan if you're running them at 40mA - even at 50% duty cycle.
  7. HarveyH42

    Thread Starter Active Member

    Jul 22, 2007
    Thanks for all the help. Sorry it took so long to get back to this, had a busy week at work.

    I made a new PCB, and it works fine, nothing is getting even warm. I went back to the smaller 78L05 (to-92 package). My power supply says it's drawing .04 amps (not particularly accurate).

    Didn't turn out to be any brighter then using single LEDs straight off the MCU pins, but learned some new stuff in the process. Will try reducing the resistors on the LEDs.
  8. SgtWookie


    Jul 17, 2007
    Your red LED's should be quite bright with the 180 Ohm resistor.

    Your green LEDs could probably use a smaller resistor.

    But you really should try the procedure I put together above. However, since you already have the LED's mounted...

    If you have an LM317 sitting around, you can use it for a constant current source by adding a resistor between the OUT and ADJ terminal, and taking the output current from the ADJ terminal.
    Iout ~= 1.2/R1
    So you could use a 60 Ohm resistor to get about 20mA out of the ADJ terminal.

    Once you get that hooked up, use it to power each LED string, and measure the voltage drop across them to get Vled(tot)

    Don't forget, your 2N3904 Darlington pairs are going to drop some voltage across themselves; and it's current-dependent. See the datasheet for exact numbers.

    Then calculate:
    Rlimit = (supply voltage - Qdrop - Vled(tot)) / Imaxdesired
  9. nanovate

    Distinguished Member

    May 7, 2007
    If you use an LM317 remember to take into account the dropout voltage.
  10. SgtWookie


    Jul 17, 2007
    Good point. Once you measure the Vf of the series of LED's, make sure that the input voltage to the LM317 is at least 2v higher. Normally, they run around 1.7v-1.8v drop.