6
\$\begingroup\$

I'm trying to design a circuit that drives six LEDs - two red, two green, and two blue - off a 3.3V GPIO pin. Since the voltage drop on a blue LED is in that range, I'm attempting to step the voltage up with an LM318N and then drop it with a resistor. However, all the red and green ones are working when set up like this, but the blue ones are not.

LM318N LED config

Is this a reasonable setup to accomplish what I'm going for, or is there something wrong with the way I'm approaching this?

\$\endgroup\$
5
  • 5
    \$\begingroup\$ If you just want to PWM/on-off it, you can simplify it greatly using just one NFET and a resistor. But sure, an opamp would do the trick too if it have enough current sourcing capability on the output. Also, +1 for schematic, propper punctation and topic/subject. \$\endgroup\$
    – winny
    Jan 20, 2017 at 6:39
  • 1
    \$\begingroup\$ This comment is aimed at your edit from 2 hours ago. Change R3 from 15k to more like 1k. In this case, you are running Q1 as a saturated switch, so you want the base current to be around 1/10 or 1/20 of the collector current. If the collector current is 10mA, you want the base current to be around 1mA. Etc. With 15k, I would expect the circuit to run SOME current through the LED's, but maybe not enough to make them very bright. \$\endgroup\$
    – user57037
    Jan 21, 2017 at 1:21
  • \$\begingroup\$ @mkeith That ought to work, but it didn't, so I tried to isolate the problem. Even running voltage source to resistor to LED, pure and simple, nothing is happening. It's possible the LED isn't to spec - I just grabbed some from the lab. In any case, I seem to be stuck here, but thank you for your help. \$\endgroup\$
    – Dinesh
    Jan 21, 2017 at 3:49
  • 1
    \$\begingroup\$ Maybe you had the LED backwards. It is a diode, after all. It just happens to emit light when forward current flows. \$\endgroup\$
    – user57037
    Jan 21, 2017 at 5:59
  • \$\begingroup\$ @Dinesh please, don't ask a second question in your first one. It's both unlikely to help future visitors and confusing to current answerers. The best course of action would now be for you to remove the follow-up question about the new circuit (completely unrelated to "driving LED with 3.3V using op-amp") from here, and post it as a new question. \$\endgroup\$
    – user20088
    Jan 21, 2017 at 14:06

4 Answers 4

13
\$\begingroup\$

LM318 is only specified to drive to within 3v of either rail, it's not a rail to rail (R2R) output opamp. As you've got it supplied from the +5v pin, its output current into a 3v load will be low at best, and might be zero.

For a drop in replacement, find an amplifier that's got a R2R output.

It might be simpler to use a switch instead, a simple transistor or FET, or a 5v rail gate with 3.3v capable input like an HCT74xx part. LM339 makes a nice low current FET driver as well, output pulls close to ground, and the inputs are very flexible.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you! I've attempted to switch to a BJT switch, but I'm not too familiar with those and the LEDs still don't work... I think my resistor setup may be wrong. I've added the schematic to OP. \$\endgroup\$
    – Dinesh
    Jan 20, 2017 at 23:15
11
\$\begingroup\$

I don't think you need to boost the voltage to drive the LED. Just look for a blue LED with a low Vf. Also, there is no reason to use an op-amp.

Use this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

You may need to tune the resistor values a bit. This is a current source circuit. When the GPIO is high, you will get a fairly constant current of roughly 10mA through the LED over a wide range of voltages. This circuit performs much better than a simple current limiting resistor when you barely have enough voltage to drive the LED.

The basic idea is that R1 and R2 are a resistor divider from the GPIO voltage of 3.3V. They produce around 1.1V at the base of Q1. Q1 is not saturated. It is acting as an emitter follower, producing 1.1 - 0.6V at the emitter. This means that the emitter current is around 0.5V / R3.

The things you might want to do are lower R2 to get a smaller voltage at the base, and change R3 to change the operating current. Right now it is around 10mA, very roughly.

Also, since this circuit maintains a regulated current irrespective of voltage, you can potentially use an unregulated voltage for the LED. For example, a single cell lithium ion battery voltage, or 5V from USB. The LED will only turn on when the GPIO is high, no matter what voltage you use for the diode.

\$\endgroup\$
2
  • \$\begingroup\$ I'm not too familiar with circuits like this, so it may take some fiddling to figure out the right resistor values, but I will give it a try! Thank you! \$\endgroup\$
    – Dinesh
    Jan 20, 2017 at 23:17
  • \$\begingroup\$ Fiddle in a simulator first. Also see the equations. \$\endgroup\$
    – user57037
    Jan 21, 2017 at 1:17
6
\$\begingroup\$

A single transistor configured as a common emitter is enough to allow you to drive the LED from a Pi GPIO and using the Pi +5v line.

Q1 can be any jellybean NPN part such as a 2N3904, 2N4401 etc.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
1
  • \$\begingroup\$ This seemed to be the simplest approach so it's what I went with first, but it still doesn't seem to be working. I've added my schematic to OP -- I think my resistor values may be off. Thank you for the suggestion! \$\endgroup\$
    – Dinesh
    Jan 20, 2017 at 23:19
5
\$\begingroup\$

There are several flaws in the circuit.

Firstly you are loading the GPIO pin quite heavilly. When unloaded the pin will be at damn near 3.3V but when loaded down heavilly it may be substantially lower than that.

Secondly as others have pointed out your op-amp is nowhere near a rail to rail device.

In general using an op-amp for this seems rather silly. I would suggest you use a transitor switch configuration and use the transitor to control all the LEDs, not just the blue ones.

\$\endgroup\$
1
  • \$\begingroup\$ The op-amp is probably unnecessary, you're absolutely right - I've only worked with op-amps in theoretical problems, not in a physical circuit, so their limitations are a little fuzzy to me. I'm trying to switch to a transistor switch now - my schematic has been added to OP. Thank you! \$\endgroup\$
    – Dinesh
    Jan 20, 2017 at 23:18

Your Answer

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

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