1
\$\begingroup\$

I'm making a constant current LED driver out of 2 2N2222 transistors and a couple of resistors. Works great. I added a PWM signal to the input so I could dim the LED, also works great.

The problem is, I'm using this LED driver for a video camera, as the shutter speed is very fast(Like 1/100000) the PWM dimming is not usable, as the camera flickers.

Is that possible to make the LED current proportional to the PWM duty cycle, and not like on/off, like a low pass filter but for the current :)

Here is my circuit:

enter image description here

Here is my LED current:

enter image description here

I'm using a single 5050 LED package with 3 diodes in it, 20mA each LED. I need to set the brightness and leave it. Eventually, I need to change it after some time, but not often.

\$\endgroup\$
2
  • \$\begingroup\$ You could put an inductor in series with the LED and then add a freewheeling diode to allow the current to flow through the LED and inductor when the PWM is off. \$\endgroup\$
    – Aaron
    Commented Jul 22, 2020 at 16:08
  • \$\begingroup\$ I tried simulating, but I got a lot ringing... but I'll try a little bit more on this subject. thanks \$\endgroup\$
    – 0x3333
    Commented Jul 22, 2020 at 20:15

2 Answers 2

1
\$\begingroup\$

You can indeed filter the PWM to control a current source. You can use something like the following. I will assume you just want to set the brightness and leave it on, then take the picture. If you are trying to turn on the LED as fast as the shutter, like a flash setup, this will not work. Also since you are using 2n2222, I will assume relatively low LED current.

enter image description here

This acts as a PWM DAC. Note that this will be rather slow depending on your PWM frequency. So if you need to change the brightness quickly, you may want to use a real DAC. Also, even with a 4pole filter, you may get a small amount of ripple on the output. Make sure this is small enough to not be an issue for your application.

Now we don't know your specific setup, but the values of R1, R2 and the filter values will depend on:

  1. Your PWM Voltage and Frequency
  2. The LED your driving. Really what the forward voltage is at the currents you want.
  3. The LED voltage source
  4. Your desired LED current range. Say 5mA to 30mA.

So this particular circuit will need to be adjusted to your needs. So some design tips.

To utilize the full PWM voltage range 0-3.3V or 0-5V, to give you the largest range of current control, you want the voltage across R2 to be the max PWM voltage 100% duty cycle at the max current you want.

So 3.3V/MaxCurrent = R2

But you need to make sure that the resistor that gives you that value actually allows that current. If you are using a white LED with a 3V drop at the current you need:

(5-3)/R2 = Max Current (not accounting for Vce of the transistor to make it simple).

So you may not find an optimal solution that gets you full scale dimming. You will either have to sacrifice the range you can control, or the max current you can use, or change the PWM voltage, or change the LED source voltage.

You can find a good technical app note on PWM DAC design from TI here. https://www.ti.com/lit/an/slaa497/slaa497.pdf?ts=1595430920134&ref_url=https%253A%252F%252Fwww.google.com%252F

R1 can be chosen so that the max base current (when opamp output is at Vcc-100mV) allows the max collector current you are designing for. You will want to use a rail to rail single supply opam, and keep it within it's linear output range.

Side note:

There can be quite a bit of design involved in such a simple setup. So in the end, you can always just use a pre-made solution. There are lots of LED drivers out there. Like this one:

https://www.digikey.com/product-detail/en/diodes-incorporated/AL8862QSP-13/31-AL8862QSP-13CT-ND/10670162

Or this one with multiple outputs and an SPI interface:

TLC5926IPWPR

\$\endgroup\$
3
  • \$\begingroup\$ You just nailed it. I imagined that I'd need to do a ampop... I have a couple of BCR421UW6 here with me, do you believe that the ampop would work on the EN pin? The datasheet isn't clear if I can put a variable voltage in the en pin... the internal configuration is basically the same as the output stage in your schematic. \$\endgroup\$
    – 0x3333
    Commented Jul 22, 2020 at 17:20
  • \$\begingroup\$ I should be technically correct here. Technically you can use the BCR421UW6 and vary the EN voltage to adjust the output current. See the graph on page 5 for Ven vs Iout. With an external resistor of 6 ohms you can get a non-linear current adjustment from 0-130mA if you vary Ven from 0.5V to 4.5V (given a Vout of 2V). So you could use Rext as the feedback to the opamp. On page 6 you can see how the Iout changes with temperature as well. So a 20 Ohm Rext will give a Iout range of 0-50mA and vary only about 10mA for a large temp range. If you don't need a linear response, you can give it try. \$\endgroup\$ Commented Jul 22, 2020 at 18:21
  • \$\begingroup\$ I don't need a linear responde anyway, just a way to control it when needed. Thanks again! \$\endgroup\$
    – 0x3333
    Commented Jul 22, 2020 at 20:14
0
\$\begingroup\$

EDIT: After your comment in which you have indicated the need for PWM control with Raspberry Pi, here is a schematic for that.
R1 and C1 form a low-pass filter which turns the PWM pulses into a proportional DC current with low ripple.

schematic

simulate this circuit – Schematic created using CircuitLab

Based on your situation, you don't need a PWM controller, since you are using very little power, which is a triple white LED with a total maximum current of 60mA running at ~3V and supplied with 5V.
PWM is used with larger currents and powers. In your circuit, the worst case scenario is the transistor running the full 60mA with about 2V across it, making it dissipate only about 120mW, significantly below its maximum rating.
Add to that the fact that you have a 50Ω resistor in series with it which would be dropping 3V at the full current (60mA), and hardly any power will be dissipated by the transistor. You wouldn't actually be able to reach 60mA even with the resistor alone because the voltage drop across it in series with the LED would add up to around 6V, higher than your supply voltage.
So, in your case PWM is an overkill and an unnecessary complication, especially considering its application in photography.
You could simply run your LEDs in series with any potentiometer, a plain switch, and a protection resistor (to limit maximum current) like this:

schematic

simulate this circuit

\$\endgroup\$
2
  • \$\begingroup\$ Unfortunately, I was not clear in my question, I need to control it digitally, from a Raspberry Pi. I could you a DAC and a transistor, by the way. Thanks for your answer. \$\endgroup\$
    – 0x3333
    Commented Mar 26, 2023 at 13:15
  • \$\begingroup\$ @0x3333 I have added another schematic to my answer, which should work in your situation. \$\endgroup\$ Commented Mar 27, 2023 at 5:22

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.