TLDR: Circuit #2 is correct.
It is incorrect to use current-limiting at the LED anode terminal as circuit #1 does, via R8, R10, R12. If you display a digit with many segments lit (like "8") then segments will be much dimmer, compared with a digit like "1" where only two segments are active - or even worse, where "." is displayed. Current limited by R8 is divided between many? of the seven segments.
7 x 100 resistors of circuit #2 add extra parts, these current-limiting resistors ensure that each of seven segments gets similar current, regardless of how many are active.
Be aware that the PNP transistors of circuit #2 are saturated switches.
Considering AT89S52 feeble output drive, one might wish to specify high-efficieny common-anode 7-segment LEDs. When digits are multiplexed, peak current escalates when more digits are added...even with high-efficiency LEDs, microcontroller current limits also limits number of digits that can be multiplexed, especially if the expected ambient lighting is bright.
Static current limit for this chip mean that PORT_0 is preferred for pulling LED digit cathodes to Vss:
- PORT_0 static current limit: 26mA total (all 8 active)
- PORT_1 static current limit: 15mA total (all 8 active)
- PORT_2 static current limit: 15mA total (all 8 active)
Feeble drive current makes me reconsider Circuit #1 using EdC's suggestion in a good answer where pulse-width-modulates the ANODE drive transistors (Q1, Q2, Q3). By allowing more on-time for digits where more LEDs are active, current is limited (as per data sheet specs) while apparent digit brightness does not depend on which of 10 digits is displayed:
- digit 0 drives 6 LEDs (3.29mA per LED)
- digit 1 drives 2 LEDs (7.44mA per LED)
- digit 2 drives 5 LEDs (3.81mA per LED)
- digit 3 drives 5 LEDs (3.81mA per LED)
- digit 4 drives 4 LEDs (4.54mA per LED)
- digit 5 drives 5 LEDs (3.81mA per LED)
- digit 6 drives 5 (or 6) LEDs (3.81mA or 3.29mA per LED)
- digit 7 drives 3 LEDs (5.64mA per LED)
- digit 8 drives 7 LEDs (2.58mA per LED)
- digit 9 drives 5 (or 6) LEDs (3.81mA or 3.29mA per LED)
- decimal point alone drives 1 LED (10.99mA)
A LTspice simulation of circuit #1 yielded LED current shown above. It was assumed that equivalent resistance of PORT_? drive was 75 ohms...data sheet suggested a maximum value of 140 ohms:
It is assumed that each LED is exactly matched with the other 7 in each digit. The significant ON resistance of PORT_? drive makes LED matching less significant. Maximum port current is more in-line than Circuit #2. But the big question is: are digits bright enough?
One would assume that keeping
current x time product constant should be the goal to maintain digit brightness constant...that's an extra lookup table. In this way, peak current required of microcontroller port outputs can be limited.
The LTspice run of circuit #1 suggests that when all eight LEDs are active (to display digit "8." ), you'd want to dally about three times longer than when two LEDs are active (to display digit "1").
Such wide variance in MUX display times wants slow display periods for each of three digits, yet fast enough to prevent flicker. For three digits, slowest MUXing rates would apply for a display of 8.88 or 88.8. If all three digits are refreshed 50 times-per-second, you'd want each of those 8's to be fully ON for about 6.66ms.
But a display of 111 would shorten the period while each digit is lit - 2.22ms for each of three digits. These three digits would be still be refreshed 50 times-per-second: each digit 2.22ms ON, and 4.44ms OFF. At least one microcontroller timer might be used to control ON/OFF times.