Driving 7 segment displays via transistors - Page 1
Forum section: electronics / beginners

author: tyguy2
author_rank: Unknown
timestamp: April 17, 2020, 04:32:23 am
content: Hello all,A bit of a simple question, I just wanted to check to ensure this works before I spend the time assembling it. I've currently got a project that has 4 common cathode 7 segment displays. I've been driving them directly using a SAMD21G, using the GPIO pins of the microcontroller to both source and sink the current (Picture attached, please excuse how bad it looks). I need to make these segments larger, however. I've decided on a new segment, but the forward voltage is 8v and the current draw is around 20ma, much higher than what the SAMD21G can source or sink. My main question is, can I use a few BJT's in the configuration I've drawn in the 2nd attached photo? I would still be multiplexing each segment, just with transistors sourcing and sinking current, correct?Thanks,Tyler

author: greenpossum
author_rank: Frequent Contributor
timestamp: April 17, 2020, 04:56:00 am
content: Does your SAMD21G pull up to 8V? If not, you will not be able to bring the emitter past the SAMD21G output voltage - 0.6V because the anode transistors are in emitter follower configuration.

author: Ian.M
author_rank: Super Contributor
timestamp: April 17, 2020, 05:01:28 am
content: No. The SAMD21G is a 3.3V MCU, and with a 3.3V logic '1' on the base, using your circuit you'll only get approx 2.5V at the emitter of each anode driver transistor when its on, far less than you need for the LEDs. The fix for that is a level shifter, to get the control signal up to the LED supply rail.The current limiting resistor is in the wrong place - they need to be in series with the individual segments to set a fixed currentPER SEGMENT, not in the common, otherwise '1' will be far brighter than '8' and segment brightnesses within '8' will also be uneven.Also, you need quite a bit more than 8V to power the LEDs to allow for voltage drop across the switching transistors and current limiting resistors. A 9V supply would be marginal even if you used MOSFETs, and you'll need more headroom for BJTs, especially since if using BJTs you'll probably want to use Darlingtons for the common cathodes as to display an '8' they have to carry seven times the segment current, (eight if the decimal point is also illuminated) and providing enough base current to guarantee saturation of a simple NPN will probably exceed the output current capability of the SAMD21G.

author: Zero999
author_rank: Super Contributor
timestamp: April 17, 2020, 05:02:12 am
content: The connection to the anodes won’t work because the transistors are configured as emitter followers. When the transistor starts to turn on, the emitter voltage rises, cutting off the base drive. The classic way to do this is to use a PNP and NPN transistor, but it’s a pain as you need two transistors for each LED.

author: Peabody
author_rank: Super Contributor
timestamp: April 17, 2020, 02:55:45 pm
content: I think the part shown in your third picture is common anode. Is that what you intend? If so, it might be a good bit simpler, with a lower parts count. You would only need four NPN/PNP pairs on the digit anodes, and all eight segment cathodes would just need a single NPN each.Or, actually, you might even get away with sinking the cathodes directly. But you would need to be sure that your supply voltage is no more than 3.3V above the voltage drop across a segment's diodes. When the digit is turned on, but a segment is not selected, the voltage on that segment's SAMD pin should be no more than 3.3V (or I guess really 3.8V). Well, I'm not at all sure this would work, but you might play with it and see.Edit: I shouldn't have said "directly" connect the segment cathodes to the processor pins. You would need a resistor for each, but maybe not a transistor.

author: Zero999
author_rank: Super Contributor
timestamp: April 17, 2020, 04:27:25 pm
content: A common anode device would be easier to control.Here's the circuit I was describing above to control the high side. Unfortunately it uses two transistors and resistors per channel, so isn't the most compact solution.

author: tyguy2
author_rank: Unknown
timestamp: April 17, 2020, 06:16:39 pm
content: So if I understand correctly, something like this would be able to drive the each digit?

author: rrinker
author_rank: Super Contributor
timestamp: April 17, 2020, 06:39:23 pm
content: There are MOSFETs with 3.3V gates - would that work instead of a BJT?

author: Ian.M
author_rank: Super Contributor
timestamp: April 17, 2020, 06:42:16 pm
content: Yes for a commonANODEdisplay with a Vf well under 4.5V that is bright enough with only 2.5mA If per segment.*ABSOLUTELY* *NOT* for your 8V Vf 20mA If commonCATHODEdisplay.The high side Q1,Q2 circuit is fine for your display except an 8V supply isn't high enough for a 8V Vf display, and the segment current limiting resistor needs to be in series with Q2's collector and chosen to permit 20mA If. However the low side driver is hopeless - there's no way you'll get 140mA through it for an '8' when that digit is selected.Also if you want constructive criticism rather than laughing and finger-pointing, please give each individual component a unique designator. No schematic should have two instances of R1 or Q1!rrinker's MOSFET suggestion is well worth considering. You'll still need a level shifter for the high side drive but at least it will need far fewer resistors and you'll probably be able to get away with a supply rail as low as 9V.

author: Zero999
author_rank: Super Contributor
timestamp: April 17, 2020, 07:03:23 pm
content: Ian, all he's obviously done is just copy my circuit into a paint program and modified it, so of course the designators will be duplicated.Quote from: tyguy2 on April 17, 2020, 06:16:39 pmYes, but as mentioned above, with 1k emitter resistors, the transistors will act as current sinks.

author: Ian.M
author_rank: Super Contributor
timestamp: April 17, 2020, 07:58:56 pm
content: Quote from: Zero999 on April 17, 2020, 07:03:23 pmEven back in the days before GUI graphics programs when I was literally cut and pasting schematics, with an Xacto knife, a steel ruler and re-positionable spray glue, I always updated the reference designators on any schematic that had them. If one is actually using a paint program, there is no excuse. There's even a convenient '3' in the transistor part number so no need to try and match fonts.

author: tyguy2
author_rank: Unknown
timestamp: April 17, 2020, 08:43:54 pm
content: Quote from: Ian.M on April 17, 2020, 07:58:56 pmI honestly don't think it's that big a deal, it was just a rough MS Paint sketch, I wasn't even thinking about component numbering. I feel like me understanding the concept is a tad more important than numbering my transistors correct?Quote from: Zero999 on April 17, 2020, 07:03:23 pmWould that matter if they were sinking current? The SAMD21 GPIO pins can supply and sink up 4mA, I believe, which is why I need to use the transistors in the first place. If I were to MOSFET's in place of this, I'm sure that would solve the current draw from the GPIO issue, but would 3.3v be a high enough voltage to drive them?

author: Ian.M
author_rank: Super Contributor
timestamp: April 17, 2020, 09:10:30 pm
content: Quote from: tyguy2 on April 17, 2020, 08:43:54 pmContrary to your feelings, it *IS* a big deal. I'll attempt to explain.The problem with duplicated reference designators is the confusion that results when discussing your circuit. If any of us fail to notice the duplication, you wont know which part of the circuit that person is commenting on. You *may* be able to figure it out from the context, but, as you don't yet have a deep understanding of the circuit, that's far from certain. As the complexity of the circuit increases the risk of confusion due to bad designators increases exponentially.A schematic with no reference designators is somewhat better than one with duplicated ones, as that forces commentators to describe the part of the circuit they are discussing more fully, but that takes more time so you'll get fewer replies, and you may find the description ambiguous so will have to waste more time asking them to clarify which component(s) they are referring to. Therefore, as a general rule, if you want the most, best quality replies, make it easy for your readers to comment on your circuit by investing your time(in this case: fixing the duplicated designators)to save their time.I've flogged this horselong enough - if you haven't got it yet, you never will until a manager or instructor in a position of authority over you forces you to grudgingly comply.Your lower Q1 BJT current sink will only sink 2.5mA because of its emitter voltage (determined by the logic '1' output voltage and lower Q1's Vbe), and your choice of a 1K emitter resistor. However at least its an approximately constant current, stabilised against supply voltage variations, provided there is sufficient supply voltage.3.3V logic levels are sufficient to drive very low threshold voltage MOSFETs, but they are a good deal less common than ones that will work with 5V logic levels, and tend to be mostly in SMD packages. A common rule of thumb is that the max. Vgs threshold voltage must be less than half the logic supply voltage. Go to a component distributor's site and do a parametric search for MOSFETs with a 0.9V to 1.6V max. Vgs threshold voltage.

author: Nusa
author_rank: Super Contributor
timestamp: April 17, 2020, 09:25:50 pm
content: As a general rule, GPIO pins can sink more than they can source, which can matter in some designs. Of course your datasheet is the final word for any particular case.

author: Peabody
author_rank: Super Contributor
timestamp: April 17, 2020, 10:56:26 pm
content: For the lower Q1/R1, how about moving the resistor up to the collector, and adding a separate base resistor? The emitter would be connected directly to ground. Then the collector resistor could be chosen for the current needed to light the segment, and the base resistor would match the gain of the transistor.

author: Ian.M
author_rank: Super Contributor
timestamp: April 17, 2020, 11:24:16 pm
content: Yep that works for common anode segment drive, as long as there's sufficient supply voltage and the supply voltage is stable. OTOH if there's plenty of headroom (i.e. Vcc>>Vf), simply dropping the emitter resistor to 120R will give a near-constant segment current of approx 20mA, stabilised against supply variations, and uses one less resistor per segment.For the O.P's original problem, if I wanted to use old-skool bipolar drivers (and had enough headroom to do so), I'd probably use a ULN2003 Darlington arrays for the common cathodes, with an UDN2981 equivalent to level shift and high side drive the segment anodes, and a current limiting resistor for each segment position. UDN298x clones are getting pretty rare, but Microchip Technology (ex Micrel)'sMIC2981is still available. If you have problems sourcing the MIC2981 locally, you *could* use another ULN2003 as a level shifter for the segments, then discrete PNP output transistors, but that needs a lot more resistors.Otherwise a modern SPI interface constant current sinking dedicated LED driver with enough outputs for all the segments of all the digits, + common anode LEDs would be a much better choice.