# Drive a LED with open-drain output

#### waulu

Joined Dec 23, 2016
59
Hello,

I was reading these two websites with some solutions to use an LED with an open-drain output.

microcontroller - Driving a LED with an open drain digital output - Electrical Engineering Stack Exchange

Driving LEDs with Open Drain Port Expander Outputs (maximintegrated.com)

I am interested in the solution with a PNP transistor. Both websites suggest the use of a pull-up resistor to mitigate the leaking current. Although both websites suggest different sources for the leaking current.

First website,

"
If Q1 is off there won't be any base current through Q1, so the LED will remain off. Q1 will have a small leakage current, and to avoid that this would get amplified by Q2 I added R3. As long as the leakage current is less than 0.7 V / 15 kΩ = 50 µA all the leakage current will flow through R3, so that will ensure Q2 will be completely off.
"

Second website,

the optional 1MΩ resistor ensures that transistor Q4 is off when the port output is high (high impedance), and it should only be necessary at elevated temperatures when Q4 becomes relatively leaky.

So I think the first refers to the leaking current from the transistor configured as open-drain and the second website refers to the leaking current from the PNP transistor.

My question is why the resistor works in either case. Why the current still doesn’t flow through the base of the PNP transistor?

Thank you

#### dl324

Joined Mar 30, 2015
12,796
My question is why the resistor works in either case. Why the current still doesn’t flow through the base of the PNP transistor?
Because the CB junction is reverse biased.

Why don't you just use the open drain output to drive the LED cathode? If you need more current, you could use a logic level P channel MOSFET and eliminate one of the resistors.

If it's a cost issue, I hear you. There are no inexpensive P channel MOSFETs in through hole packages.

#### Yaakov

Joined Jan 27, 2019
2,921
Because the CB junction is reverse biased.

Why don't you just use the open drain output to drive the LED cathode? If you need more current, you could use a logic level P channel MOSFET and eliminate one of the resistors.

If it's a cost issue, I hear you. There are no inexpensive P channel MOSFETs in through hole packages.
These are about 90 cents from reputable sources: https://www.diodes.com/assets/Datasheets/BS250P.pdf

#### Papabravo

Joined Feb 24, 2006
15,779
Very little current will flow through the base emitter junction if the potential difference across the junction is less than 0.7V. In each case the pullup resistor ensures that any potential difference across the the base emitter junction will be vanishingly small. It is a consequence of Ohm's law that if the current through a device is zero or very very small then the voltage drop across the device will be zero or very very small.

In your second example you have a 1MΩ resistor. Let us say that there is 1 femto Ampere of current flowing through it. Aplly Ohm's law to compute the voltage drop.

$$(1 \times 10^{-15} \;\text A )(1 \times 10^{6}\;\Omega )\;=\;1 \times 10^{-9}\;\text V$$

Subtracting 1 nanovolt from 2.5 volts gets you 2.499999999 volts, and you can see the magnitude of the change. In the cosmic scheme of things you don't have to worry about things you can barely measure. You can do similar calculations with the first example to find out how much current the FET has to draw to lower the base of Q2 from 3.3 V to 2.6 V where the transistor will begin to conduct.
The sum of the base current and the current through R3 will go through R2, dropping 2.6 volts through 1.5kΩ. The relentless applications Ohm's law, and KCL, and KVL will tell you what you need to know.

One more thing: Nowhere is it written that one side of an LED must be connected to ground. The LED certainly doesn't care doesn't care -- why should you.

#### waulu

Joined Dec 23, 2016
59
Because the CB junction is reverse biased.
I think when when they talk about leaking current, they mean current that pass when the junction is reverse biased, like in diode. So, the LED should be off, but due to the leaking current that's amplified, the LED may or may not turn on.

Why don't you just use the open drain output to drive the LED cathode? If you need more current, you could use a logic level P channel MOSFET and eliminate one of the resistors.

If it's a cost issue, I hear you. There are no inexpensive P channel MOSFETs in through hole packages.
Yes, in my case I need the transistor because the output cannot sink enough current. This is a personal project and I rarely use BJT transistors, so that was my reasoning. Just to practice.

Very little current will flow through the base emitter junction if the potential difference across the junction is less than 0.7V. In each case the pullup resistor ensures that any potential difference across the the base emitter junction will be vanishingly small. It is a consequence of Ohm's law that if the current through a device is zero or very very small then the voltage drop across the device will be zero or very very small.

In your second example you have a 1MΩ resistor. Let us say that there is 1 femto Ampere of current flowing through it. Aplly Ohm's law to compute the voltage drop.

$$(1 \times 10^{-15} \;\text A )(1 \times 10^{6}\;\Omega )\;=\;1 \times 10^{-9}\;\text V$$

Subtracting 1 nanovolt from 2.5 volts gets you 2.499999999 volts, and you can see the magnitude of the change. In the cosmic scheme of things you don't have to worry about things you can barely measure. You can do similar calculations with the first example to find out how much current the FET has to draw to lower the base of Q2 from 3.3 V to 2.6 V where the transistor will begin to conduct.

The sum of the base current and the current through R3 will go through R2, dropping 2.6 volts through 1.5kΩ. The relentless applications Ohm's law, and KCL, and KVL will tell you what you need to know.

One more thing: Nowhere is it written that one side of an LED must be connected to ground. The LED certainly doesn't care doesn't care -- why should you.
Ok for the second website that mention leakage from the PNP transistor. So there's always leakage, but the bigger the voltage between EB, the bigger the leakage. So we add a the pull up resistor to reduce the VEB voltage and as consequence to reduce the leakage, but there's always some. Is that right?

For the first website that mention leakage from the MOSFET, I don't understand how a pull-up resistor serves as the path for the current and not the EB junction. Because the junction EB allows some current to pass. But I guess it’s the same situation, the pull-up keeps the voltage VB high and so the leakage is really negligible. So like the author said, unless the current is bigger than 0.7/(pull-up resistor), there’s no problem.

Ok Thank you, I think now I am able to have a basic understanding of this.

Last edited:

#### KeepItSimpleStupid

Joined Mar 4, 2014
4,665
The bigger problem is that the leakage current can turn-on the FET over time. The FET has capacitance, which charges via the leakage current. If the voltage gets large enough, the FET turns on. How much current does the ate need to turn-on?

#### waulu

Joined Dec 23, 2016
59
Hello KeepItSimpleStupid,

I was just looking how to drive an LED with an open drain output. I found these examples and I got interested in that. But in my case I am not using a FET, I am using the LD39050,

LD39050.fm (mouser.fr)

and I want to use the output "Power Good" with an LED . After that I started search how to use a PNP and what precautions to take. That eventually led me to these two websites and the doubt about the leakage current.

EDIT: Anyway, that idea is interesting, the possibility of the leakage current charging the capacitor of the FET to the point that turns it on.

Last edited:

#### KeepItSimpleStupid

Joined Mar 4, 2014
4,665
So, for FETS, you generally need a series resistor (200 ohms is popular) and the leakage current path for simple FET driving. Since, the "voltage across a capacitor cannot change instantaneously" the resistor is added. For faster switching times, you need a driver that can supply enough current to deal with the capacitance. It also needs to suck the charge out as well.

Non-idealatites you have to deal with. Sometimes three 1K resistors in series is not the same as a 3K resistor. Fingerprints on a PCB may matter. Wiggling wires in the Earth's magnetic field generates a current. An SMT resistor mounted on it's edge is a different component than one mounted on it's body.