2
\$\begingroup\$

This is a followup to my question https://arduino.stackexchange.com/questions/98809/difference-between-using-gnd-and-digital-low-for-7-segment-display-pin which should've been asked here as it turns out not to be unique to arduino's pins.

I am using this 4-digit 7-segment display.

segment pinout

So my circuit is basically 220 ohm resistors for all the segments (display pins 6 through 16 on the bottom each go through a resistor before going to a digital output pin on the arduino)

I read online that each segment should have its own resistor instead of having one resistor for all to maintain even brightness. The segments are rated for max 25 mA. Assuming the digital pins output 5V, this requires resistance of 200 ohms I think? Well I don't really know because there are multiple resistors in parallel. I don't understand how the current per pin adds up.

Display pins 2-5 are directly connected to arduino digital pins 2-5. The reason I did this was so I could multiplex which pin is LOW for each digit.

I received this answer, which I have several closely related followup questions for on the calculations.

Each LED has a "forward voltage" that depends on the specific model, roughly on its color and technology. The data sheet tells us 4.0 V typically at 20 mA (for the digits, as they have 2 LEDs in series). It raises with the current, but not linearly, to about 4.05 V at 25 mA. Please be aware that these are typical values, the concrete values can differ a lot!

Assumed that the Arduino's pin would output 0 V for LOW and 5 V for HIGH, which is idealized, the remaining voltage at the resistor is about 1 V. Divided by 25 mA results in a resistance of 40 Ω.

Do we divide by 25 mA if we wanted to use that current and find the resistance? Suppose I made no changes and left my 220 ohm resistor. Then the current across the LED is 4.5 mA, which is way below the max, correct?

Now the multiplexing comes into play. Since you use 4 digits, most probably each of them is driven roughly during 1/4 of the time. To have the average of 25 mA, you need to multiply the current by 4, giving 100 mA. The resistor will have 10 Ω then.

For multiplexing, does it mean "multiply by 4 to get the same average current as if the digit were continuously powered?" Otherwise, I don't see why I would need an average 25 mA across an entire multiplexing cycle. My thought was that 1/4 of the time, there is 25 mA through the segments, then 3/4 of the time it is off. The brightness is fine for my purposes.

When multiple segments are on per digit, the HIGH side of each segment still carries 100 mA as calculated above. But on the LOW side (the common cathode) the current is the sum of all driven segments, up to 7. Outputting an "8" will result in 700 mA!

The pins of your Uno cannot source or sink a lot of current. If you try to do more, real world effects according to physics jump in and make the mental model invalid. According to this answer on SE/EE, the maximum current per pin is 40 mA.

If the current is higher, a LOW will not hold the voltage near GND. It will be significantly higher. The same is true for HIGH. The data sheet of your Uno's MCU will tell you more, look for "pin driver strength".

This reduces the usable voltage on resistor and LEDs. This leads to less current, until some balance point is reached. Please be aware that you are using the device outside the specifications here, which could damage it permanently.

If each arduino COM pin can only provide 40 mA, then when outputting an "8" each segment will only get 40 / 7 = 5.7 mA. Is it saying the circuit will change LOW voltage until it gets say 25 mA per segment, or the segment will simply only get 5.7 mA? I don't think I am pulling anywhere near 700 mA in this whole display.

Edit: I expected the 4.5 mA would be dim, but it's actually reasonably bright. I tried measuring the current but I think my multimeter is broken for current because it reports 0.0 mA always. I also tried voltage and found 1.6 V, which would make Vf about 3.4 V.

\$\endgroup\$
6
  • \$\begingroup\$ How important is it that each segment "appear to humans" as equally bright? (For example, aircraft instrumentation manufacturers consider it extremely important. Customers complain bitterly, otherwise.) If you don't care much, then that's one thing. But there are a lot of concerns that come to mind reading that you are using a 5 V rail, MCU I/O pins directly at the cathodes, using LEDs with compliance voltages near the rail, and accepting the use of resistors on the segments as sufficient current limiters with so little overhead to work on. You may be fine with it. I would not be. \$\endgroup\$ Commented 17 hours ago
  • \$\begingroup\$ If you say you care a lot about the display consistency and quality, then it's on to a different direction and your questions become moot. \$\endgroup\$ Commented 17 hours ago
  • \$\begingroup\$ @periblepsis exaxt brightness is not important, given that this is an arduino project of a toy clock. That being said I have fairly normal vision, and after I fixed the colon always being on I don't see any noticeable difference in the brightness of digits. \$\endgroup\$
    – qwr
    Commented 16 hours ago
  • \$\begingroup\$ Okay. Thanks for saying so. I haven't read the specs and don't want to. But with MCUs, there is usually a sinking current limit (when LO) that is a per pin specification. But there should also be a per port limit spec, as well. And perhaps also an overall spec for the MCU. Have you checked all this? Also, the port pin doesn't know what you are doing. It just responds. If you are trying to sink current in excess of its ability, what happens is that its voltage rises until there's no longer a problem. Which also means less current. But not in a predictable way, when exceeding. \$\endgroup\$ Commented 16 hours ago
  • \$\begingroup\$ I don't know what you mean by port. The only port I am using is USB power. With that, the overall pin current max is 200 mA. If my new calculation of 4.5 mA per segment is correct, this should not exceed the overall max current. \$\endgroup\$
    – qwr
    Commented 15 hours ago

2 Answers 2

3
\$\begingroup\$

First, you never want to use a device at the max rating, so designing for 25mA per segment is wrong. You’ll want to leave some room, run them at maybe 10 or 15mA, or you could experiment to see what the lowest current you can use is and still have them bright enough.

Second, since the cathodes will have the combined current of all the segments in a digit you don’t want to drive it directly from an MCU output, instead use a transistor. This is how LED displays have been done for as long as they’ve existed. 5V displays commonly use a 330 or 470 ohm resistor for each segment and a 2N2222 or 2N3904 for each digit.

\$\endgroup\$
4
  • \$\begingroup\$ Ok, but this did not answer my questions about the calculation. \$\endgroup\$
    – qwr
    Commented 15 hours ago
  • \$\begingroup\$ @qwr Ok, I’ll update when I can get on my desktop. \$\endgroup\$
    – GodJihyo
    Commented 14 hours ago
  • \$\begingroup\$ I used 220 ohm resistors because I originally thought they were sufficient. My question is: Suppose I made no changes and left my 220 ohm resistor. Then the current across the LED is 4.5 mA, which is way below the max per segment, correct? The total draw per digit could be 4.5 * 7 = 31.5 mA, which is still more than the arduino pin should provide. \$\endgroup\$
    – qwr
    Commented 6 hours ago
  • \$\begingroup\$ Tip: voltage is measured across a component. Current flows and is measured through the component. \$\endgroup\$
    – Transistor
    Commented 2 hours ago
1
\$\begingroup\$

5V supply with a 4V Vf and a desired If of 25mA does indeed require a 40 ohm resistor: (5-4)/0.025; no idea where 200 ohms came from.

However, @GodJihyo is right: 25mA is the absolute maximum rating, which should be interpreted as "never exceed", not "continually operate at". Indeed, the luminous intensity is quoted at an If of 20mA, so your resistors now would be 50 ohms.

Multiplexing means you only activate one digit on the display at a time. It cuts down on wiring complexity since you can wire all the anodes for the same segment on each digit together (segment "a" of digit 1, segment "a" of digit 2, etc) and, by only connecting the cathode of one digit to ground at a time, only that digit will display the numeral. Instead of requiring seven data lines multiplied by the number of digits, you only need seven data lines plus the number of digits, so 11 data lines for a 4-digit display (not counting colon, decimal point, etc) instead of 28 data lines.

Seven segments at 20mA gives 140mA, which is close to, but not exceeding the package limit of 200mA for the "standard" Arduino (you haven't stated which one you have). 140 mA cannot be sunk (fed into) any of the Arduino pins, so you will need to outsource this to another component like a 2N3904 or a 2N7007. Neither of them are perfect shorts from collector to emitter (or drain to source) - the cathode of the LEDs won't be at 0V, it'll be at ~0.3V or so - so your resistors will need to drop to ~35 ohms to compensate.

That said, the datasheet says the Vf could be as high as 5.2V, in which case the segment won't light at all. I recommend moving to a dedicated driver chip and a higher supply voltage.

\$\endgroup\$
3
  • \$\begingroup\$ I used 220 ohm resistors because I originally thought they were sufficient. My question is: Suppose I made no changes and left my 220 ohm resistor. Then the current across the LED is 4.5 mA, which is way below the max per segment, correct? The total draw per digit could be 4.5 * 7 = 31.5 mA, which is still more than the arduino pin should provide. \$\endgroup\$
    – qwr
    Commented 6 hours ago
  • \$\begingroup\$ 4.5mA is probably too low to be usably visible, but you could try. It also still does not help you if the Vf is high since that's just a manufacturing tolerance thing. And yes, it's still more than your Arduino pin can sink so it really doesn't do anything for you. \$\endgroup\$
    – vir
    Commented 5 hours ago
  • \$\begingroup\$ I expected the 4.5 mA would be dim, but it's actually reasonably bright. I tried measuring the current but I think my multimeter is broken for current because it reports 0.0 mA always. I also tried voltage and found 1.6 V, which would make Vf about 3.4 V. \$\endgroup\$
    – qwr
    Commented 3 hours ago

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.