Fade LED with minimal components

Thread Starter

k1ng 1337

Joined Sep 11, 2020
101
Hi I would like to create a simple fade in and fade out effect ideally for a common anode RGB but I will settle for a single colour LED.

Design requirements:

- fade in 0-5v LED + resistor
- fade out 5-0v LED + resistor
- incorporate BJT or MOSFET driven by 5v CMOS logic IC

To reiterate: CMOS logic signal -> BJT / MOSFET -> fade in / out LED


This project comprises LEDs that switch at frequencies less than 1hz so I would like the effect to be as linear as possible. I suppose this topic is about fading the switching signal into the transistor not the LED but I don't see why it couldn't happen after the transistor switches. I imagine this can be accomplished with resistors and capacitors only.

Regards,
 
Last edited:

LowQCab

Joined Nov 6, 2012
1,099
Did You know that You can buy an LED that Does this all by its self ?
With no external parts.
Or are You just seeing if You can do it DIY style ?
.
.
.
 

DickCappels

Joined Aug 21, 2008
7,717
I'll volunteer this circuit. It is a flashing caboose light for a friend's model railroad a few years ago. Simulates the fast turn off and slow cool down of the filament of a light bulb. Easily modified.

1626426456521.png
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
101
Looks like R5 R10 C3 Q3 and possibly R6 C4 Q4 provide the effect you describe, can you elaborate on what's happening? Algebra preferred :)
 

Reloadron

Joined Jan 15, 2015
6,063
- fade in 0-5v LED + resistor
- fade out 5-0v LED + resistor
- incorporate BJT or MOSFET driven by 5v CMOS logic IC
As pointed out fading a LED in and out using voltage and subsequently current (a LED is a current driven device) is not a good idea. Using PWM (Pulse Width Modulation) is the typical approach. You can use discrete components or just a single uC (micro-controller) chip with minimal code. Complexity depends on what you really want for effects. Using a RGB LED you can also easily change colors or just a plain LED fade in and out a single color. A single chip and transistor or single chip and three transistors, whatever you want?

Ron
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
101
I've used PWM via 555 and Arduino elsewhere, this topic is for a class of projects that I refer to as "old fashioned".. using the most basic building blocks possible ie. discrete components the way the pioneers in the industry did. I like this approach because I'm both fascinated by simplicity in design and it helps me understand what's happening at the most basic level and then I can see (and not see) first hand what may need to be improved.

Another example project would be an OP amp.. do I expect to work good or at all? Na. Do I want to try? At least once :)
 

DickCappels

Joined Aug 21, 2008
7,717
Looks like R5 R10 C3 Q3 and possibly R6 C4 Q4 provide the effect you describe, can you elaborate on what's happening? Algebra preferred :)
The circuit can be thought of as being made from three major blocks: an LED Power Supply Oscillator/Driver, a Blink Rate Oscillator, and a Power Modulator to modulate the drive power to the LED, thus blinking it on and off. The discussion of the LED Power Supply Oscillator / Driver assumes that the LED is "on" -that is the signal from the Blink Rate Oscillator is always high, and this is modeled in the circuits in the description of the LED Power Supply Oscillator / Driver by showing the emitter of Q2 grounded.

1626505539761.png
Figure 2. The basic 1.5 volt LED Power Supply provides
pulses up to 3 volts peak with which to drive the LED.

The Led Power Supply Oscillator / Driver shown in Figure 2 is a pretty good little 1.5 volt LED power supply. An oscillator, a bistable multivibrator made of Q1 and Q2 oscillates at about 15 kHz with approximately a 50% duty cycle. There are many explanations of multivibrators on the web, so I will not discuss it here, except to say that the main weakness of this kind of oscillator is that if it ever stops, it needs to be "kicked" back into oscillation. A suitable "kick" can be made by disconnecting and reconnecting the battery. Don't worry, its unlikely that the oscillators will stop spontaneously. If your oscillator ever stops while power is applies, it will most likely be the result of an intermittent connection of a temporary short circuit. These oscillators are very reliable.

The collector of Q2 drives a low value resistor so this stage it can supply enough current to drive the LED. The only problem here, is that the pulses coming from the collector of Q2 are about 1.4 volts peak-to-peak, and a red LED needs close to 2 volts to operate. The trick that gets around the problem is to alternately charge a capacitor to 1.5 volts, then place it in series with the 1.5 volt battery and and LED, so the LED can get up to 3 volts.

1626505628881.png
Figure 3. C3 is alternatively charged then discharged
to provide a high enough voltage to drive the LED.

Figure 3 shows the part of the circuit that converts the 1.5 volt battery voltage into a drive signal of up to 3 volts for the LED. The collector of Q2 switches between ground and +1.5 volts through the 100 ohm resistor at about 15 kHz because it is part of an oscillator.

1626505684849.png
Figure 4. The 100 Ohm resistor limits the current available to charge C3.

During one half cycle of the 15 kHz oscillation, which lasts about 30 microseconds, Q2 turns off. The collector of Q2 is connected to the end of resistor R4 that is not connected to the battery. This end of R4 rises toward + 1.5 volts and provides base current to Q3 through base resistor R5, causing Q3 to saturate and to hold the negative end of C3 at ground. The positive end of C3 charges to up toward 1.5 volts through R4 during this period. The actual voltage that C3 charges to is dependent on how much C3 had discharged during the discharge cycle.

During the charging up half cycle, the LED in figure 3 does not conduct because the voltage across it is only about 1.5 volts.

At this point, C3 is charged to up to 1.5 volts.

1626505728104.png
Figure 5. R10 limits the discharge current through the LED.

To get the LED to light up, C3 is placed in series with the LED. This happens when Q2 turns on. Assuming that C3 is charged all the way to +1.5 volts. When Q2 turns on, the positive end of C2 is connected to ground, forcing the negative end of Q2 to go to negative 1.5 volts (see photo 2). The LED and R10 would then have 3 volts across them. The current during this half cycle is limited mostly by R10. If R10 is made 0 ohms, then a higher peak current, and a brighter LED can be obtained.

This circuit is meant to drive a red LED for direct viewing - in other words, in a case in which the viewer looks directly at the LED rather than looking at a scene illuminated by the LED. As such, in most cases, the LED should not be very bright. The luminance of the LED can be reduced by increasing either R4 or R10. The benefit from increasing R4 is that doing so will result in a lower battery current than would be obtained by increasing R10 to obtain the same luminance. R4 can only be increased until the voltage when Q2 is off does not go high enough to turn on Q3. Once that point is found, further dimming can be obtained by changing R10. If you are not particularly miserly about battery current, you can just simple adjust R10 for the luminance you desire.

Before we leave R10 - you don't really need it. If you leave it out completely, the peak current in the LED will be limited by the equivalent series resistance of the battery, capacitor C3, and the characteristics of Q2.

1626505769703.png
Figure 7. Q4 is the power modulator.

It would be a simple matter to use the Blink Signal to control the output of the LED Power Supply Oscillator/Driver circuit. One way would be to connect R2 to the Blink Signal. When the Blink Signal is low, the LED Power Supply Oscillator/Driver would not oscillate, and the LED would not light up. But one of the goals of this project is to get the LED to fade up then fade down in luminance. Therefore, just stopping and starting the power supply won't quite cut it.

The power to the driver, of which Q2 is part, is controlled by Q4. If C4 were not present, the Blink Signal from the Blink Rate Oscillator would simply switch Q4 on and off. When Q4 is off, the emitter of Q2 floats and the LED Power Supply Oscillator/Driver circuit does not oscillate, so there is no light from the LED. When Q4 is saturated (on), the emitter of Q2 is connected to ground, and the LED Power Supply Oscillator/Driver circuit both oscillates and supplies power. In some parts of the range of operation of Q4 when Q4 is between being off and being saturated, the LED Power Supply Oscillator/Driver circuit operates but does not supply full power to the LED. It is the controlled transition of Q4 between being off and being saturated that allows us to fade the LED from off to full luminance and then back down.

Here is how it works:

When the Blink Signal into R6 is low, Q4 is off. When the Blink Signal goes high, Q4 begins to draw current, and its collector voltage begins to drop. As the voltage starts to drop, it causes current though C4 which opposes the current through R6 from the blink signal. This reduces the base current into Q4, and slows the transition of Q4's collector voltage between the off and saturated states. During the transition, the more current Q4 draws through its collector, the more power is available to the driver stage to drive the LED, and the higher the luminance of the LED.

This effect also occurs when the Blink Signal goes low, causing Q4 to make the transition from saturated to off.

Operation in the region between on and off occurs over about 200 milliseconds. The rate of change is controlled by the values of C4 and R6. Since R6 needs to be this low (1k) in order to keep Q4 saturated when Q2 is on, C4 needs to be this large to get a 200 millisecond transition. A longer transition would require a larger value for C4. A faster transition would require a smaller value for C4.

When operating, the average current drain is about 8 milliamps when powered from a 1.5 volt battery.

That pretty much sums up operation of the circuit.

This was designed for somebody who did not have the knowledge or tools to use a microcontroller and who preferred to not use integrated circuits.

Per @Reloadron in post #6: A little 8 pin (or six pin for that matter) controller with a minimal amount of memory outputting PWM would have done well and for some would be the best course of action.
 

MrChips

Joined Oct 2, 2009
24,207
I believe another technique is to use two square waves of slightly different frequencies and feed them to a D-type flip-flop or an XOR gate.
 

ErnieM

Joined Apr 24, 2011
8,179
Going linear isn't that tough. I once created a LED light that was spec'd to run over 8 to 28 VDC in, and over that range produce the same intensity curve as an incandescent bulb it was intended to replace.

I nailed the curve (it was a given as part of the spec) by using an A2D to measure the applied voltage and match that to a piecewise linear brightness curve. The PWM setting was the same as the brightness, ie for 25% brightness set the PWM to 25%.

I may have access to the project come Monday.
 

Thread Starter

k1ng 1337

Joined Sep 11, 2020
101
The circuit can be thought of as being made from three major blocks: an LED Power Supply Oscillator/Driver, a Blink Rate Oscillator, and a Power Modulator to modulate the drive power to the LED, thus blinking it on and off. The discussion of the LED Power Supply Oscillator / Driver assumes that the LED is "on" -that is the signal from the Blink Rate Oscillator is always high, and this is modeled in the circuits in the description of the LED Power Supply Oscillator / Driver by showing the emitter of Q2 grounded.

View attachment 243762
Figure 2. The basic 1.5 volt LED Power Supply provides
pulses up to 3 volts peak with which to drive the LED.

The Led Power Supply Oscillator / Driver shown in Figure 2 is a pretty good little 1.5 volt LED power supply. An oscillator, a bistable multivibrator made of Q1 and Q2 oscillates at about 15 kHz with approximately a 50% duty cycle. There are many explanations of multivibrators on the web, so I will not discuss it here, except to say that the main weakness of this kind of oscillator is that if it ever stops, it needs to be "kicked" back into oscillation. A suitable "kick" can be made by disconnecting and reconnecting the battery. Don't worry, its unlikely that the oscillators will stop spontaneously. If your oscillator ever stops while power is applies, it will most likely be the result of an intermittent connection of a temporary short circuit. These oscillators are very reliable.

The collector of Q2 drives a low value resistor so this stage it can supply enough current to drive the LED. The only problem here, is that the pulses coming from the collector of Q2 are about 1.4 volts peak-to-peak, and a red LED needs close to 2 volts to operate. The trick that gets around the problem is to alternately charge a capacitor to 1.5 volts, then place it in series with the 1.5 volt battery and and LED, so the LED can get up to 3 volts.

View attachment 243763
Figure 3. C3 is alternatively charged then discharged
to provide a high enough voltage to drive the LED.

Figure 3 shows the part of the circuit that converts the 1.5 volt battery voltage into a drive signal of up to 3 volts for the LED. The collector of Q2 switches between ground and +1.5 volts through the 100 ohm resistor at about 15 kHz because it is part of an oscillator.

View attachment 243764
Figure 4. The 100 Ohm resistor limits the current available to charge C3.

During one half cycle of the 15 kHz oscillation, which lasts about 30 microseconds, Q2 turns off. The collector of Q2 is connected to the end of resistor R4 that is not connected to the battery. This end of R4 rises toward + 1.5 volts and provides base current to Q3 through base resistor R5, causing Q3 to saturate and to hold the negative end of C3 at ground. The positive end of C3 charges to up toward 1.5 volts through R4 during this period. The actual voltage that C3 charges to is dependent on how much C3 had discharged during the discharge cycle.

During the charging up half cycle, the LED in figure 3 does not conduct because the voltage across it is only about 1.5 volts.

At this point, C3 is charged to up to 1.5 volts.

View attachment 243765
Figure 5. R10 limits the discharge current through the LED.

To get the LED to light up, C3 is placed in series with the LED. This happens when Q2 turns on. Assuming that C3 is charged all the way to +1.5 volts. When Q2 turns on, the positive end of C2 is connected to ground, forcing the negative end of Q2 to go to negative 1.5 volts (see photo 2). The LED and R10 would then have 3 volts across them. The current during this half cycle is limited mostly by R10. If R10 is made 0 ohms, then a higher peak current, and a brighter LED can be obtained.

This circuit is meant to drive a red LED for direct viewing - in other words, in a case in which the viewer looks directly at the LED rather than looking at a scene illuminated by the LED. As such, in most cases, the LED should not be very bright. The luminance of the LED can be reduced by increasing either R4 or R10. The benefit from increasing R4 is that doing so will result in a lower battery current than would be obtained by increasing R10 to obtain the same luminance. R4 can only be increased until the voltage when Q2 is off does not go high enough to turn on Q3. Once that point is found, further dimming can be obtained by changing R10. If you are not particularly miserly about battery current, you can just simple adjust R10 for the luminance you desire.

Before we leave R10 - you don't really need it. If you leave it out completely, the peak current in the LED will be limited by the equivalent series resistance of the battery, capacitor C3, and the characteristics of Q2.

View attachment 243766
Figure 7. Q4 is the power modulator.

It would be a simple matter to use the Blink Signal to control the output of the LED Power Supply Oscillator/Driver circuit. One way would be to connect R2 to the Blink Signal. When the Blink Signal is low, the LED Power Supply Oscillator/Driver would not oscillate, and the LED would not light up. But one of the goals of this project is to get the LED to fade up then fade down in luminance. Therefore, just stopping and starting the power supply won't quite cut it.

The power to the driver, of which Q2 is part, is controlled by Q4. If C4 were not present, the Blink Signal from the Blink Rate Oscillator would simply switch Q4 on and off. When Q4 is off, the emitter of Q2 floats and the LED Power Supply Oscillator/Driver circuit does not oscillate, so there is no light from the LED. When Q4 is saturated (on), the emitter of Q2 is connected to ground, and the LED Power Supply Oscillator/Driver circuit both oscillates and supplies power. In some parts of the range of operation of Q4 when Q4 is between being off and being saturated, the LED Power Supply Oscillator/Driver circuit operates but does not supply full power to the LED. It is the controlled transition of Q4 between being off and being saturated that allows us to fade the LED from off to full luminance and then back down.

Here is how it works:

When the Blink Signal into R6 is low, Q4 is off. When the Blink Signal goes high, Q4 begins to draw current, and its collector voltage begins to drop. As the voltage starts to drop, it causes current though C4 which opposes the current through R6 from the blink signal. This reduces the base current into Q4, and slows the transition of Q4's collector voltage between the off and saturated states. During the transition, the more current Q4 draws through its collector, the more power is available to the driver stage to drive the LED, and the higher the luminance of the LED.

This effect also occurs when the Blink Signal goes low, causing Q4 to make the transition from saturated to off.

Operation in the region between on and off occurs over about 200 milliseconds. The rate of change is controlled by the values of C4 and R6. Since R6 needs to be this low (1k) in order to keep Q4 saturated when Q2 is on, C4 needs to be this large to get a 200 millisecond transition. A longer transition would require a larger value for C4. A faster transition would require a smaller value for C4.

When operating, the average current drain is about 8 milliamps when powered from a 1.5 volt battery.

That pretty much sums up operation of the circuit.

This was designed for somebody who did not have the knowledge or tools to use a microcontroller and who preferred to not use integrated circuits.

Per @Reloadron in post #6: A little 8 pin (or six pin for that matter) controller with a minimal amount of memory outputting PWM would have done well and for some would be the best course of action.
Thanks Dick for the detailed analysis, I will be sure to review and implement it on the breadboard when I have the proper apparatus in front of me. In the meantime you helped me apply an important principal to my understanding: Power In = Power Out. Concerning my original question - you have combined the exponential characteristics of the capacitor and LED as well as the resistor(s) to create a predictable waveform for the LED. Therefore you made the capacitor into a variable voltage/current source of finite and predictable value (charge) to ultimately bias the LED. Please feel free to correct my reasoning.

Very cool stuff, I won't bombard you with questions (at this time) that could be answered via the oscilloscope and breadboard but until then I would be most interested to see the graphs of simulations you may have conducted for your project.
 

DickCappels

Joined Aug 21, 2008
7,717
I think your reasoning is pretty good.

The circuit was tweaked so that the LED would come on quickly then fade a little slower as an old incandescent bulb would. It simulated a 1960's caboose light.

I did not simulate the circuit before building it and I did not take photographs of waveforms. That was done before I started using LTspice and other available releases of SPICE (within budget) were without schematic capture and just too much trouble to use when I had a scope right there on my bench.
 
Top