using BJT to turn on 7-segment LED

Discussion in 'General Electronics Chat' started by jut, Dec 1, 2009.

  1. jut

    Thread Starter Senior Member

    Aug 25, 2007
    This circuit is really for multiplexing four 7-segment LEDs. I expanded one of the 7 segments to show all of its LEDs separately. I'm trying to understand how the transistor goes into saturation when the microcontroller (uC) applies 5 volts to it digital pin.

    If the uC has 5 volts on pin 5 and 0 volts on say pin 21 it doesn't seem like "LED for segment A" would turn on because the diode initially acts like an open circuit thus not allowing the proper forward bias to be put across the base-emitter junction of the transistor.
  2. steinar96

    Active Member

    Apr 18, 2009
    Let's say you have 5V on the emitter. And 4.2v on the base. Knowing that Ve = Vb + 0.65 we get
    Ve = 4.85V making Vce = 0.15V.
    Saturation is usually defined as Vbe > 0.7 and Vce < 0.2V so in our case the transistor is saturated and thus allows current to flow. Once it is "open" the remaining voltage is applied across the diode and as it is higher then 0.7V the diode will turn on.
  3. SgtWookie


    Jul 17, 2007
    Steinar96, I'm afraid you got it backwards.

    Actually, the transistor is being used as an emitter follower. The collector is connected to +5v, and the emitter will follow the voltage on the base, but it will be about 0.7v lower than the base voltage.

    The troubling thing about this circuit is that there is no current control for the individual segments, other than the current sink limitations of the PIC I/O pins. There should be current limiting resistors between pins 21-28 of the PIC and the 7-segment display. The value of the resistors would depend on the Vf @ desired current of the segments, and Vcc less the Vce of the emitter follower.

    I would swap that NPN driver for a PNP, so that it could be used as a saturated switch. It would invert the logic for RA3, but that's easy to change.

    You could keep the logic the same by changing the NPN to a PNP, and adding an NPN saturated switch to the output to drive the PNP.

    See the attached for what I'm talking about.
    R2 should be changed to 390 Ohms.
    The current limiting resistors on PIC pins 21-28 should be 220 Ohms.
    Last edited: Dec 2, 2009
  4. jut

    Thread Starter Senior Member

    Aug 25, 2007
    Thanks for the help SgtWookie. I appreciate it very much.

    The circuit I posted may not be the best, but I still want to understand it.

    Looking at the circuit I originally posted, to "turn on" any LED, I apply 5V (from my digital I/O pin) across the base-emitter junction of the NPN and the LED. So I'm applying 5V across two diodes and a 150k resistor. Ohms law tells me that (5-0.7-0.7)/150k=24uA should flow into the base. If the NPN has a beta of 200, then I should see 4.8mA in the collector current. So the NPN transistor is being used in active mode, not as a switch, correct?
  5. Ron H

    AAC Fanatic!

    Apr 14, 2005
    The forward voltage drop of an LED is not 0.7V. It depends on the color of the LED. Other than that, your math is correct, but you should never depend on beta to set current, as its value varies widely from device to device, with temperature, with Vce, etc. You might as well drive the anodes with an unknown-value resistor.
    You need a saturating PNP, as SgtWookie recommended.
  6. SgtWookie


    Jul 17, 2007
    Ron_H basically gave you "the scoop".

    To expand on it a bit more though, with a 7-segment display, you'll have a varying number of segments turned on depending upon what number you are displaying. For example, to display a "1" requires segments B and C to be lit, while an "8" requires all 7 segments lit.

    Let's say that your NPN transistor with it's 150k Ohm base resistor is an ideal transistor with a fixed beta of 200 that never changes (they don't exist, but this is theoretical) and you managed to find a 7-segment display with a Vf of precisely 0.7v that doesn't change with current. (they don't exist either, but this is theoretical).

    So, segments B and C are turned on to display that "1". You're sourcing 4.8mA from the NPN transistor, so the two segments get 2.4mA each.

    Now you need to display an "8", so segments A through G are turned on. Each segment gets 4.8mA/7 or 0.686mA, and the display looks very dim.

    This is why each segment needs it's own current control. The common anode supply must be a saturated switch, able to carry enough current to supply all segments simultaneously, including the DP, with minimal change in Vce.

    Now, your actual Vf for your display will vary. You will need to look in the datasheet for your displays' specifications.

    However, if you can't find a datasheet for it, you could assume a Vf of 1.7v @ 15ma; that would be for an older red 7-segment display. You can assume the Vce of the PNP switch will be <0.2v, so you can even omit that from the calculation.
    Rlimit >= (Vcc - Vf_LED) / 15mA
    Rlimit >= (5v - 1.7v) / 0.015
    Rlimit >= 3.3 / 0.015
    Rlimit >= 220 Ohms.

    So, 220 Ohms should be safe for both your uC and the display(s) you wish to drive.

    Keep in mind that the I/O pins on a PIC uC are limited to 20mA source/sink. There is also a total package limit on current source/sink that you must stay below. You will need to consult the datasheet for the PIC you are using to determine it's limit. See the "Electrical Specifications" section.