# Op amp controlled LED current

I'm trying to implement a simple current control circuit for an LED from here: https://www.allaboutcircuits.com/technical-articles/the-basics-behind-constant-current-led-drive-circuitry/

The principle of the circuit seems straight forward- the voltage at the inverting input should be controlled by the current passing through the resistor, which in turn is the current passing through the LED minus the input current of the op-amp (1 pA according to the datasheet). For the control voltage on the non-inverting input I am using a DAC output from a microcontroller.

My problem - even when my control voltage is zero my LED lights up. In fact for 0V input I am getting 2.4V across my diode and 0V across the load resistor which corresponds to about 5mA of current through the diode.

With increased control voltage the voltage starts to increase across the resistor but the output soon saturates. and the voltage across the resistor does not match the control voltage. The op amp I am using is a MCP6241 which is a single supply rail-to-rail op amp and I'm running it at VCC = 3.3V. So I am guessing this may be something to do with the single supply?

Is there a solution using this op-amp?

• search for "voltage controlled current source opamp". You'll find millions of schematics that include the missing transistor in your schematic. Oct 20, 2020 at 19:20
• Thanks Marcus. I have used the transistor based design before but I came across this design without a transistor and was interested to see if it worked. I guess it doesn't! But I'm trying to understand why it doesnt. Oct 20, 2020 at 19:31
• Looks like you have a bit of input offset, a few mV, and the op-amp is correcting for this by raising the output - normal behavior. But since the I-V curve for an LED is essentially flat up to a volt or two, the op-amp has to raise the output to at least this level before significant current starts to flow through and raise the voltage at the non-inverting input.
– vir
Oct 20, 2020 at 19:31
• Ah right, that makes sense. Could that be compensated for by an offset on the other input? Oct 20, 2020 at 19:34
• Your best bet is probably to use an op-amp with an offset adjust or add a pass element as Marcus suggested. You potentially could bias up the inverting input so that it was at a few mV with no current flowing through the diode. Bias at the non-inverting input would have to be negative. Also, I said non-inverting input in the previous comment, it's the inverting input that sees the change when current through the LED goes up.
– vir
Oct 20, 2020 at 19:45

The chosen opamp MCP6241 is quite suitable for this application as it is rail-to-rail input/ouput, and Vcc as low as 1.8v.
You have two options to handle it:
1) add a resistor between Vcc and inverting-pin of opamp. Because when the + pin is zero, the - pin tries to reach zero as well but because of input-offset, an error appears on the output. so you have to make sure that with zero input on + pin, there's a "near-zero but above-zero" voltage on - pin.
Choose it's value as high as possible, for example in range of 10Kohm, a value so much bigger than the the resistor in series with LED. Also, you's better add a capacitor between - pin and GND, in case of any potential instability.
2) add a high value resistor in parallel with the LED.
I suppose the latter solution works better.
To solve your second problem you could use a lower value for the resisor R; and also add a voltage divider (resistor-divider) in front of + pin. In this case a fraction of input voltage is applied to the + pin. So your input voltage range can be 0 to Vcc, while, for instance, 1/5 of this range appears on + pin and consequently on - pin, which provides a good range of current on LED.

1. Clearly that circuit not work well with near zero reference voltage. Maybe input voltage offset of the opamp.
2. The resistant value is very sensitive if you choose to low then the offset voltage can cause more current at zero voltage ref. as I = V/R. if you select too high value then the current will satterate at low value. the maximum voltage across resistor can't exceed 3.3V - Vf which Vf is forward voltage of led.
3. the best condition for this, you need higher supply voltage for led and higher resistant value. BTW if you want to control LED with MCU why don't just use PWM?
• I am developing a student activity to demonstrate that LED optical output is proportional to current so I am looking for ways to directly modulate the current through the diode rather than just adjust the integrated apparent brightness. I liked this circuit because it seemed a little more direct than the method using the transistor. However from the answers I've had and my own experiments it seems to have other subtleties so that make it more interesting! Oct 20, 2020 at 21:23
• Also point 2 was very useful. The diode I orginally was using was a blue LED and its forward voltage was around 3V which was why it saturated so quickly, switched to a lower bandgap red LED which gives more headroom for the current sense resistor Oct 20, 2020 at 21:25
• If that is your purpose. If I were you facing this problem I will use the circuit to control voltage that apply to both resistor and LEDs then measure current. so we can control current based on controlled voltage. this method might use to avoid this problem. Oct 20, 2020 at 21:33