Driving 7 segment display with NPN transistors

Discussion in 'The Projects Forum' started by Firestorm, Nov 23, 2009.

  1. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    I'm trying to drive 7 segment displays(common cathode) with NPN transistors. The datasheet for the 7 seg suggests 2.25 V drop and 20mA.
    With that said, the board that I am using outputs ~3.3V and about 3mA. I already have a bunch of these NPN transistors, just need some advice on how to connect it. Thanks.
     
  2. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, there's good news and bad news.

    The good news is that you know what the specifications for the 7-segment displays are.

    The bad news is that they are common cathode.

    This would be just fine if you had a high-side driver for the individual anodes of the 7-segment display, but I'm assuming that you don't.

    You can use the NPN transistors to sink current from the common cathode when you want to select an individual 7-segment display if you are multiplexing them.

    However, you will need PNP transistors in addition to the NPN transistors in order to source current to the anodes of the displays.

    You will also need individual current limiting resistors for the anodes of the display; one per segment. If you are multiplexing the displays, you will need just one current limiting resistor for the same segment in all of the displays. If you are not multiplexing the displays, you will need one current limiting resistor per segment per display.

    The value of the current limiting resistor will depend upon your Vcc/Vdd.
    Rlimit >= (Vcc_Vdd - Vsat(NPN_cathode) - Vsat(PNP_anode)) / Desired_Segment_Current
    You will also need current limiting resistors on the bases of each NPN and each PNP transistor.

    You may find it a bunch easier to just use Darlington arrays and Darlington Source arrays.
     
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Here is a high-side source-type driver IC that Digikey stocks:
    http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=620-1120-ND
    This will really simplify the driving of your anodes; there are eight Darlington source drivers in one 18-pin DIP package.

    You will still need current limiting resistors, but all of the individual NPN/PNP transistors and base resistors go away on the anode driving side.
    The only real drawback is the Vce(sat); it'll be somewhere between 1.3v and 1.6v for a 20mA load.

    If you want a similar driver for the low side, you could look up ULN2003 or ULN2803; but probably won't be worth it unless you have more than 3 displays to drive.
     
  4. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    Thanks SgtWookie.
    I knew I could do it with PNP, just trying to use what I had. I am multiplexing the displays (there are 5 of them). I will see what I else I have laying around(possible order a driver IC), and try to draw up something today. Thanks again.
     
  5. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Well, you didn't say what part number(s) your NPN transistors are.

    Since your board only outputs 3.3v @ 3mA, you will either need to use Darlington transistors or the drivers I mentioned, especially for the common cathode.

    For a transistor to be well saturated, it needs 1/10 the collector current as the base current.
    If you were displaying an "8", all seven segments would be lit. Let's say you were running them on 15mA current. 7 x 15mA = 105mA current for the collector to sink, you would need 10.5mA base current. You're short about 7.5mA.
     
  6. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    sorry about that. the transistors are 2n3904.
    so what you are saying is that I should probably use the driver you mentioned?
     
  7. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    I have enough GPIO ports on the board, so i could drive each segment with it's own port. This would prevent the circuit from having to push the 105mA and only need to boost the current for each segment. Would that make darlington pairs more beneficial?
    Thanks again for the help.
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    OK, 2N3904 transistors are rated for 200mA collector current, but they really "run out of steam" at about Ic=100mA.

    If they were PNP 2N3906 transistors, you could use them to source current to the anodes; but... you'd still need 2N3904's to sink the current from their bases.

    The driver I suggested would make things a heck of a lot easier.

    If you went with using discrete transistors, for each of the seven segments, you would need:
    1) A base limiting resistor for an NPN transistor connected to the output pin.
    2) An NPN transistor, emitter to ground, base to the other end of above resistor.
    3) A PNP transistor, base connected to the collector of the NPN transistor via a current limiting resistor, with a 1k pull-up resistor to Vcc; emitter connected to Vcc.
    4) A current limiting resistor for the display segment.
    Two transistors, 4 resistors per segment; total of 14 transistors, 28 resistors; 42 parts, 98 connections to solder - for the anode side of the 7-segment displays.

    With the driver IC, you just need to add one current limiting resistor for each segment; that's a total of 8 parts, and far fewer connections to make.
     
  9. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You need to decide how much current you want to flow through each segment of the display.

    Since you are multiplexing them, only one display will be on at a time.

    The common cathode will need to sink the combined current for the display that's selected. You will need to use a transistor or Darlington to sink the current.
     
  10. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    If I use the chip that you suggest (which sounds way easier), I would have the 2n3904s to sink the current from the common cathode. Then have the GPIO connected to the input of the chip, and the outputs connected to the display with resistor in between?
    The datasheet for the chip shows that the input having a max input current of less than half a mA. Wouldn't that be a problem? Would the easy solution be to cut the current with a resistor off the GPIO port connected to ground or am I reading the datasheet wrong?

    I don't really have a preference on how much current runs through each segment. The datasheet showed the 2.25V, 20mA. Brightness isn't a big factor, just as long as they light up. Thanks again for your help, it's been wonderful.
     
    Last edited: Nov 23, 2009
  11. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    You would have to connect two 2N3904s in a Darlington configuration (per display) in order to sink enough current. Otherwise, your 3mA 3.3v signal won't be enough.

    Make a schematic of what you are considering.

    Don't worry about the input current of the source array. It has built-in resistors to limit that.

    Well, you have to make a choice. I suggest you keep it under 20mA. 15mA is a good target.

    However you choose to drive them, and whatever your Vcc is, you will need to calculate the total voltage drop for the LED segment, the Vce of the high-side driver, the Vce of the low side driver, and subtract all that from your Vcc. You should have at least 1v left over.

    Then you divide the leftover voltage by the current you want; and your current limiting resistor needs to be at least the result of that equation.
    Basically:
    Rlimit >= (Vcc - (Vce(upperdriver) + Vce(lowerdriver)) / DesiredSegmentCurrent
    For DesiredSegmentCurrent, use 0.015A
     
  12. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    I've attached what I've got so far.
    I'm unsure about what the voltage is coming out of the chip. I assume the lowerdriver voltage would be the 3.3V. I also don't have the resistor values because of this. The drop from the 7 segment display is 2.25V I believe. The datasheet for those is here:
    http://datasheet.octopart.com/SC03-12HDB-Kingbright-datasheet-583848.pdf

    What all am I missing? Thanks.
     
  13. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    That's pretty much it.

    You will lose somewhere around 1.3v to 1.6v across the source Darlington array.
    Count on about 1.3v for now.

    You'll probably lose about 1v across the 2N3904 Darlingtons.
    Your LED displays have a Vf of 2.2v at 20mA.
    Looks like you want to use 5v for your Vsupply.
    So, 5v - (1.3v+1v) = 5v-2.1v = 2.9v
    2.9v-2.2v = 0.7v. Kind of close.
    0.7v/15mA = 46.66 Ohms. 47 Ohms is the closest standard value.

    Use 680 Ohms for the 2N2904 Darlington base resistors.
     
  14. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    Would it be better to bump up the source voltage to 6.
    With you calculations, it would actually be 0.5V/15mA which gives you around 33 ohms.
    I don't see anything wrong with a voltage increase, just wanting to double check. This will change the resistor on the anodes, but will it still be 680 for the common cathode?

    Thanks.
     
  15. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    I don't get how you came up with that. Perhaps I miscalculated when I was tired, and I'm tired again this evening.

    You don't use the 680 Ohms on the common cathode; the common cathode is connected directly to the 2N3904 Darlington collector.

    The 680 Ohm resistor is used as the base current limiting resistor for the 2N3904 Darlingons.
     
  16. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    That should be 2.7V I think.

    I was referring to the common cathode as the output from my GPIO ports, going into the base. I just worded it wrong, sorry about that.

    So 6 V should do the trick? I ordered a couple of those chips yesterday, so hopefully this will work out great. Thanks for all the help. I will post a full schematic when I finish it.
     
  17. Firestorm

    Thread Starter Senior Member

    Jan 24, 2005
    353
    0
    [​IMG]

    Just wanted to show the scoreboard completed. Thanks for all of your help SgtWookie, it was extremely helpful. The ribbon cables run to a renesas m16c board.

    Thanks again for all the help.
     
  18. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Sorry I missed your prior post, but looks like you got it right. There certainly have been a lot of requests for help lately, and I just can't keep up with everything.

    Glad you got it working well. :)
     
Loading...