Connecting a seven segment display to CPLD - Page 1
Forum section: electronics / general

author: garvind25
author_rank: Regular Contributor
timestamp: September 26, 2017, 04:05:21 pm
content: Hi,While connecting a 7 segment display (common cathode) to a coolrunner CPLD, where should I connect the resistor to; in-between the anode terminals and CPLD pins or just one resistor between the common cathode terminal and the gnd? Also, of what wattage should this resistor be of (I dont know of the current of the LEDs in the 7 segment display -- I purchased them from a local shop)Thanks,Arvind Gupta

author: Kleinstein
author_rank: Super Contributor
timestamp: September 26, 2017, 04:28:10 pm
content: For a 7 seg LED display the resistors need to go to the 7+dP segment lines, usually not the common cathode or anode. So it takes 7 or 8 resistors.The size and wattage depends on the LED current needed, the supply and the driver power. In low light application the current might be low (e.g. 1 mA range). Operation in sunlight might need 10 mA or even more. Still at 10 mA and maybe a 2 V drop the power to the resistor is still small.Modern CPLDs / FPGAs tend to run on a rather low voltage which may make it hard to drive LEDs at all. Common anode might have a slight advantage here as the LED voltage might be slightly higher than the CPLDs supply and with some chips the low side drive can be a little stronger.

author: garvind25
author_rank: Regular Contributor
timestamp: September 27, 2017, 04:08:48 am
content: Thanks for your reply. Just curious but to save space on the board, can I not connect a single high wattage resistor at the common cathode, instead of connecting 8 individual resistors (pls see attached pic.) Can that create a problem ?Regards,Arvind Gupta

author: newbrain
author_rank: Super Contributor
timestamp: September 27, 2017, 06:42:41 am
content: Yes you can do it.But there'll be "problems".Consider what happens when the digit 1 is displayed (two segments lit): the current in each segment will be (Vcc-Vled)/2RNow, consider digit 8 (all segments on): the current is now (Vcc-Vled)/7R, 3.5 times less than before.So, the brightness of the display will depend on the displayed value.Moreover, there are small differences in the Vled of each segment, leading to an uneven brightness even between segment in the same digit: the segments with the lower Vled wil tend to gobble up all the current for themselves.Not recommended, if not for a quick check that the logic is working correctly.

author: Kleinstein
author_rank: Super Contributor
timestamp: September 27, 2017, 03:35:21 pm
content: Some CLPD can program / limit the output current. So they may have in internal limit to a suitable current limit and in this case one could get away without any resistor. However one must be sure not to set the current to damaging high values.AS the resistors can be low wattage (more like 10 mW range), one can use a small form factors like 0201 SMD. There usually is place for such tiny parts, though soldering needs a steady hand and good eye sight. With normal LED displays there usually is enough space for at least 0603 form factor.

author: garvind25
author_rank: Regular Contributor
timestamp: September 27, 2017, 05:29:37 pm
content: OK ... then do you suppose that 1Kohm smd resistors will be ok for each segment?Thanks.Arvind Gupta

author: rstofer
author_rank: Super Contributor
timestamp: September 27, 2017, 08:01:49 pm
content: Quote from: garvind25 on September 27, 2017, 05:29:37 pmNo...You need to think about Ohm's Law. If your driving voltage is 3.3V, your LED Vf (forward voltage drop) is, say, 2.0V at an If (forward current) of, say, 15 mA (and this is where you think you have enough brightness) then you do the math.The resistor needs to drop (3.3 - 2.0) volts at 15 mA. R = E / I so 1.3/0.015 = 86 Ohms - call it 100 Ohms.I don't know the Vf and If for your displays. Look the information up in the datasheet.Verify that If is within the capabilities of the pin current for the CPLD. You may need to reduce it to, say, 10 mA.All of the above applies to the case where you are NOT multiplexing digits. If you are multiplexing, you need a different approach.If you look at the upper right corner of page 2, you will see how Digilent multiplexes a 4 digit display (there are two displays on the board) on 3.3V. The display is rated at Vf=1.9V and If=10..20 mA.https://reference.digilentinc.com/_media/nexys4-ddr:nexys_4_ddr_sch.pdfThe display is KW4-281ASBhttp://www.lucky-light.com/LED%20Displays/Four%20Digit%20Display/KW4-281.pdfSo, their 100 Ohm resistor is dropping 3.3-1.9 or 1.4V. The current through each segment is 1.4 / 100 or 14 mA but that is divided by 4 so each segment only averages 3.5 mA. Remember, each digit is only on 1/4 of the time.I'm not sure why their If is so low (and I haven't measured it) but they work fine.In order to multiplex digits, you need some way to control the common cathode. That's what the transistors are all about. They turn on each digit in turn. The pin current would be too high when all 8 segments were on - nearly 28 mA.

author: garvind25
author_rank: Regular Contributor
timestamp: September 28, 2017, 07:16:23 pm
content: Thank you for your reply. while going through the schematic of nexys board, I could see that the common anode terminals were being controlled with pnp transistors + resistors at the base of the resistor. This will increase the hardware on board...I was thinking of another technique to interface the 7 segment units (common cathode) with the CPLD as in the attachment. I have not drawn the other (shared) data lines -- a,b,c...dp. This way I can directly control which 7 segment display unit to enable (by programming the corresponding I/O pin as logic 0 -- to enable or logic 1 -- to disable display unit). The values of resistors can be calculated by knowing the maximum current allowed through an I/O pin (in the worst case, each LED segment will get 1/8 th of this value). If you suppose this technique is OK, then I wanted to know the following:1. How much max. current is allowed per I/O pin of XC2C128 (for 3v3 operation). I could not find the max. value in the datasheet. I need this value to fix the value of theresistors.2. When the programming is done for the pin, I hope it is OK if the pin connected to common cathode terminal is programmed as an output pin (I was wondering if a pinprogrammed as output pin will sink current)Awaiting your reply.Arvind Gupta.

author: rstofer
author_rank: Super Contributor
timestamp: September 28, 2017, 09:35:22 pm
content: https://www.xilinx.com/support/documentation/data_sheets/ds093.pdfPage 10 gives a set of curves for output voltage versus current. Study the graph carefully and you will see that Iol can not be 35 mA before the output that should be 0V is all the way up at 3.3V. So, you darn sure can't sink anything like 35 mA.The logic output current in most of the examples is 8 mA. See page 4, top table.In other words, you will be lucky if the device can drive even 1 segment per pin.For a more complete discussion on reading the graphs, see starting at page 13 here:https://www.xilinx.com/support/documentation/user_guides/ug445.pdfPick a current and you can see what Voh and Vol will be. It's pretty grim!There's a reason we do things the way we do and the folks at Digilent are really good at it.ETA: Yes, pins can source and sink current. Just like it shows on the curves. Note that Iol only has one curve while the various logic voltages have separate curves.

author: garvind25
author_rank: Regular Contributor
timestamp: September 29, 2017, 06:47:29 pm
content: Yes… I went through the graphs of XC2C128 and could see that an I/O pin can source/sink 8 mA current at 3.3v. Also since I want to multiplex 4 units of seven segment display, I can understand that in a worst case scenario, one I/O pin will have to provide current for 4 segments. So if I keep 1.5 mA for each segment and assume a voltage drop of 2.0v for red led of each segment, the total current through the resistor should be 6 mA and the voltage drop across it will be 3.3-2.0=1.3v. So the value of resistor will come up to be 217 or 220 ohms. Also the power handling capacity would be 1.3v X 6 mA = 7.8 mW or quarter watt resistors will do. I hope you find this correct. Also do you suppose that 1.5 mA per segment per unit of 7 segment display is enough?Also to provide selection of seven segment unit, I am considering each common cathode terminal be connected to the collector of an npn transistor, its base being connected to an I/O pin of CPLD through a resistor. To calculate the value of resistor, I assumed BC547 with hfe=110. In the minimum case scenario, only 1 segment of a 7 segment unit will be on. It will provide 1.5 mA current through the common cathode and thereby the collector of the transistor. The value came out to be 242 Kohms. In the maximum case scenario, all 8 of a seven segment unit will be switched on. The current through the common cathode and thereby the collector of the transistor will become 10.5 mA. The resistor calculated was 34.5 K ohms. My question is which resistor value to consider. The nexyx schematic does not mention which pnp transistor was used. So I cannot back calculate for the amount of current per segment for which the resistors were calculated.Looking forward to hear from you.Arvind Gupta.

author: rstofer
author_rank: Super Contributor
timestamp: September 29, 2017, 09:08:48 pm
content: Quote from: garvind25 on September 29, 2017, 06:47:29 pmI don't quite follow this. As I see it you would have 8 pins pulling up on the segments and (optionally) the decimal point. Each pin has only a single LED. The transistors multiplex among the 4 displays so they carry as much as 8 LEDs. Still the CPLD pin only carries 1 LED.QuoteI doubt that 1.5 mA will work. Digilent uses 3.5 mA (average).QuoteI think this is not quite right. Each transistor selects a digit and the digit MAY consist of all 8 LEDs being on at the same time. ETA: I deleted my rough calculation, it was wrong!. Suppose the multiplexing is stuck and the LEDs are fully ON. In this case, the collector current is 8 * 14 mA = 112 mA. Digilent picked 2.2k resistors so (3.3-0.7)/2200 = 1.2 mA of base current. For Hfe of 100, this is just enough.This higher current leads to higher brightness and, sure enough, when the LEDs aren't multiplexing, they are a LOT brighter.Clearly, you calculate the base resistor on maximum load because that is where you need maximum base current.For a first cut, I would do just what Digilent did even though they used Common Anode.It's also worth remembering, the CPLD pin current is 14 mA. This means there is 0.4V decrease in the 3.3V curve and this impacts the brightness somewhat. There is no issue with Iol because the transistor is handling the pull-down.You really need to breadboard this and be certain that you are satisfied with the results before you commit to a PCB.You calculated 8 mW dissipation, why use a resistor capable of 250 mW? The resistors that Digilent uses are about the size of a grain of sand. The transistors are in dual packages and are very small - less than an 0805 resistor and they have 6 pins. Tiny stuff mounted to the bottom of the board and contained within the area bounded by the display pins.You probably won't go wrong simply using what Digilent uses.