1
\$\begingroup\$

Some of the answers are now incorrect because the original question was "confused". In an ideal world, the question should have been maintained with its original sense after answers were given. Due to the very substantial "churn", I have decided to edit it and reopen it with the OP's intended meaning. The aggravation caused to various members is regretted. || RM (moderator)


I wish to use a GPIO pin to drive an LED, but the GPIO current capabilities are too low. In addition,

  • The LED is expected to light when the GPIO output signal is low.

  • The GPIO has a +3.3 V supply and is a LVTTL output

  • I want to power the LED using a +5 V source.

  • The current GPIO is rated @ 5 mA maximum, and

  • The LED will be driven with 10 mA initially.

I assume that characteristics of GPIO may change with processor board change. The LED I am going to use typically has a nominal 2 V drop at 20 mA.

Initially I designed a simple driver using FET and gate pull-down resistor, but then realized that for some pins I will not be able to change polarity of the active signal in the firmware. As my above described single FET based circuit is inverting it would not light the LED when the GPIO was low, as is required.

I looked through the web to find some complicated circuits, but I need a simple and cost-effective solution performing its duties and not firing current back from 5 V to 3.3 V.

I'd probably try two FETs daisy chained, but is it the best way to go, and are there two FETs in single package (or even more FETs, as I have several LEDs to drive)?

Any ideas? Thanks!


Regarding the term "inverting", let me clarify: if you consider two situations: LED pulled up to Vcc, and LED pulled up to Vcc through FET, you will have LED lighting when input is low in first case, and not lighting in second case. The discussion is not about currents and voltages, it about the state of the LED. This was my mistake not clarifying that originally signal polarity is negative - in other words the LED is expected to light when the signal is low.


Does this one look appropriate? The only issue remaining is to choose the transistor, what's about IRLML2803?

enter image description here

Found the device NDC7002N, old one, but seemingly to fit the requirements: threshold is appropriate for 3.3V-LVTTL switching. Relatively high Rdson is no problem here as series resistors are high enough to have fraction of power through the transistor.

Update: I have chosen to use 1G17, and it works as expected. The main thing here is you must use genuine (e.g. TI) chips with partial-power-down capability as other manufacturers may not have it. Check datasheets carefully.

\$\endgroup\$
13
  • 2
    \$\begingroup\$ I've adjusted the wording in this question to include the clarification about "inverting" but also include the updated text. You will need to include the note clarifying "inverting" so as not to invalidate anyone's answers. \$\endgroup\$
    – Null
    Commented Apr 9 at 14:14
  • 1
    \$\begingroup\$ OP, let's get an accurate starting point, where I've been trying to get us for a while now I'm afraid. Please use the edit history and read the edit I made to your question. You'll see I'd rewritten it completely and concisely, to say what you'd later been saying in comments/edit but unfortunately in a confusing way. Is any part of that rewritten version wrong at all? \$\endgroup\$
    – TonyM
    Commented Apr 9 at 14:24
  • 1
    \$\begingroup\$ NOTE SOME OF THE ANSWERS ARE NOW INCORRECT BECAUSE OF THE VERY SUBSTANTIAL ALTERATIONS ANDMULTI PARTY EDITING. IN AN IDEAL WORLD THE QUESTION SHOULD HAVE BEEN MAINTAINED WITH ITS ORIGINAL SENSE AFTER ANSWERS WERE GIVEN. DUE TO THE VERY SUBSTNTIAL "CHURN' i HAVE DECIDED TO EDIT IT AND REOPEN IT WITH THE OP'S INTENDED MEANING. || THE AGGRAVATION CAUSED TO VARIOUS MEMBERS IS REGRETTED. \$\endgroup\$
    – Russell McMahon
    Commented Apr 10 at 7:50
  • 1
    \$\begingroup\$ @TonyM How dare you de-shout my addition ! :-) :-) :-) :-) || The "shouting was to (attempt to) make very sure that we did not enter another round of to & fro editing because someone "somehow missed" the up front request . As sometimes happens. But, I'll not reshouten it :-). It's a shame all round, and caused more pain that it should have. It's hard to stop this happening occasionally. \$\endgroup\$
    – Russell McMahon
    Commented Apr 10 at 14:02
  • 1
    \$\begingroup\$ Morning @RussellMcMahon, I couldn't read it as I had to put pillows over my ears :-D I left caps on your answer notes as authors can then do something about em but the question's...better anyway now. Hence lower-case italics which think bring out the heartfelt poetry in your words, or something. You'll see that I rewrote the question a while back (see edit 2). I should have put that under the original question text as an 'EDIT:', rather than replace the question. But I also did it to give the OP an example of succinct question writing, as they seemed to be struggling to put their point across. \$\endgroup\$
    – TonyM
    Commented Apr 10 at 14:11

5 Answers 5

3
\$\begingroup\$

What you appear to want is a same-polarity buffer that can drive an LED on a different rail, using the function: GPIO LOW for LED lit.

You can use a single-gate 74LVC17 buffer IC, a cheap and readily-available part in a tiny package (see below diagram from datasheet).

It will run from your 5 V supply and without a decoupling capacitor at the low speeds an LED will use. It may end up close to some decoupling you already have, anyway. Its logic input accepts your 3.3 V GPIO and can drive 24 mA or sink 24 mA. Note that these currents cause a small voltage drop in the driver output stage, which is fine as you're already dropping much more across the LED resistor.

The logic input also has hysteresis for improved noise rejection. This has no downside in your application and you may decide that it helps there.

schematic

simulate this circuit – Schematic created using CircuitLab

enter image description here


The following answer was posted for the original version of the question, for LED lit when GPIO high...

You can use a load switch IC, of which there are many around. A good example is the tiny and low-cost FDC6330L which has Vin of 3..20 V, Iout(max) of 2.3 A and Vsw(on) of 1.5..8 V.

A circuit for using an FDC6330L to drive one LED is shown below. Note that the single IC contains the two MOSFETs shown boxed. (Circuit diagram is a modified Fig. 3 from its datasheet.)

The 22 kΩ pull-down on GPIO is not absolutely necessary. It stops the LED lighting on MCU start-up, while the MCU is going through reset then configuring its GPIO as an output. Until then, GPIO is usually an input with a weak leakage output current. This resistor can be removed if the GPIO already has an internal pull-down, the board already has a pull-down or you'd rather save a resistor and don't mind the LED flash.

enter image description here

ADDED: THIS IS A GOOD ANSWER TO THE ORIGINAL QUESTION. It assumes that the LED is lit when the GPIO drive pin is high - as originally implied. - RM (moderator)

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

the LED is expected to light when the signal is low.

Well - - - that changes everything.

Still, this is possible with only one transistor because the LED Vf is greater than 5 V minus the sum of Voff (3.3 V) plus Vbe (0.6 V).

Here is an emitter follower of the opposite transistor polarity. In this case, the voltage across the R1 is greater so its value increased.

enter image description here

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

ADDED: THIS IS A GOOD ANSWER TO THE ORIGINAL QUESTION. It assumes that the LED is lit when the GPIO drive pin is high - as originally implied. - RM


while GPIO is 3.3V, I want to drive the LED using 5V source

and

but this FET-based circuit is inverting.

No it isn't, not when driving an LED attached to the drain circuit. You want current through the LED when the GPIO pin is high so, functionally, that's non-inverting.

If source connects to ground and gate is driven by the MCU pin then current flows through the drain-connected-LED when the MCU output pin is high (and activating the MOSFET): -

enter image description here

Image (modified) from here

EDIT to invert the logic (using two NPN transistors, CE and CC)

enter image description here

enter image description here

\$\endgroup\$
6
  • \$\begingroup\$ Misunderstanding here. GPIO signal high -> FET output is low. The circuit is inverting even if you see the LED being on and think it is "logical 1". \$\endgroup\$
    – Anonymous
    Commented Apr 9 at 10:26
  • \$\begingroup\$ @Anonymous the circuit is only inverting if you consider the voltages but, that is inappropriate for the illumination of an LED. The LED requires current and, on this occasion, that makes the circuit non-inverting. \$\endgroup\$
    – Andy aka
    Commented Apr 9 at 10:29
  • \$\begingroup\$ Updated the question \$\endgroup\$
    – Anonymous
    Commented Apr 9 at 10:38
  • \$\begingroup\$ @Anonymous you said this in your original question: while GPIO is 3.3V, I want to drive the LED using 5V source <-- are you now saying something else? What precisely does this mean in your edit: in other words LED is expected to light when signal is low <-- are you now saying you want the LED to light when the GPIO pin is low? \$\endgroup\$
    – Andy aka
    Commented Apr 9 at 11:04
  • 1
    \$\begingroup\$ The OP totally misunderstood the "inverting" concept. Apparently, they want to get 5V (or whatever voltage) output from a logic-high input signal -> Basically a high-side driver/translator. \$\endgroup\$ Commented Apr 9 at 14:03
2
\$\begingroup\$

ADDED: THIS IS A GOOD ANSWER TO THE ORIGINAL QUESTION. It assumes that the LED is lit when the GPIO drive pin is high - as originally implied. - RM


Looked through the web to find some complicated circuits, but I need simple and cost-effective solution performing its duties and not firing current back from 5V to 3.3V.

I have several LEDs to drive

Why not use an IC dedicated for that purpose then?

If you want to drive each LED with a corresponding GPIO (i.e. one GPIO per LED) then the good old TD62783 or their more-recent-less-power-hungry counterparts would work. The IC is a set of high-side load switches:

schematic

simulate this circuit – Schematic created using CircuitLab

An IC will not make your design more complicated, and can be considered a cost-effective solution as it allows you to save quite a few discretes and passives.

\$\endgroup\$
7
  • \$\begingroup\$ One LED per dedicated LED GPIO pin. Just need non-inverting translation from 3.3V to 5V. \$\endgroup\$
    – Anonymous
    Commented Apr 9 at 8:56
  • \$\begingroup\$ @RohatKılıç you give logic 0, and LED on. Then, when inserting translator in between, you have same rule - logic 0 and LED on. \$\endgroup\$
    – Anonymous
    Commented Apr 9 at 8:57
  • 1
    \$\begingroup\$ Rohat, your two transistor circuit does exactly what my single transistor circuit achieves. \$\endgroup\$
    – Andy aka
    Commented Apr 9 at 13:30
  • 1
    \$\begingroup\$ @Andyaka Obviously. But the difference comes from the probable fact that the OP misunderstood the "inverting" concept. If you see the edit history of my answer you'll see I first suggested ULN200x, and also one of my comments here was exactly what you said in your answer: You apply logic-high, you get the LED on. so how could this be "inverting"? Turns out the user wants to get 5V (or whatever voltage) with a logic-high input signal. Hence my last edit. \$\endgroup\$ Commented Apr 9 at 13:59
  • 2
    \$\begingroup\$ If you are going to quote the question (which is not really necessary) then you should at least edit mistakes in the part you quote so as not to propagate them. \$\endgroup\$
    – Null
    Commented Apr 9 at 14:05
2
\$\begingroup\$

ADDED: THIS IS A GOOD ANSWER TO THE ORIGINAL QUESTION. It assumes that the LED is lit when the GPIO drive pin is high - as originally implied. - RM


If the GPIO output is 3.3 V and the LED Vf is 2 V, then this probably can be done with one external NPN transistor as an emitter follower. I say "probably" because the GPIO output voltage will decrease some depending on how much current it has to supply. That current should be pretty low, because an emitter follower is a non-saturating topology where the transistor is running at its max current gain.

3.3 V - 2.0 V = 1.3 V

1.3 V - 0.6 V = 0.7 V

0.7 V / 0.02 A = 35 ohms

Use a 33 or 36 ohm resistor as the LED current limiter. There is no resistor in series with the base because an emitter follower limits its own base current.

If the transistor, with a collector current of 20 mA, has a gain of 50, then the GPIO output has to source 0.4 mA. If the output voltage sags under that load current, decrease the LED resistor appropriately.

Here is the schematic:

enter image description here

\$\endgroup\$

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.