1
\$\begingroup\$

What is the correct way to connect an LED to a logic circuit?

The obvious thing to do is this:

schematic

simulate this circuit – Schematic created using CircuitLab

I have two concerns:

  • Can the logic gate's output actually deliver enough power to drive the LED? (Sure, LEDs are very low-power. But so are logic gates!)
  • Will the load from the LED distort the output so much that I can't connect it to any other gates?

The second problem looks like it ought to be trivial (if inconvenient) to solve:

schematic

simulate this circuit

Now only the output of the buffer has to deal with the load from the LED; the AND gate is blissfully unaware that anything has happened.

Trouble is, I'm planning to use 74HCxx logic running at 5 V, whereas it looks like most LEDs want to run at ~2 V. Also, it appears 74HCxx can only supply up to 4 mA, whereas most LEDs seems to draw drastically more current than that.

So now what?

Perhaps I could use a resistor to work around the voltage difference. (My knowledge of analogue electronics is far too weak to know if that would work.) Alternatively I could just run all the logic at 2 V instead. (The 74HCxx series seems to support that.) All of which does nothing to solve the current problem.

Do I need one of the level-translating logic gates? Or do I need to build something even more elaborate than that?

\$\endgroup\$
  • 1
    \$\begingroup\$ A LED, like all diodes, will only draw as much current as you supply it with. \$\endgroup\$ – Ignacio Vazquez-Abrams May 26 '18 at 18:02
  • 1
    \$\begingroup\$ In both your schematics the LEDs will need series resistors to limit the current and they need to be flipped over so that they can be allowed to light. As depicted the LEDs will be reversed biased all the time. \$\endgroup\$ – Michael Karas May 26 '18 at 18:14
  • \$\begingroup\$ @MichaelKaras Ah, I always forget whether the arrow is supposed to point towards + or away from it... \$\endgroup\$ – MathematicalOrchid May 26 '18 at 18:18
3
\$\begingroup\$

The circuits you propose won't work (the LED will not light up) because you're trying to make the current flow through the LED in the wrong direction (reverse mode).

Also it is a must to use a series resistor. Yeah sure, it will work without a series resistor but that puts a lot of stress on the logic gate and the LED. Also without the resistor the current through the LED is very uncontrolled and that should be avoided.

Let's cut to the chase and let me show you how it is done:

schematic

simulate this circuit – Schematic created using CircuitLab

For this circuit D1 and D2 will light up when "signal" is high (one = 1 = +5 V)

Resistors R1 and R2 limit the current to about 3 mA when using a 5 V supply. For modern LEDs 3mA will be enough current. If you're using old LEDs you might need up to 20 mA and then it is better to use an additional transistor to make that current flow as logic gates aren't designed to supply such a current.

\$\endgroup\$
3
\$\begingroup\$

You need to remember that the HC gates cannot supply more than 4mA and provide valid logic levels at the same time. So, if you want to drive an LED from a gate output you can not also use that gate output as a logic signal. Your second solution is the more correct one.

Now, if you no longer care about maintaining valid logic levels where the gate output is connected to the LED then you can source considerably more than 4mA from the gate output. The manufacturer doesn't provide min/max values for this situation because that's not really how the gates are supposed to be used. Some manufacturers will provide graphs of typical output current as a function of output voltage. To be safe, you will need a series resistor to limit current. In the absence of data sheet specifications you will need to try some experiments. Be sure that you don't exceed the total current limit of the entire packaged device.

This whole approach is OK for a hobbyist situation but it's not suitable for high-volume manufacturing if you care about reliability. The right way to control an LED is with a discrete transistor or using an integrated circuit that is specifically designed for driving high-current loads.

\$\endgroup\$
  • \$\begingroup\$ Can you give an example of an IC "specifically designed for driving high-current loads"? Does that mean one of the "open collector" logic gates, or something else entirely? \$\endgroup\$ – MathematicalOrchid May 27 '18 at 8:55
  • \$\begingroup\$ From a quick google search, look at the Microchip TC4467. There are many choices, depending on your needs. \$\endgroup\$ – Elliot Alderson May 27 '18 at 11:54
  • \$\begingroup\$ It looks like the key phrase to search for is "driver". Thanks for the tip. \$\endgroup\$ – MathematicalOrchid May 28 '18 at 8:43
  • \$\begingroup\$ Changing to 74AC parts will provide +/-24mA current capability, no extra buffering would be needed to drive the LED/resistor and any following logic. \$\endgroup\$ – CrossRoads Dec 20 '18 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.