base resistor of pnp transistor

Discussion in 'General Electronics Chat' started by skk, Jun 3, 2011.

  1. skk

    Thread Starter Member

    Mar 15, 2011
    I have an 8 LED driving circuit using a pnp transistor. I stole the design from somewhere, and I don't know what value to use for the base resistor, or even how to figure it out.

    I tried to draw it in text but it didn't work out. Let me explain the circuit:

    VCC ( 5v ) is connected to the emitter of the PNP transistor. The collector of the PNP is connected to the annodes of the 8 LEDs. The cathodes of the 8 LEDs are connected to the 8 row drive pins of the microcontroller. The base of the transistor is connected to another microcontroller pin via a base reistor.

    Both row and column pins are active low.

    How do I come up with a good value for the base resistor?

    I never did understand transistors, how do I come up with the base resistor value? Is there anything else missing here, or a way to make the circuit better?
    Last edited: Jun 3, 2011
  2. SgtWookie


    Jul 17, 2007
    You didn't include the CODE blocks, so your schematic got all scrunched up to the left. I added them:
    Code ( (Unknown Language)):
    2.               +/\/\/\/\-|>|--- micro controller pin 7
    3.               |    ......................
    4. vcc --\     /-+/\/\/\/\-|>|--- micro controller pin 0
    5.        v   /
    6.        -----
    7.          |
    8.          ------/\/\/\/\----- micro controller pin for the row
    I also added current limiting resistors for the LEDs, because each will need one.
    R >= ( Vsupply - LED_ForwardVoltage ) / DesiredCurrent
    to calculate the LED current limiting resistors.

    Basically (sic) Rbase ~= (Vcc - Vbe) / (Ic / 10)
    Your Vcc needs to be the same as your uC's Vcc; if it's higher, you won't be able to turn the PNP transistor off.

    So, if you have two LEDs in parallel that need 20mA current each, that is a total of 40mA collector current (Ic), and your base current will need to be 1/10th that much, or 4mA.

    Vcc = 5v
    Vbe is usually around 0.7v.
    So, substituting:
    Rbase ~= (Vcc - Vbe) / (Ic / 10)
    Rbase ~= (5v - 0.7v) / (40mA / 10)
    Rbase ~= 4.3 / 0.004
    Rbase ~= 1,075 Ohms. You could use either 1.1k or 1k Ohms.

    Keep in mind that for a single (non-Darlington) transistor, you need 1/10th of the collector current for the base current. Since most uC's are limited to ~20mA per I/O pin, the most collector current you should plan on is 200mA; in the case of LEDs that need 20mA, you could have up to 10 in parallel.

    For a 200mA load, you could calculate:
    Rbase ~= 4.3 / 0.02 = 215 Ohms. 220 Ohms is the closest standard value.

    You can use 2N2907 transistors; they are common and inexpensive; good for up to about 500mA collector current as a practical limit, 2N3906 transistors are limited to around 100mA as a practical limit.

    Also keep in mind that uC's have a package limit for current; some might be pretty low. You will need to read the electrical specifications table for your particular uC. If you exceed either the I/O pin limits or the total package limits, you may damage the uC permanently.
  3. skk

    Thread Starter Member

    Mar 15, 2011
    Thanks again for your excellent advice!
  4. skk

    Thread Starter Member

    Mar 15, 2011
    Reading over your reply again I suspect there may be a problem with my design. I want to be able to turn on any number of the 8 LEDs together. They are all in parallel, so if I just turn on 1, it will have 8 times less current than if I have all 8 on. What can I do to work this problem?
  5. SgtWookie


    Jul 17, 2007
    If you have 8 LEDs in parallel, and you want 20mA current through each when it is selected, then you will need a maximum of 8 x 20 = 160mA collector current, so 16mA base current, which will require a (4.3/0.016) = 268.75 (use a 270) Ohm resistor on the base.

    This will allow for any or all of the 8 LEDs to be on.

    You will need to calculate the current limiting resistors for each LED as I showed above:
    Remember, you must check to make certain that your uC will support the total current sink required for that circuit; at 20mA per LED and 16mA for the base, that's 8 x 20mA + 16mA = 176mA sink current, which is a lot; that's beyond the capability of many microcontrollers.

    You may need to either reduce the current for each LED by increasing the current limiting resistors, or use transistors or logic-level MOSFETs to sink the current from the LED cathodes. The 2N7000 MOSFET would be a good choice; they are pretty inexpensive, have a Vdss rating of 60v, and will sink up to 200mA current - and come in a TO-92 plastic package. They have an Rds(on) of ~6 Ohms when Vgs (voltage on the gate relative to the source terminal) is 4.5v.
    Last edited: Jun 3, 2011