Alternating analog LED fader

Introduction

There are 2 approached to linearize the LED brightness perception. We can choose between an open loop approach or a closed loop approach.

  • The closed loop approach uses an LDR to measure the LED light intensity. This signal is converted into a current using a current mirror. A linear triangular waveform is used as the source for the fader and is also converted to a current using a current mirror. The measured light current is subtracted from the triangular waveform current. The LED is fed with the resulting current, so the LED current changes exponentially, as the LDR resistance to light intensity curve is logarithmic. The human eye will perceive this as a linear changing brightness due it's logarithmic brightness perception curve.

  • In the open loop approach, we need to add a quadratic or exponential growing current so the human eye perceives the fading as a linear changing brightness. This can be done with an anti-log or exponential amplifier using an OPAMP, but i found a simpler circuit that is based on a current mirror and generates a quadratic function using 2 diodes in reference "leg" of the current mirror.

Closed loop approach

Triangular waveform generator used as a source for the linear LED fader

For our LED fader, we need a voltage source that generates a linear increasing and decreasing voltage.
We also want to be able to change the fade in and fade out period individually.
For this purpose we use a symmetrical triangular waveform generator that is constructed using 2 OPAMPs of an old workhorse : LM324.

The triangular waveform generator is build with a general purpose (non rail-to-rail) LM324 OPAMP.
U1A is configured as a Schmitt trigger using positive feedback to create the necessary wide hysteresis. U1B is configured as an integrator by using C1 in the negative feedback loop.
The integrator output is connected to the Schmitt trigger input, and the Schmitt trigger output is connected to the integrator output.
The frequency and symmetry of the triangular waveform can be adjusted with D1, respectively D2. The frequency control components are put in parallel with the symmetry control components because that way the symmetry control has less effect on the frequency, then when both controls would be in series.
Q1 and Q2 buffer the output of U1B and act as a current booster for charging and discharging C1.
R8 is added for stability and to minimize the effect of the emitter followers Q1 and Q2 on the output of U1B.

Click here to download the LTSpice simulation of the triangular waveform circuit

The oscilloscope picture below shows the voltage at the output of the buffer formed by Q1 and Q2 :

Linear LED fading circuit using an LDR as a logarithmic feedback element

To linearize the brightness of a LED, an LDR is used as a feedback element in a closed loop arrangement. Because the LDR resistance versus light intensity is logarithmic, it is a suitable candidate to do the job.
Q1 and Q2 form a current mirror that converts that output voltage of the triangular waveform generator into a current via R1, which is in the "reference leg" of the current mirror. The current through Q1 is mirrored to Q2, so the same triangular current flows through Q2.

D1 is there because the output of the triangular waveform generator does not fully swing to zero, because i'm not using a rail-to-rail but an easy obtainable general purpose OPAMP in the triangular waveform generator.
The LED is connected to Q2, but also the Q3, that is part of a second current mirror.
Q3 and Q4 form a current sourcing mirror (See : Current mirrors). The LDR is put in the "reference leg" of this current sourcing mirror, so the resistance of the LDR determines the current generated by this mirror. The more light falls on the LDR, the lower it's resistance and the higher the current through Q4 will be. The current through Q4 is mirrored to Q3, which is connected to Q2. So now we have to think in currents and not in voltages anymore.

Q2 sinks a triangular current I1 and Q3 sources a current I2, that is directly related to the amount of light that falls on the LDR and follows a logarithmic curve.
I3 is the current through the LED and is the result of the linear triangular current I1 minus the logarithmic LDR current I2, which is an exponential current.
And that is exactly what we need to linearize the brightness of a LED. Because an exponential current is driven through the LED, the perceived brightness will change in a linear way, which has a much better fading/dimming effect than just running a linear current through the LED.

The picture below shows how to assemble a RGB LED (left side) and an LDR (right side) using shrinking tube :

The oscilloscope picture below shows the voltage over R6 (=10E), that represents the current through the LED :

Open loop approach

Open loop linear LED fading circuit using a current squarer to get a semi-exponential current

Click here to download the LTSpice simulation for the current squarer

Because LED/LDR combinations are not standard components, i searched for other ways to generate an exponential or squaring current through a LED in an open loop configuration. The result is the circuit above..

Q1 and Q2 form a current squaring circuit that is based on a current sinking mirror. R1 converts the triangular output voltage, which is first divided using P1, to a current, flowing through Q1. But the emitter of Q1 is not connected to ground via a resistor, but via 2 diodes. The 2 diodes will have a squaring effect on the current through Q1. This current is mirrored to Q2, so I2 has the same squaring curve.
Q3 and Q4 form a constant current sinking source. The LED is connected to this constant current source but also to the current sinking mirror Q1 and Q2. So the current through the LED is the result of the constant current I1 minus the squaring current I2, which is an semi-exponential current I3.
This exponential current through the LED will result in a nice linear fading of the perceived brightness of the LED.

The oscilloscope picture below shows the voltage over R2 (=180E), that represents the current I2, which is subtracted from the constant current I1 :

Combined open loop and closed loop approach

Combining the open and closed loop approach results in a alternating linear LED fader circuit

Because the LED current in the open loop circuit is inverted when compared to the LED current in closed loop circuit, we can combine both circuits to create an alternating LED fader in which one LED fades in while the other fades out and vise versa.

Pictures

Video