Driving LEDs from logic circuits - Page 1
Forum section: electronics / beginners

author: paulca
author_rank: Super Contributor
timestamp: November 16, 2017, 12:45:43 pm
content: I asked this buried in one of my other long threads, but didn't get any responses, so excuse me reasking in a separate thread.I see lots of youtube videos and online circuit diagrams which slap LEDs directly on the outputs of logic gate chips.Yet when I check some of the gate chips datasheets I see figures like +-25mA per gate, -+50mA total for the whole chip.With the correct current limiting resistor you can certainly get an LED to light with 20mA, but I have seen people hanging 8-12 LEDs of the same chip.Either they are using more "beefy" gates or for prototyping they are not particularly worried about heating up the logic gate IC or potentially burning it out, so they don't care.I used an NPN on the outputs to drive the LEDs, but ... it makes the circuits more time consuming to build.So... given the datasheet says 50mA max... if I put 8 LEDs pulling 20mA each (160mA) through it, will it fail, get a bit warm but struggle on, or probably not notice with a shorter life span?

author: capt bullshot
author_rank: Super Contributor
timestamp: November 16, 2017, 12:55:34 pm
content: Why would you want to operate a LED at 25mA?If it is just for indication, most modern LEDs work fine with 2mA, so not a big deal having a lot of them on the same chip.Of course, if you use larger currents, you have to obey the datasheet of the driving chip for maximum supply current. Exceeding this rating is quite possible with most chips and often stays unnoticed - yes, maybe even works reliably - but you're always on a risk doing so.

author: jaromir
author_rank: Unknown
timestamp: November 16, 2017, 12:57:41 pm
content: It's usually either they don't care (you can be quite quick done seraching for arduino circuit with no series resistor to LED) or they are using lower than 20mA of current per LED.20mA is perhaps good for special or antique LEDs, most of modern LEDs do have enough of brightness for indication purposes at few mA, 2 or perhaps 5, say. High efficiency blue LEDs are good with less than 1mA of current, at 20mA they are annoyingly bright.

author: paulca
author_rank: Super Contributor
timestamp: November 16, 2017, 01:06:07 pm
content: Ah. Think I see where I have gone wrong. I browsed through a few LED datasheets and I think I know where I got 20mA from. It was a few YouTube tutorials on using current limiting resistors. But the key words were "not more than 20mA". Most datasheets seem to show test figures for their LEDs to a maximum of 20-30mA, but yes, on digging further they seem to have 'typical' operating If=2mA to If=5mA.So as long as I choose the current limit resistors carefully they should be fine on the output gates. If I have 50mA to play with I could put 10-25 LEDs on a chip!Devil's in the details.Makes my logic gate explorations a little easier to build.EDIT: It's interesting to note that googling "LED current limiter resistor" results in many results showing the classic formula R = (Vs - Vf) / I, but... almost all of them plug in values like 20mA and 30mA for I. Most don't even mention they will run at 2mA. A few out of maybe a dozen suggested that as the max current is usually 20mA figures of 10-15mA should be aimed for.

author: jaromir
author_rank: Unknown
timestamp: November 16, 2017, 01:28:21 pm
content: I believe, the 20mA/LED figure has its roots decades ago, when LEDs were really not much bright. I still remember buying old, eastern block supplies of LEDs that were not happy unless you ran them at limit of datasheet values, especially green and yellow were poor. 10mA was barely usable, 20mA was OK-ish, 25mA was datsheet limit. I was teenager then (1990's), eastern block components were still plentiful; one LED cost me one day worth of pocket money, 4011 IC was three days worth and C520 (GDR equivalent of AD2020) was 18 days worth of pocket money.For comparison, few years ago I bought huge pack of 1000 red 3mm LEDs from aliexpress (it was like 5USD or so), I tested them randomly, they are quite uniform, running happily and perfectly OK for indication purposes with 620Ohm resistor at output of 3,3V powered CMOS ICs.

author: Zero999
author_rank: Super Contributor
timestamp: November 16, 2017, 02:16:42 pm
content: Also note that there's a difference between what current, a logic output can provide, without damage and what it can provide, whilst still outputting a valid logic level. The maximum current through either power supply pin is often also lower, than the rating of all of the outputs added together.Take the 74HC04 for example. Maximum output current of 20mA, but with a supply voltage of 4.5V (the low end of a typical 5V rail), the maximum output current, whist still outputting a valid logic level, is 4mA. The maximum current through the supply pins is 50mA.http://www.ti.com/lit/ds/symlink/sn74hc04.pdf

author: paulca
author_rank: Super Contributor
timestamp: November 16, 2017, 02:59:56 pm
content: Quote from: Hero999 on November 16, 2017, 02:16:42 pmIt gets a bit Apollo 13 doesn't it.

author: paulca
author_rank: Super Contributor
timestamp: November 16, 2017, 03:08:45 pm
content: So as a sanity check...Given a SN74HC02:http://www.ti.com/lit/ds/symlink/sn74hc02.pdfMy Vcc is 5V.My OH will be ~4.8V @ -4mAMy LED Vf ~=1.9VTherefore my resistor to maintain ~4mA is ~820 Ohm or ~1k5 for ~2mA?Not exactly convenient values, but a 1k sounds about right.

author: Audioguru
author_rank: Super Contributor
timestamp: November 16, 2017, 08:14:27 pm
content: If the output of a Cmos logic gate is driving an LED then why do you want it to also produce a valid TTL 0.4V maximum output voltage??With a 5V supply, the typical maximum output current from a Cmos 74HCxx IC into a 2V red LED without a current limiting resistor is about 48mA(!) and some can produce more. The output transistors are tiny with low capacitance for high speed and the 25mA limit is fine for logic. I have some LED blinkers with 10 outputs at 23mA each driven from a 74HC4017 but only one output is active at a time.Here are graphs showing the typical output current from a 74HCxx logic gate without current limiting:

author: paulca
author_rank: Super Contributor
timestamp: November 16, 2017, 09:16:09 pm
content: Are the 74HC4xxx series not CMOS and the 74HCxx non CMOS? Anyway I don't believe the 74HC02 is CMOS or TTL.They work fine with 1k resistors and the total consumption for the whole working board this evening (555 made with OpAmps and a NOR gate Latch) was 9mA.

author: trys
author_rank: Regular Contributor
timestamp: November 16, 2017, 10:22:35 pm
content: You didn't acknowledge my post:Quote from: trys on November 16, 2017, 02:03:54 pm

author: trys
author_rank: Regular Contributor
timestamp: November 16, 2017, 10:27:40 pm
content: Glad I helped.

author: Zero999
author_rank: Super Contributor
timestamp: November 16, 2017, 11:17:24 pm
content: Quote from: Audioguru on November 16, 2017, 08:14:27 pmThere can be various reasons for needing to do this, such as using two gates to make an astable to flash an LED: one of the gate outputs will drive an LED as well as another gate.

author: Audioguru
author_rank: Super Contributor
timestamp: November 16, 2017, 11:39:36 pm
content: Quote from: paulca on November 16, 2017, 09:16:09 pmSimply look at the datasheets:SN7402- very old TTL with a maximum output low at 0.4V of 16mA and a minimum output high at 2.4V of a very low current.CD4017- ordinary low current Cmos with a maximum supply of 18V and a maximum output current with a 5V supply of a few mA.SN74HC02 or SN74HC4017- high speed, high output current Cmos with a maximum recommended supply of 6V and an output current of 50mA unless current limiting is used.An ordinary NE555 or LM555 is also TTL but has a 200mA maximum output current. A TLC555, LMC555 and ICM7555 are ordinary Cmos with a low output current.

author: paulca
author_rank: Super Contributor
timestamp: November 17, 2017, 07:40:03 am
content: Thanks AudioGuru.I was for some reason expecting "CMOS" to be in the product title on CPC, but it is as you suggest in the datasheet:"These devices are members of the High-Speed CMOS (HC) logic family."The part that caught me in the datasheet originally was the +-25mA maximum allowable output. But the datasheet then goes on to state:• ±4-mA Output Drive at 5 VAs Hero999 pointed out (with reference to my actual application) the gate is also driving the input of another NOR gate... which is actually something I didn't consider... how much current does an input sink at high. Though I think it's in the order of 1u Amp. I "think" I am looking at Ii and/or Icc which are listed in nano and micro amps.The LEDs work fine for indication with a 1k Ohm current limiter.It was late when I got it working last night, so Saturday morning I want to finish it up, tieing all unused gates low, bypass caps on the power and put the oscilloscope on it. I should have traces for "Just transistors", "opamps+logic latch", "actual 555" to compare. All using the same test harness circuit.The first thing that is apparent though, "Just transistors" seems slow and fragile compared to the IC version. I'm convinced the output frequency has changed significantly too.

author: stmdude
author_rank: Frequent Contributor
timestamp: November 17, 2017, 08:16:02 am
content: Quote from: paulca on November 16, 2017, 12:45:43 pmIt seems like the original question has been answered in quite some detail, but I'd like to add a little bit of extra info._Usually_ (but not always) MCUs can sink a lot more current that they can source, so when we do it in products, we connect the cathode of the LED to the MCU instead of the anode. The anode is connected directly to a power-rail through a current-limiting resistor.It gives us a bit more headroom in the internal power-budget of the MCU.

author: Audioguru
author_rank: Super Contributor
timestamp: November 17, 2017, 04:48:58 pm
content: Old TTL maximum output low voltage is 0.4V. The maximum input low current for an old 74LSxx logic IC is 0.4mA then a 74HCxx high speed Cmos output can drive 10 of them. But a logic low input voltage for Cmos that has a 5V supply is much higher at 1.5V.