This is the circuit I'm using to control a white LED with the MOSFET's gate connected to an output pin on the STM32:

enter image description here

This is the 5V power source:

enter image description here

VIN is a single cell li-ion battery. The enable pin EN_5V is always set high by the STM32. I verified there's a steady 5V at the LED anode.

This is a snippet from the datasheet of the DMN601DMK MOSFET:

enter image description here

I'm applying a 250 Hz 2.5V square wave (2 ms on, 2 ms off) to the gate at PB0.

The waveform at the gate (G2) is as expected:

enter image description here

I verified the source (S2) is at 0V. However, during the gate low pulse, the waveform at the drain (D2) is close to 3V instead of the expected 5V:

enter image description here

This explains why the LED isn't fully turning off during the low pulse of the gate- it was slowly decaying to 0V.

What could be the explanation?

Update: following advice below, I added a 10k across the LED, and now the voltage at the LED cathode is 5V (instead of 3V) during the off cycle, indicating there's no voltage drop. The problem was MOSFET current leakage (Zero Gate Voltage Drain Current in the datasheet). The yellow waveform is a different signal that just shows when the LED is off- when the yellow waveform is high, the LED is off, and when the yellow waveform is low, the LED is on. The blue waveform is the voltage measured from ground to the LED cathode. enter image description here

  • \$\begingroup\$ It might be two different things. Is the while LED with a phosphor? And, you measured voltage at drain, not current. If you have two probes, you can measure the voltage over resistor, does voltage over resistor drop to 0V immediately? \$\endgroup\$
    – Justme
    Jan 30 at 5:19
  • \$\begingroup\$ This is the white LED I'm using: digikey.com/en/products/detail/luminus-devices-inc/…. The voltage at the LED cathode side of the resistor goes to a little over 2V when the drain side of the resistor is at 0V, which makes sense because of the LED voltage drop. The LED cathode side of the resistor is at the same voltage as the drain side of the resistor during the high pulse (close to 3V when the gate is low). \$\endgroup\$
    – donut
    Jan 30 at 5:44
  • \$\begingroup\$ If I'm reading the data sheet for the MOSFET correctly, it has leakage currents in the low microamps. That's enough to turn on an LED very slightly in a dark room. If you want the LED to turn completely off, I think putting a bit of resistance, say 100k ohms, in parallel with the LED will fix this? I don't know if that's the orthodox way. \$\endgroup\$ Jan 30 at 6:21
  • \$\begingroup\$ The datasheet refers to gate-source leakage, not drain-source leakage, so I'm not sure what that is. \$\endgroup\$
    – donut
    Jan 30 at 6:39
  • \$\begingroup\$ You haven't considered the scope impedance (10M for a 10X probe). Repeat the test with a resistor across the LED. Try 100k. \$\endgroup\$
    – Mattman944
    Jan 30 at 8:16

2 Answers 2


All MOSFETs have a "zero gate voltage" drain current, meaning that they leak a little current between drain and source even when \$V_{GS}=0\ \text{V}\$.

For the DMN601, that could be as much as 1 μA, quoted on page 2 of the datasheet. That doesn't sound like much, but through a diode (especially an LED) it's easily enough for that diode to develop many hundreds of millivolts. It may even glow visibly.

I believe this is why you don't see zero volts across the LED, when it's supposed to be off.

Luckily, the solution is simple - a resistor in parallel with the LED, to divert current around the LED. Its value should be chosen to develop a small voltage (say 100 mV) with a few microamps (say 10 μA) flowing. By Ohm's law:

$$ R = \frac{V}{I} = \frac{100\ \text{mV}}{10\ \mathrm{\mu A}} = 10\ \mathrm{k\Omega} $$


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ If there's leakage current during the time when the MOSFET should be off, would you expect to see 0V across the resistor R7 above the MOSFET though? Also, doesn't the datasheet only show gate-source leakage? \$\endgroup\$
    – donut
    Jan 30 at 17:27
  • \$\begingroup\$ @donut Yes, the voltage across R7 will be close to zero. The datasheet I linked to includes "zero gate voltage drain current" parameter. \$\endgroup\$ Jan 31 at 2:40
  • 1
    \$\begingroup\$ Wow, that worked! Thank you!! I put a 10k across the LED and now the voltage at the LED cathode is at 5V during the off cycle. \$\endgroup\$
    – donut
    Jan 31 at 7:15
  • \$\begingroup\$ I added the new scope shot to my original post. \$\endgroup\$
    – donut
    Jan 31 at 7:24

Like you measured yourself, when FET is off, there is equal voltage over both sides of the resistor, the LED cathode side and FET drain side, which means, no current flows.

So I am pretty sure the MOSFET is off when you set gate to 0V, and there are other reasons why you may think the FET is not off if you only look at voltage waveforms at FET drain.

The reason for any waveforms (which you don't show) that the LED would be on or slowly decaying is capacitance.

The LED has some capacitance, maybe a few or few tens of picofarads. Small and usually insignificant, but in your measurements, highly visible.

When FET has stopped conducting and no current flows in the circuit, the stray capacitances of the LED are still charged to the forward voltage value and slowly discharging. The only thing that changes rapidly is that current through resistor drops to 0 so there will be 0V drop over the resistor, so the drain voltage quickly rises only to match the voltage being charged over the LED capacitance.

Another thing worth mentioning is that you are also measuring the voltage at drain with a scope probe, so there will be a small current through the LED and probe which actually keeps it charged and it will never rise higher than 5V minus the forward voltage drop. The common probe impedances are 1Mohm for 1x probe or 10Mohm for 10x probe, but other options exist, such as 2.2Mohm for a non-switchable Agilent 10x probe with 500MHz bandwidth.

A third thing which will affect the waveforms is that the LED also acts as a photodiode or a solar cell, just a poor one because a LED is optimized to emit light, not to capture it. So ambient lighting conditions will affect what will be the resulting voltage drop over the LED and how slowly or quickly the LED capacitance will discharge. You can try it by e.g. turning off lights in the room or shining light from flashlight (mobile phones are handy with that).

And since it is a white LED, it is actually a blue LED with yellow phosphor. The phosphor keeps glowing for some time after LED is turned off, so it can be quite visible and take many seconds to fade out. Which also affects the LED as photodiode.

  • \$\begingroup\$ Thank you for your insight. The LED datasheet doesn't include capacitance. Do you think all white LEDs would have a similar capacitance if that's the issue? Also, would all white LEDs have a phosphor that creates an afterglow? I need the LED to be fully off in less than 1 ms for my application. \$\endgroup\$
    – donut
    Jan 30 at 6:38
  • \$\begingroup\$ @donut All LEDs have capacitance, it does not depend on color. The capacitance is generally not reported because it is irrelevant for LEDs used for generic indicator lights or such as your LED intended for lighting. And yes, all single diode white LEDs are blue LEDs with yellow phosphors. You can likely get LEDs that are RGB which produces white by producing a mixture of red, green and blue, but generally you need to drive all three LEDs yourself with three suitable resistors to tune the whiteness. If you need LED to turn off fast, then at least this LED does not specify phosphor decay. \$\endgroup\$
    – Justme
    Jan 30 at 6:54
  • \$\begingroup\$ Do you think it's possible to have a phosphor decay that is less than 1 ms? Also, I'm not sure if the issue is LED capacitance and/or phosphor decay, neither of which are mentioned in LED datasheets I've looked at so far. I'm not sure what to do next. \$\endgroup\$
    – donut
    Jan 30 at 7:13
  • \$\begingroup\$ @donut I also don't know what you should do next, but I believe I thoroughly answered the question you asked. You can ask further questions for remaining problems. Maybe don't use a white LED? Usually LEDs don't have enough capacitance to keep them on more than a few microseconds so capacitance is not an issue. Or you could actively discharge it if you need nanosecond level turn off times for data comms. \$\endgroup\$
    – Justme
    Jan 30 at 7:20
  • \$\begingroup\$ Could afterglow of the phosphor explain the voltage drop across the LED? Also, if afterglow is the issue, would actively discharging the LED prevent that? \$\endgroup\$
    – donut
    Jan 30 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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