Circuit for quad 7 Segment display

Hi,

I'm a complete newbie so I'm doing some basic Hello World style projects with the different pieces I have bought.

I wanted to set up a quad 7 segment display (3641AS) and just print some numbers to it. I can understand the logic of how to do this but unsure about the circuit setup. So I started by just displaying one digit.

The 3641AS is common cathode so I connected the D1 pin to Gnd and ignored the other digits. I connected each of the 7 segments via a 200Ω resistor to I/O pins on the Arduino. This worked as expected; with some code I could display any number I wanted on digit 1.

One thing to note; I went with the 7 resistors on the LEDs instead of one on the common because I read elsewhere that it's better. Other posts here seem to support that saying this avoid different brightness's of the the led segments (which I can understand).

This is where things get confusing for me. So now I want to change the circuit so that can change which digit I'm lighting up. So I move the D1 from Gnd to an I/O pin. The plan is by setting that pin LOW I can light up that digit.

However, then pin would now have ~84mA going into it when set LOW. This was measured with a multimeter. But I/O pins on an Arduino should have a maximum of 40mA right?

Does that mean I need resistors on the segment pins and on the common pin (D1-D4 this case)?

And if so, how do I calculate the value of the resistor? I'm familiar with Ohm's law and I know the current at that point (~84mA). But not sure where to go from there. In case it's relevant the voltage drop across any of the 7 resistors plus segment LED is ~4.5V.

Hopefully that all makes sense,
Cheers!

Does that mean I need resistors on the segment pins and on the common pin (D1-D4 this case)?

No, unless you want really dim LEDs.
It means that you needs an N channel MOSFET between each digit's common cathode and ground. Each MOSFET needs a separate output pin to drive its gate and you set one of them high, with the others low, at a time.

rob89:
However, then pin would now have ~84mA going into it when set LOW. This was measured with a multimeter. But I/O pins on an Arduino should have a maximum of 40mA right?

And that is the absolute maximum recommended, common (is it?) sense dictates that you work at much less, between 20 and 30 mA perhaps. So if you limit the segment current (by the segment resistors of course) to 3 mA, that would be sort of workable.

The reason not to use a common resistor for the digit remains, it will tend to "share" the current between the digits so that a "1" will be far brighter than an "8". So if you use the 1k resistors for the segments you can control the digits by directly connecting them to ATmega328 pins.

Even then, the ATmega328 pins have an inherent internal resistance of about 45 Ohms, so you still get brightness variation. The calculation of the resistors? Ignoring the internal resistances of the microprocessor, the LED drops about 2 V, leaving 3 V for the resistor, 3 V / 1k is 3 mA.

Now this is of course, as you said, a "basic Hello World style project" for educational purposes to understand multiplexing. You would definitely not use this in a serious project, you would use a MAX7219 IC which is a multiplexing display driver which performs all the multiplexing for you, you just send it the data once, each time you need to change what is displayed, and it operates the displays (and you only need one resistor).

I actually suggest you get a couple of these or alternatively the matrix displays, cheaply on Aliexpress to play with. :grinning:

Do you already have a uln2003 or uln2803? These are rather old chips now with some limitations compared to modern alternatives, but they are still very common, so if you have one to hand, it will do for this purpose. It is a simple chip, really just 7 or 8 transistors in a package. Darlington pairs of transistors, in fact, which means they do have quite a large voltage drop, compared to the type of transistor Perry suggested. So when you calculate your led series resistors using Paul__B's formula, the led segments will drop around 2V, and the uln chip around another 1.5V, leaving only around 1.5V drop across the series resistors.

These are rather old chips now with some limitations compared to modern alternatives.

Is there a modern alternative? I've seen ones with I2C interfaces and probably SPI, but never just, say, MOSEFETs equivalent to Darlington pairs.

PaulRB:
Do you already have a uln2003 or uln2803? These are rather old chips now with some limitations compared to modern alternatives, but they are still very common, so if you have one to hand, it will do for this purpose.

Frankly, I feel they are better never mentioned as with obsolete parts in general! Only causing trouble down the line. :roll_eyes:

Well, I was careful not to suggest the OP go and buy one, only use if already had that part. They are common in many Arduino starter kits. And it would work in this circuit, if that were the case, wouldn't it?

In terms of a modern equivalent, someone mentioned one in a topic just a few days ago. Wasn't that you @Paul__B?

I guess in modern circuit manufacture, where pick-n-place machines have replaced hand-assembly, getting component count down to minimum is no longer always the same thing as getting cost down to a minimum. Placing a dozen discrete components, which can be purchased very cheaply in large volumes, may be cheaper than placing a single more expensive component such as a modern equivalent to a uln chip.

rob89:
One thing to note; I went with the 7 resistors on the LEDs instead of one on the common because I read elsewhere that it's better. Other posts here seem to support that saying this avoid different brightness's of the the led segments (which I can understand).

That would be the case if you are displaying one digit continuously, or multiplexing one digit at a time. But you could also multiplex one segment at a time, and that would let you eliminate all the resistors on the segment lines, and just have a single resistor on each common cathode line coming back to its I/O pin. No transistors would be needed. A segment line would have to source at most four segments, and a common cathode line would never need to sink more than one segment. But the segments would need to draw more current when they are on because they will be on only 1/7 of the time instead of 1/4 of the time. Whether this will work will depend on how much current is needed to give you adequate brightness, but it would give you the same illumination on each segment no matter how many are lit up, and would save on parts. And the SevSeg library supports it.

Thanks for the replies folks! Some great advice.

I'm going to buy some MOSFET as Perry suggested (don't have any uln2003 or uln2803 unfortunately) as I want to get this method working even if it's only as a learning experience. But I'll also invest in some MAX7219 drivers and some dot matrices to play around with too.

As for the segment multiplexing suggestion, that sounds interesting but I'll leave it for another time!

PaulRB:
In terms of a modern equivalent, someone mentioned one in a topic just a few days ago. Wasn't that you @Paul__B?

Maybe, I don't recall but in any case that would be the TBD62003AFG.

This is a seriously useful part, clearly better than eight separate FETs, but a TPIC6B595 (shift register/ driver) is probably more readily available (or cheaper) and would be a better exercise to program it so that you only need the three control pins rather than 7 or 8.

Paul__B:
TBD62003AFG ... is a seriously useful part, clearly better than eight separate FE Ts,

It only has 7 channels. Perhaps there is an 8 channel version.

Yes: TBD62083AFG

Sorry, I had it mis-filed!

TBD62387. No, this one is the non-inverting version.