How to safely drive an LED with an open-drain microcontroller pin - Page 1
Forum section: electronics / beginners

author: PythonGuython
author_rank: Contributor
timestamp: April 09, 2024, 01:08:01 pm
content: I have a microcontroller with an open-drain pin that can't handle more than 6V. The LED needs to conduct when the pin is at low impedance, and not conduct when the pin is high impedance. Originally I made this circuit:but I realized the pin's maximum voltage rating would be an issue because when it is in the high impedance state, it will see the full 12V.My best attempt at a solution was using a PNP and placing the driving resistor first along the line so that it drops the voltage, but I don't think this is a good idea because my understanding is that it is hard to size current precisely with BJTs because hfe can vary wildly.

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2024, 01:15:09 pm
content: What sort of LED is it?Can't you simply power the LED off 5V?How much current does it use?

author: PythonGuython
author_rank: Contributor
timestamp: April 09, 2024, 01:19:02 pm
content: Simple indicator LED pulling 2 mA. I only have access to 12V because this indicator is supposed to indicate battery charging status - even when the device is turned off. When the device is turned off my regulators are turned off, so I don't have 5V

author: Ian.M
author_rank: Super Contributor
timestamp: April 09, 2024, 01:25:06 pm
content: Cascode the output with N channel JFET rated for more than 12V Vds, gate grounded. That will effectively give you a open drain output that can handle 12VEdit: it also needs a Vgs cutoff voltage <6V.

author: selcuk
author_rank: Frequent Contributor
timestamp: April 09, 2024, 01:25:41 pm
content: There may be protection diodes on MCU pins. A diode from pin to VCC, and another one from GND to pin. In that case, you may not be able to turn off the LED. Check the datasheet. You can use a transistor supplied with 5V to control the transistor driving the LED.

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2024, 01:49:56 pm
content: A plain old BJT in common base configuration will work.

author: Peabody
author_rank: Super Contributor
timestamp: April 09, 2024, 02:20:28 pm
content: What microcontroller has open drain outputs? Do you want the indicator LED to turn off when you power down the MCU?

author: wraper
author_rank: Unknown
timestamp: April 09, 2024, 02:24:01 pm
content: Quote from: PythonGuython on April 09, 2024, 01:19:02 pmMakes no sense. How it's supposed to be controlled by MCU when MCU has no low voltage power?

author: PythonGuython
author_rank: Contributor
timestamp: April 09, 2024, 02:33:08 pm
content: I probably should have explained more. I left some details out to avoid over explaining, but that has clearly led to confusion. This is a battery charging IC. I said microcontroller because it is a digital status pin. The battery charging IC is powered by a 9-12.6V LiPo. I think one of the solutions posted here will work for me.

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2024, 05:53:03 pm
content: Quote from: Ian.M on April 09, 2024, 01:25:06 pmLike this.It's definitely the simplest idea. Just three components, including the LED. If a J-FET with a higher on resistance and lower saturation drain current is used, then the series resistor can be eliminated, although beware that J-FETs can vary widely, so it's probably better to keep the resistor.

author: AndersJ
author_rank: Frequent Contributor
timestamp: April 09, 2024, 06:52:18 pm
content: Is it OK to float the source when W1 is open?

author: tooki
author_rank: Super Contributor
timestamp: April 09, 2024, 08:42:46 pm
content: Quote from: PythonGuython on April 09, 2024, 02:33:08 pmThat wasn’t “leaving out detail”, it was completely mischaracterizing the situation entirely. An MCU GPIO simply isn’t the same thing as an output of a dedicated IC, even if it is a digital output.How about you just tell us the part number of the charging IC, and what your actual needs are?

author: Zero999
author_rank: Super Contributor
timestamp: April 09, 2024, 10:00:04 pm
content: Quote from: AndersJ on April 09, 2024, 06:52:18 pmIt's not floating. When W1 opens, the source sits at the FET's threshold voltage above the gate, which is a couple of volts, in the case of the J112. The source node always has a low impedance.In any case, it's gates which shouldn't be left floating. It's perfectly fine to allow an unused open-drain output to float.