Analog dimming of LEDs - Page 1
Forum section: electronics / beginners

author: NNoise
author_rank: Newbie
timestamp: August 05, 2020, 08:32:31 pm
content: Hey y'all!I'm working on this circuit, and I have 4 LEDs that I want to dim linearly, to visualise an analog voltage that's generated elsewhere in the circuit, essentially.So I'm wondering what's the easy/proper way to do analog dimming of LEDs ? Is there an LED driver that has analog "gain" for every LED channel ? I only found ON/OFF drivers or PWM drivers when I did a quick search on Mouser.So far, I have implemented basic analog dimming by using opamp feedback like so:Is there some IC that could be used like the following ?Or like this ?I *do* have an MCU on this project, but if I could keep this whole thing analog and PWM-free, I wouldn't mind.Cheers,

author: TimFox
author_rank: Super Contributor
timestamp: August 05, 2020, 09:21:01 pm
content: A quad op-amp and four small resistors would be simple. Your proposed circuit only saves three resistors. If using a single supply, be mindful of the input common-mode range. The output for the amp will be a bit more positive due to the LED.

author: laneboysrc
author_rank: Contributor
timestamp: August 06, 2020, 02:07:44 am
content: I don't know of any ICs with an analog input, but if digital (SPI) control would be OK then the TI TLC5940 could work.It has a "dot correction" feature that allows you do adjust the LED current in 63 steps (not PWM, but analog current control). IREF sets the max current, and dot correction allows you to reduce the current for each LED individually.

author: brucehoult
author_rank: Super Contributor
timestamp: August 06, 2020, 02:22:14 am
content: Quote from: NNoise on August 05, 2020, 08:32:31 pmI don't even know whether LED brightness varies linearly with current. It's certainly not at all linear with voltage. And current is a lot harder to control. There's probably a very good reason why everyone uses PWM to get linear control of LEDs and DC motors and so forth :-) As long as the frequency is high enough there's no reason not to.

author: TimFox
author_rank: Super Contributor
timestamp: August 06, 2020, 02:25:54 am
content: His op-amp circuit controls the LED current. Much of the non-linearity of light output vs. current is due to chip heating.

author: Ian.M
author_rank: Super Contributor
timestamp: August 06, 2020, 07:00:06 am
content: Usually, you want a linear perceived brightness response, but the human eye's response is far from linear. See comments here:https://www.eevblog.com/forum/beginners/correcting-led-pwm-brightness-curve-using-analog-stuffs-(no-programming)/

author: tooki
author_rank: Super Contributor
timestamp: August 06, 2020, 01:11:55 pm
content: Quote from: brucehoult on August 06, 2020, 02:22:14 amNo, it’s not linear with current, either. That’s why we can run white LEDs with homeopathic currents and still see them, while on the high end, adding more current has diminishing returns.

author: TimFox
author_rank: Super Contributor
timestamp: August 06, 2020, 01:29:39 pm
content: This article has a curve of output flux vs. current, taken from a Cree data sheet:http://andrewpearson.org/?p=643At a constant junction temperature (85 C in his example), the curve is close to linear.Of course, it will be closer to exponential as a function of voltage due to the I-V curve.As pointed out above, perceived brightness is approximately logarithmic in actual flux, an example of the Weber-Fechner law in psychophysics.White LEDs have phosphors included, which complicates the behavior.A simple addition to the op-amp circuit would be to apply a fixed voltage through an audio-taper potentiometer to the non-inverting input, however the OP wants an external variable control voltage. A kludge might apply the control voltage through a series resistor to a series string of forward-biased 1N4148 diodes to change the curve.

author: StillTrying
author_rank: Super Contributor
timestamp: August 06, 2020, 02:55:24 pm
content: Viewed with a photo diode I've found allindicatorLEDs to be very linear,pulsedeven up to ~300mA.www.eevblog.com/forum/beginners/floating-probe!-for-$2-50/msg1849505/#msg1849505That's a white @ 300Hz around 4 to 12mA, greens and blues can do >200kHz without doing anything special.But you still can't judge LED brightness by eye. If you made the current/brightness X1, X2, X4, X8, X16, X32, it would still be impossible to tell if it's currently on X4 or X8, or X8 or X16.For a very clear indication of clipping you'd probably have to use the 4 LEDs something like:1. Clipping.2. Nearly Clipping.3. Normal.4. Low.

author: TimFox
author_rank: Super Contributor
timestamp: August 06, 2020, 03:19:40 pm
content: I first dealt with this problem at work when we were worried about the linearity of a photosensor used in a radiation detector. A simple setup with a green LED and a DC supply with ammeter worked well until relatively high LED current, where we had both linearity and hysteresis problems, which were obviously due to thermal effects in the LED. I checked my reference book on opto-electronics (now in storage while I wait for bookcase delivery at home after retirement) and found the explicit equation for light flux output vs. current and temperature, which was in qualitative agreement with these results.

author: Unixon
author_rank: Frequent Contributor
timestamp: August 06, 2020, 05:49:24 pm
content: Quote from: NNoise on August 05, 2020, 08:32:31 pmWith a LED you're probably want to control current through the diode, not a voltage drop over its junction.So you may want to modify your first circuit, by swapping LED and resistor and placing LED between Vcc and opamp-resistor node.What power levels are we talking about? Is it for indication or lighting?

author: TimFox
author_rank: Super Contributor
timestamp: August 06, 2020, 06:07:59 pm
content: No, his first circuit controls the current through the LED, not the voltage across it. Note that the feedback compares the input voltage (at non-inverting input of op-amp) with the voltage across the resistor (proportional to the current through the LED). This is a common circuit to supply constant current to a floating load.

author: NNoise
author_rank: Newbie
timestamp: August 06, 2020, 06:47:51 pm
content: Linearity of the response is not an issue. My mistake, I should not have said "linearly", I just used the word to emphasize the analog rather than PWM.Like I said, it's just for indication, so to answer the question wrt current, a few tens of milliamps tops, a few milliamps if I use high-brightness LEDs.The reasoning behind using such an IC rather than the first opamp circuit is as follows:The entire design is a stack of multiple PCBs, the top one behind the interface, with the LED. The top PCB is pretty packed, so putting the driver on the PCB below is the prefered option. However, using an opamp, I need two connexions per LED between the top and bottom PCBs. Using such an IC, I'd only need N+1 connexions (N sinks/sources, and one VLED) for N LEDs.The complete design is likely to have 16 LEDs, so I'd much rather have 17 connexions than 32 (like I said, the top PCB is fairly packed already).However, I think maybe with some effort, I can cram 4 tssop14 opamps on the top board, thus using the first schematic for the 16 LEDs. Then I'd need the 16 pilot voltages, + the two power rails (or even just one power rail, as the pilot voltage is strictly positive). SO I can maybe still have 17 or 18 connexions at worst.

author: TimFox
author_rank: Super Contributor
timestamp: August 06, 2020, 06:58:08 pm
content: By the way, if you use dual-rail op-amps in this circuit, you should add a small diode in parallel with the LED to protect it against reverse voltage, since the reverse voltage could get high should the input go negative.

author: Unixon
author_rank: Frequent Contributor
timestamp: August 06, 2020, 07:51:51 pm
content: Quote from: TimFox on August 06, 2020, 06:07:59 pmArgh... I'm sorry I've misread his circuit. I was comparing it to OpAmp+MOSFET based current source I've recently used and it was arranged a little bit differently.

author: Unixon
author_rank: Frequent Contributor
timestamp: August 06, 2020, 08:00:49 pm
content: I was referring to this circuit:

author: jpanhalt
author_rank: Super Contributor
timestamp: August 06, 2020, 08:35:23 pm
content: There is a variety of LED controllers available.The AS1101 group take voltage (e.g., from a DAC or PWM + low-pass filter) to control current. The TI TCA6507 takes a digital input (I2C). Those are just two examples that I have used. There are many more.The salient point is that you have to control current, not voltage.

author: David Hess
author_rank: Super Contributor
timestamp: August 07, 2020, 12:59:17 am
content: LED brightness is only approximately linear over a small range of current but it is usually good enough for practical purposes.A much more linear output over a wider range can be produced by driving the LED with a PWM waveform and this is not much more complex when several LEDs are required because the triangle wave generator can be shared and each LED only requires a comparator.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 07, 2020, 03:54:44 pm
content: Several years ago I bought a bunch of PT4115 driver chips from Ali.These use a current shunt resistor and and inductor in series with a LED string and generate their own PWM signal, that should result in a fairly constant DC current because of the inductor.Setting the dimming level can either be through a PWM signal, or a DC voltage.When using PWM on the input the adjustment range is quite large, while with a DC voltage the dimming seems to be rather limited.Also:I would not pay too much attention to "lineairity", as your eyes are very far from linear, they are more like logarithmic over some 7 or mode decades. It's why you can see "normally" in bright sunlight and in semi twilight, and there are multiple arrangements built in, such as contraction of the iris and "night vision mode" which needs a few minutes to kick in some chemicals in your retina and only works with Black and White (Or is that considered a discriminatory term nowaday's?)Anyway. Eyes are pretty amazing appendages.The first photographs started in the 1820-ieshttps://en.wikipedia.org/wiki/Photographand it took some 200 years to make affordable cameras that surpass it. I think even most "phone" camera's are still worse in low light conditions then your biological eyes.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: August 07, 2020, 04:38:59 pm
content: From another post I just had an idea.Replace the opamp in your circuit with an LM317.The output is 1.25V higher then the adjust pin, which partly compensates for the voltage drop over the LED. It will have a "dead zone" at low input voltages.So if you have a pot with 0 to 5V on the adjust pin, the output swings to 1.25 to 6.25V.The LM317L in TO-92 is also quite small and cheap, but handles only upto 100mA, and dissipation of TO-92 is not great so it overheats easily.==============But in more general terms:Your opamp should transfer input voltage to the voltage over the shunt, and therefore the LED current pretty accurately, and LED brightness is somewhat lineair with current, but has big temperature effect and saturation.But the biggest "limit" are your amazing eyes, and the way your brain interprets it.Your brain interprets brightness in relation to the things around it.If you look at optical illusions of shadows, then it's hard to believe that 2 identical shades of grey are the same. Eyes are not optimized for stuff like this, and the same goes for brightness of a LED.https://duckduckgo.com/?q=optical+illusion+shades+of+gray&t=hk&iax=images&ia=images

author: RJSV
author_rank: Super Contributor
timestamp: August 08, 2020, 09:41:13 pm
content: Uh, Doctorandus_P, a question, as you might be able to help me (us):Someone working in medical often has expertise and background in basic Neurology concepts. I'm hoping to find a good textbook for bridging between Optical related (medical) and an EE 'dorkus', like me.Containing things like "...brain region performs an equivalent of Fourier Transform... edge detection..."That sort of textbook. Any ideas ?