Author Topic: How to calculate base resistor value for multuplexed 7-segment display?  (Read 5483 times)

0 Members and 1 Guest are viewing this topic.

Offline matrixofdynamismTopic starter

  • Regular Contributor
  • *
  • Posts: 180
The TDSG5150 (data http://docs-europe.electrocomponents.com/webdocs/0e30/0900766b80e30a57.pdf) is a common anode 7 segment dislay.
Therefore, it needs PNP transistors to be turned on when multiplexing displays.

The calculation for current limiting resistor per segment is trivial. However, there is some confusion for calculating the value of a base resistor used with PNP when multiplexing the displays.

Assume transistor being used is https://cdn.sparkfun.com/assets/learn_tutorials/4/2/3/2N3906.PDF

When calculating the base resistor, we assume value of collector current. I assume that this will be for the case when all segments are on. Is that correct? Since this will be a value perhaps close to or bigger than 100mA and we shall calculate a required  base current value from that and worst case beta, what will happen when less segments than maximum are on? Won't that cause current overload and some segment being burnt out since they have more than max of their current through them?

I initially made the base current resistor calculation such that only one segment was on ( a bluder on my part ) giving max Ic or 10mA, then after making circuit I found that a digit 1 formed on the display is bright as it has only two segments on and digit 8 is very very dim. My theory is that the collector current of 10mA is acually being split into eight segments and each becomes dim and when it splits into only 2 segments, it becomes bright. However, this being the case, how do I get constant brightness regardless of how many segments are on? This is confusing me.

What is the correct way to find value of base resistor ?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #1 on: February 05, 2017, 01:20:42 am »
Assuming you are multiplexing the digits, you don't limit the current in the digit drive circuit as that would make '1' far far brighter than '8', as you are seeing.  Each segment driver needs a current limiting circuit - all the same apart from the d.p., which may need less current for the same brightness.   If you are driving the segments direct from logic it could be as simple as series resistors, or you could have a more complex constant current driver circuit.

In the case of a common anode display with BJT drivers, the anode drivers *MUST* remain fully saturated at all times when on.  As a rule of thumb - design for enough base drive for double the max total current for all segments + d.p. on.
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #2 on: February 05, 2017, 01:24:14 am »
Beta is not used when a transistor is used as a saturated switch. The datasheets show that the transistor saturates pretty well when the base current is 1/10th the collector current regardless about how high is the beta when it is not saturated.
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 12298
  • Country: au
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #3 on: February 05, 2017, 01:29:15 am »
The key to success:

Assuming you are multiplexing the digits, you don't limit the current in the digit drive circuit as that would make '1' far far brighter than '8', as you are seeing.  Each segment driver needs a current limiting circuit
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #4 on: February 05, 2017, 01:57:54 am »
Actually, if you study the 2N3906 datasheet closely, you'll see that the VCE_sat rises sharply above about 50mA IC.  That means the transistor isn't man enough for the job if you need more than 6.25mA per segment unless you have a lot of headroom + constant current segment drivers.   You'll also need a heck of a lot of base drive to guarantee saturation , if you are pulsing the current above the display's 25mA continuous If per segment rating.

You've got two choices here if you need more drive - use P-MOSFETs or add some 1A NPN transistors to make Sziklai pairs (Lower VCE_sat than Darlington pairs), as the required base drive will be more than the logic can supply if you simply substituted 1A PNP transistors.
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3382
  • Country: us
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #5 on: February 05, 2017, 03:16:45 am »
You've got two choices here if you need more drive - use P-MOSFETs or add some 1A NPN transistors to make Sziklai pairs (Lower VCE_sat than Darlington pairs), as the required base drive will be more than the logic can supply if you simply substituted 1A PNP transistors.

ZTX549 is a PNP that would work well, but it's probably more expensive than a P-MOSFET.

 

Offline matrixofdynamismTopic starter

  • Regular Contributor
  • *
  • Posts: 180
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #6 on: February 05, 2017, 02:06:07 pm »
The circuit I made basically looks like this:
http://embedded-lab.com/blog/wp-content/uploads/2011/03/Lab11_Circuit_SevenSegmentMultiplexing.jpg

I want to get 10mA per segment. This would be 70mA for a 7-segment display as I am not using the decimal point. I have left the decimal point floating which should be acceptable and not cause latch up or any other anamoly since this is not a microelectronic IC.

Assuming I aim to get 100mA max Ic, this would be no less than 10mA of Ib for saturation, which does seem a lot. If I do use Rb, this would be R=V/I=(3.3-0.6)/0.001=2.7kohm or less. For double the base current, this shall become 1.35kohm. With 0.4V VCE as per the datasheet, then 0.6V across the LED itself, we have 3.3-0.6-0.4=2.3V across the Rs of the LED segment. This gives Rs=2.3/0.001=230ohm.

Now, with each segment having Rs=230ohm, when the transistor is in saturation mode, it should only be able to force 10mA per segment, thus when more segments are on, the Ic will increase to accomodate more segments, 10mA with just one segment and 20mA with two segments and so on. Thus, the Ib can remain same and put transistor in saturation, but the actual Ic will be limited by the Rs and how many segments are being activated, each segment will only let 10mA through due to Rs.

In other words, it is not that the transistor will "force" the 100mA (calculations for saturation) of Ic resulting from 10mA base current through regardless of how many segments are on. It will not happen that if one segment is on, 100mA will be forced through it, and if two segments are on then 50mA will be forced through each. No. Because of limit imposed by Rs.

I hope that my above understanding is correct. Correct me if I am wrong please. Thank you very very very very much, Ian.M said that the VCE rises sharply once the Ic becomes more than 50mA, I am not sure how exactly that is as per the datasheet.
 
And another transistor is perhaps better to get even though when multiplexing the microcontroller will only drive 10mA from one pin for a period of time. I will consider FET as well which I have not done yet. I shall think about it.
« Last Edit: February 05, 2017, 02:10:24 pm by matrixofdynamism »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16620
  • Country: us
  • DavidH
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #7 on: February 05, 2017, 03:38:47 pm »
At a forced beta 10 or 10mA base current with a 2N3906, the saturation voltage difference between 0.2V at 100mA and 0.1V at 10mA is insignificant.  Using a cheap 2N4403 will halve the saturation voltage under the same conditions.  There is no reason to use a more expensive transistor and if the 10mA base current is a problem, then a 2N4403 could be operated at a much lower forced beta with an insignificant increase in saturation voltage.

A cheap bipolar PNP with an even lower saturation voltage like a SS9012, BC638, or BC640 would improve the situation further.  There are a couple of cheap p-channel surface mount MOSFETs which could be used but except for zero gate current, they perform no better.

 

Offline matrixofdynamismTopic starter

  • Regular Contributor
  • *
  • Posts: 180
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #8 on: February 05, 2017, 05:24:07 pm »
@David Hess, please read my previous post. I want no less than 70mA (aiming for 100mA) of Ic.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16620
  • Country: us
  • DavidH
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #9 on: February 05, 2017, 06:00:47 pm »
@David Hess, please read my previous post. I want no less than 70mA (aiming for 100mA) of Ic.

That is *at* a collector current of 100mA.  A forced beta of 10 with an Ic of 100mA is 10mA of base current.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #10 on: February 05, 2017, 06:27:57 pm »
Your base resistor calculation is no good. You are working from my double the base current rule of thumb which is only helpful when the transistor dataseet gives HFE vs Ic, with no saturation graphs.  Fig 13 + worst case HFE @ 10ma IC says HFE could drop as low as 30 @ IC=70mA, so you need 2*70/30 mA Ib, which is 4.66mA. 
I don't know how you got to 2.7K then halved it to 1.35K - a rough estimate for Rb by my rule of thumb would be 850 Ohms.

However the saturation graphs recommend Ic/Ib of 10 so more base drive is indicated.

The PIC supply voltage is 5V.  The PIC datasheet says:
   Parameter D080 Output Low Voltage
   I/O ports, max. 0.6V @ IOL = 8.5 mA, VDD = 4.5 V, -40° to +85°C.

There is no graph.  Extrapolating this to 10mA, as-if it was purely a resistive drop gives 0.7V. 

Assuming you are still using the 2N3906, for 100mA Ic, fig.15 “ON” Voltages gives 1.0V Vbe(sat) @ Ic/Ib = 10.

V(Rb) = 5 - 0.7 - 1 V = 3.3V.
Rb= 3.3V/10mA = 330 Ohms

Now lets consider the LED series resistors.

From the same fig.17, we can read off the expected Vce(sat) for various Ic.  The two extreme cases are two segments lit ('1'): 20mA and seven segments lit ('8'): 70ma.  Vce(sat) @20mA Ic = 0.1V  Vce(sat) @70mA Ic = 0.18V (approx).

The TDSG5150 display datasheet gives Vf as 2.4V Typ, 3V Max. @If=20ma.  Fig 13 refines tht to about 2.2V Typ @If=10mA.  Designing to the typical Vf, and accepting that the current will be less if a higher Vf display is encountered:

For 2 segments lit:
V(Rs) =5 - 0.1 - 2.2 - 0.7 V = 2V
Rs= 2V/10mA = 200 Ohms

Recalculating for seven segments lit:
V(Rs) =5 - 0.18 - 2.2 - 0.7 V = 1.92, round to 1.9V
Rs= 1.9V/10mA = 190 Ohms

Nearest E12 resistor: 180 Ohms

There will be an approx 5% segment current variation between '1' and '8' which shouldn't be noticeable.  All digits should be from the same batch - if not check how well matched their Vf is.  You want them within 0.1V of each other.

Note: If you want to go much higher than 10mA per segment, you are in trouble with the 2N3906.  The PIC simply cant supply enough base current without excessive Vol rise.  We are already extrapolating off the datasheet to get Vol @ 10mA.   You need a transistor with more HFE at large Ic - several good ones have already been suggested, or if you don't care about cost and are only working with what parts you have handy, my suggestion of a Sziklai pair could be used, which gets the base current requirement down to where any low powered CMOS logic could drive it.
« Last Edit: February 05, 2017, 06:35:46 pm by Ian.M »
 

Offline 97hilfel

  • Regular Contributor
  • *
  • Posts: 66
  • Country: it
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #11 on: February 05, 2017, 06:58:43 pm »
Wouldnt it be the easiest way to drive your displays using a common ground module with a 8 bit d-flipflop? then you dont need the multiplexing, just send the flipflop a clock signal and everything is fine, just put a 330 Ohm resistro between each outputpin of the fliflop and the bcd display.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16620
  • Country: us
  • DavidH
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #12 on: February 05, 2017, 08:11:31 pm »
Wouldn't it be the easiest way to drive your displays using a common ground module with a 8 bit D-flip-flop? then you don't need the multiplexing, just send the flip-flop a clock signal and everything is fine, just put a 330 Ohm resistor between each output pin of the flip-flop and the bcd display.

I like chaining 74HC595 shift registers together for this but it quickly gets out of hand compared to a multiplexed design as you add digits.  With modern high brightness LED displays, multiplexing is also a lot more power efficient because the LEDs are more efficient at high currents which would otherwise produce a blinding display.
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5877
  • Country: de
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #13 on: February 05, 2017, 08:21:29 pm »
Somehow the simple task of driving a 4-digit, 7-segment display has evolved (devolved?) into a project approaching the LHC.

Let's relax.

I'd simply drive the anodes with NPN transistors without any base resistor at all (as emitter followers).

You'll need to reduce your segment resistors a bit to compensate for the extra VBE drop, but that's no big deal.

A suitable transistor for this is the BC337.

Done.

 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #14 on: February 05, 2017, 08:35:31 pm »
The easy option is a MAX7219 SPI 8 Digit Seven Segment Display Module from EBAY.
However you wont *LEARN* any electronics that way . . . .

BC337 NPN emitter followers to drive the digit anodes should be OK for a Red display (due to its lower Vf drop), but they are marginal for a Green display.  The PIC16F628A datasheet doesn't have Voh vs Ioh curves, but the PIC16F628 datasheet does, and its characteristics are fairly similar.   You'll drop about 1V sourcing 1mA 10mA from the PIC, as its sourcing capability is much less than the sinking capability and I estimate you'll end up with about 0.7V across Rs with an uncertainty of about a factor of two.  For a one-off where you are prepared to fiddle with resistor values, its doable, but it certainly isn't a production ready design or even one you'd be happy to supply as a kit.

P-MOSFETs would be a much better choice - no more base resistor, the PIC runs cooler and the low on resistance puts a higher proportion of the total drop across the segment resistors where you need it to minimise segment current variation.
« Last Edit: February 05, 2017, 08:51:59 pm by Ian.M »
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 5877
  • Country: de
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #15 on: February 05, 2017, 08:49:24 pm »
Quote
You'll drop about 1V sourcing 1mA from the PIC

No, you won't. The high output voltage is specified (worst case) as VDD - 0.7 V, and that's at a load of 3.0 mA.
A BC337-40 will draw (worst case) 0.28 mA base current at an IC of 70 mA.
I would estimate a port output voltage of VDD - 0.1 V in that case (the MOS outputs are reasonably linear).

« Last Edit: February 05, 2017, 08:52:32 pm by Benta »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: How to calculate base resistor value for multuplexed 7-segment display?
« Reply #16 on: February 05, 2017, 08:58:14 pm »
Typo: I meant 10mA, now corrected.  See FIGURE 18-18 in DS450300C, however you are right, the drop will be a lot lower as I over-estimated the base current.
The higher gain BC337-40 is even more favourable, and I withdraw my objections to your proposed circuit.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf