Author Topic: Driving LEDs from logic circuits  (Read 6496 times)

0 Members and 1 Guest are viewing this topic.

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Driving LEDs from logic circuits
« on: November 16, 2017, 12:45:43 pm »
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?
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Driving LEDs from logic circuits
« Reply #1 on: November 16, 2017, 12:55:34 pm »
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.
Safety devices hinder evolution
 

Offline jaromir

  • Supporter
  • ****
  • Posts: 337
  • Country: sk
Re: Driving LEDs from logic circuits
« Reply #2 on: November 16, 2017, 12:57:41 pm »
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.
 

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Driving LEDs from logic circuits
« Reply #3 on: November 16, 2017, 01:06:07 pm »
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.
« Last Edit: November 16, 2017, 01:24:40 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline jaromir

  • Supporter
  • ****
  • Posts: 337
  • Country: sk
Re: Driving LEDs from logic circuits
« Reply #4 on: November 16, 2017, 01:28:21 pm »
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.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Driving LEDs from logic circuits
« Reply #5 on: November 16, 2017, 02:16:42 pm »
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
 

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Driving LEDs from logic circuits
« Reply #6 on: November 16, 2017, 02:59:56 pm »
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

It gets a bit Apollo 13 doesn't it.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Driving LEDs from logic circuits
« Reply #7 on: November 16, 2017, 03:08:45 pm »
So as a sanity check...

Given a SN74HC02: http://www.ti.com/lit/ds/symlink/sn74hc02.pdf

My Vcc is 5V.
My OH will be ~4.8V @ -4mA
My LED Vf ~=1.9V
Therefore my resistor to maintain ~4mA is ~820 Ohm or ~1k5 for ~2mA?

Not exactly convenient values, but a 1k sounds about right.
« Last Edit: November 16, 2017, 03:10:41 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Driving LEDs from logic circuits
« Reply #8 on: November 16, 2017, 08:14:27 pm »
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:
 

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Driving LEDs from logic circuits
« Reply #9 on: November 16, 2017, 09:16:09 pm »
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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline trys

  • Regular Contributor
  • *
  • Posts: 170
  • Country: gb
  • I started with the AC128
    • Trystan's Workbench
Re: Driving LEDs from logic circuits
« Reply #10 on: November 16, 2017, 10:22:35 pm »
You didn't acknowledge my post:


You will probably find that your LEDs will light with just 1mA, so you're looking at a series resistor of 4K7 (or something like that) if the outputs are at 5V. They won't be bright, but you'll be able to see them.

The mA draw of LEDs is usually quoted as maximums to stop us lot frying them. An LED fed with 20mA gives a good bright light.

Trys
 

Offline trys

  • Regular Contributor
  • *
  • Posts: 170
  • Country: gb
  • I started with the AC128
    • Trystan's Workbench
Re: Driving LEDs from logic circuits
« Reply #11 on: November 16, 2017, 10:27:40 pm »
Glad I helped. :)
 
The following users thanked this post: paulca

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Driving LEDs from logic circuits
« Reply #12 on: November 16, 2017, 11:17:24 pm »
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??
There 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.
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Driving LEDs from logic circuits
« Reply #13 on: November 16, 2017, 11:39:36 pm »
Are the 74HC4xxx series not CMOS  and the 74HCxx non CMOS?   Anyway I don't believe the 74HC02 is CMOS or TTL.
Simply 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.
 

Online paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4001
  • Country: gb
Re: Driving LEDs from logic circuits
« Reply #14 on: November 17, 2017, 07:40:03 am »
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 V

As 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.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline stmdude

  • Frequent Contributor
  • **
  • Posts: 479
  • Country: se
Re: Driving LEDs from logic circuits
« Reply #15 on: November 17, 2017, 08:16:02 am »
Yet when I check some of the gate chips datasheets I see figures like +-25mA per gate, -+50mA total for the whole chip.

It 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. 
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Driving LEDs from logic circuits
« Reply #16 on: November 17, 2017, 04:48:58 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf