# Why are LEDs on most embedded designs inverted?

I noticed, that on all my evaluation boards that I had up to this point in time. The LEDs were all connected in active low to the Microcontroller Port. I understand that from a safety view it's better to have active low RESET lines and such. But why LEDs?

• In the old days, NMOS and NPN transistors were much stronger than PMOS or PNP. So we all got in the habit of arranging LED's so that the logic input sinks rather than sources current. It mostly doesn't matter any more, but old habits die hard. I have connected LED's the other way on occasion. It works fine as long as your respect the current limit of the IO. – mkeith May 23 '17 at 16:15
• It is often the case that a microcontroller's IO pins are able to sink more current than they can source. This can make for brighter LEDs without exceeding the total max current source for the whole chip. Your milage may vary of course, always check the datasheet. – Wossname May 23 '17 at 16:15
• TTL grandfathered the notion of active low drive and CMOS I/O is always inactive high or floating input with/without active pullup. thus LED OFF after RESET – Sunnyskyguy EE75 May 23 '17 at 22:08
• Historical note: TTL inputs floated high, and to drive an input low, you had to pull current from it. That is why TTL outputs had to be able to "sink" significant current in the low state, while they did not have to "source" much current in the high state. (In fact, TTL parts with open collector outputs could not source any current at all in high state.) – Solomon Slow May 24 '17 at 13:42
• One other point. In "the good old days" LEDs were very inefficient and you really needed 20mA to make them look reasonable. These days 5mA is dazzling, so source or sink is not usually an issue. – Dirk Bruere May 24 '17 at 14:00

It's still the case that MCU I/O pins often have weaker drive sourcing current than sinking current.

In a typical CMOS MCU output, when they drive LOW, they turn on an N-channel MOSFET; and when they drive HIGH they turn on a P-channel MOSFET. (They never turn both of them on at the same time!) Because of the differences in mobility that apply for N-channel vs P-channel (about a factor of 2 to 3 difference), it takes extra effort to make the P-channel device exhibit similar "quality" as a switch. Some go to that extra effort. Some do not. If not, the ability to sink (N-channel) or source (P-channel) current will be different.

Some of them are almost symmetrical, in that they can source almost as much as they can sink. (Which just means they are about as good of a switch to ground as they are a switch to the power supply rail.) But even when extra trouble is attempted, there are other issues that make it unlikely the two devices will be fully similar and it still is usually the case that the sourcing side is still at least somewhat weaker.

But in the final analysis, it's always a good idea to go look at the datasheet itself to see. Here's an example from the PIC12F519 (one of the cheapest parts from Microchip that still includes some internal, writable non-volatile storage for data.)

This chart shows the LOW output voltage (vertical axis) vs the LOW sinking current (horizontal axis), when the CPU is using $$\V_{CC}=3\:\textrm{V}\$$:

This chart shows the HIGH output voltage (vertical axis) vs the HIGH sourcing current (horizontal axis), also when the CPU is using $$\V_{CC}=3\:\textrm{V}\$$:

You can easily see that they don't even bother trying to show the same sinking vs sourcing current capabilities.

To read them, pick a current that is of similar magnitude on both charts (very difficult, isn't it?) Let's select $$\5\:\textrm{mA}\$$ on the first chart and $$\4\:\textrm{mA}\$$ on the second one. (About as close as we can get.) You can see that the PIC12F519 will typically drop about $$\230\:\textrm{mV}\$$ on the first one, suggesting an internal resistance of about $$\R_{LOW}=\frac{230\:\textrm{mV}}{5\:\textrm{mA}}\approx 46\:\Omega\$$. Similarly, you can see that the PICF519 will typically drop about $$\600\:\textrm{mV}\$$ on the second chart, suggesting an internal resistance of about $$\R_{HIGH}=\frac{600\:\textrm{mV}}{4\:\textrm{mA}}\approx 150\:\Omega\$$. Not very similar. (NOTE: I've extracted data from the curves for $$\25^\circ\textrm{C}\$$.)

So if you were designing this particular MCU into a circuit where you wanted to directly drive a $$\2\:\textrm{V}\$$ LED at about $$\10\:\textrm{mA}\$$, which way would you wire it? It's clear that you'd have to consider LOW as ON, since that is the only way that the datasheet says you might be successful, at all, without the need for an external transistor to boost the current compliance of the output.

[You may also take note that the above calculations at nearby sinking vs sourcing currents appear to show two resistance values that are approximately a factor of three from each other (about $$\50\:\Omega\$$ vs $$\150\:\Omega\$$.) This is probably not coincidental to the differences in mobility that I mentioned at the outset, that between P-channel and N-channel mosfets.]

• Hi jonk, please see my comments an examples to Olin below and reconsider. It's fair to say MCUs used to be that way, and logic chips in general, but not so these days. Microchip seem to be an exception you've both looked at but they're hardly the volume market out there :-) – TonyM May 23 '17 at 18:42
• @TonyM I've tested countless devices about ten years ago -- from the MSP430 to Microchip PIC devices. While in many cases the MCUs have gotten much closer in source vs sink capabilities, there was ONLY one case where I found the source capability to equal or exceed the sink capability. And that was in a device where ONLY ONE PIN was so specified and achieved. All of them, otherwise, exhibited lower drive. Not to the point of the example device I gave, but far enough that it is worth knowing. The MSP430, for example, provides about 60 ohm sink and about 100 ohm source. – jonk May 23 '17 at 18:51
• @TonyM So while the details vary, of course, and some devices will be closer (much closer at times) than others, the point remains. Do you have a specific device that provides detailed curves over sink and source currents that I might examine, in order to improve my answer here? Let's say that the selected device must operate with $V_{CC}=3\:\textrm{V}$, so that I can keep apples to apples. I'd enjoy improving the answer. – jonk May 23 '17 at 18:52
• Now you're asking, I've closed 'em all. Have a look at the Silicon Labs part and usually NXP datasheets are good, I'll have to recheck in a bit. But my examples show that logic chips today are balanced and its only digging deep you find imbalance. You can clearly hang an LED either way off these outputs and they'll work fine. The outputs don't have to be really precisely balanced to see that the old logic has gone, like 74LS outputs with 1.6 mA sink and 0.4 mA source, a 4-to-1 ratio. So one can't say the point remains, it's mostly just old habits pervading. Unless you love only Microchip :-) – TonyM May 23 '17 at 19:14
• @TonyM My point is more about looking at datasheets and doing the associated sanity checks, than it is about any one device. Also, though, it's not unreasonable to anticipate some difference. And that if you have a choice, you may find that it's a little bit more secure using active-LOW, even today. But always CHECK!! Clearly, for some applications (LEDs for example) it's far more likely today than 20 years ago. But the OP is asking about "Why?" they find what they find. My answer is an answer to that question. I'd still like to see some curves (not table rows) of some device at 3V. – jonk May 23 '17 at 19:18

It is fairly common (although not as common as it used to be) that microcontroller output pins can sink more current in the low state than they can source in the high state. As a result, designers got used to putting LEDs, or anything else that needs a high (for a microcontroller pin) current between power and the pin instead of between ground and the pin. When the micro has symmetric source/sink capability, this is not necessary, but does no harm either.

For example, here is a snippet from the PIC 16F1459 (a reasonably recent and certainly mainstream production part) datasheet:

Note how the currents for the Output Low Voltage case are higher at the same supply voltage than for the Output High Voltage case. And, the sink currents are specified for a 600 mV rise, while the source currents for a 700 mV drop. All in all, this micro has substantially stronger low side drivers on its regular I/O pins.

Many newer micros are symmetric, apparently particularly those that don't have much source/sink capability in the first place.

When the LED requires more current than a digital output can handle, or at least more than you want to let it handle, you need to use a external transistor. A low side switch is the natural and simple choice. The LED is then connected between power and this transistor.

• Hi, a correction for your answer: [it was fairly common that microcontroller output pins could sink more current in the low state than they can source in the high state. Microcontrollers of the last 10 years or more have balanced outputs that source as much as they sink] I agree completely it was the case with 8048, 8051, 6811 and all the old'uns but not so with post-2005 or thereabouts-ish stuff like all the ARMs. Thanks. – TonyM May 23 '17 at 16:41
• @Tony: Asymmetric source/sink is still common, although less than it used to be. I just checked one of the PIC 16F1xxx (16F1359 specifically) parts, which are fairly new. With 5 V Vdd a high output can source 3.5 mA with 700 mV drop. A low output can sink 8 mA with 600 mV drop. This is far from gone, even in modern micros. – Olin Lathrop May 23 '17 at 16:59
• The PIC16F1xxxx are an upgrade from the old PIC16Fxxx line but still ancient technology. They are all symmetrical now as close as possible with wide tolerances 25% typ. and 1/Vdd sensitive. – Sunnyskyguy EE75 May 23 '17 at 18:23
• Thanks for looking but Microchip part looks misleading. I looked up: NXP P89LPC933 (8051, 2004) with Iol=Ioh=20 mA; NXP LPC1111 (ARM, 2010) with Iol=Ioh=4 mA; TI OMAP5910 with Iol=Ioh=same (configurable) mA; TI TMS320C620 with Iol=Ioh=8 mA; Silicon Labs EFM32GG380 (2014) with Iol=Ioh=same (configurable) mA. Ignore the missing '-' on sinks. Could have kept going, just quick 5 mins in my datasheet library...personally, I haven't seen an unbalanced one in decades. Please can you re-edit your answer similar to my earlier comment, good to give the full picture and harmless to your answer to do so. – TonyM May 23 '17 at 18:30
• @OlinLathrop "6F1xxx series is a recent sequal to the old 16Fxxx series." Yes I am aware of that, but they chose not to upgrade the RdsOn specs so Vol,Voh are identical so that Q would not change in legacy board designs which affects stripline characteristics and ringing. Changing driver Z in half on uncontrolled impedance tracks ( read inductive) may cause false edges from ringing) hence, grandfathered driver specs for those operating at max f.clk. Q=2pi*f * L(f)/ESR for source drive – Sunnyskyguy EE75 May 23 '17 at 22:02

By using a pull-down design it is possible to switch a device (eg a LED) with a 5V supply, using a 1.8V but 5V tolerant microcontroller without any external components.

When the (open-drain configured) pin is not pulled down it is floating, as no current is drawn the voltage will float to the supply voltage of the led so to 5V. This is ok for some but not all low-voltage micros.

This way you can run the leds directly off a supply line and use a lower current voltage converter for the micro. This is the only way to use eg. blue leds on a 1.8v micro without adding more components.

For example the pins of the NXP LPC81xM series are 5v tolerant when the micro is powered, even at 1.8v

Dataseet of NXP LPC81xM

Because open drain mosfets generally sink more current than push pull and sometimes even tolerate a wider voltage range. Using an LED with open drain only works with an active low configuration. Depends on the micro though, some are only push pull.