Jump to content
Electronics-Lab.com Community

LED dimmer


Recommended Posts

Hey all,


I want to make an LED dimmer, that has about 5 LEDs hooked up to a 12VDC supply.  They should gradually  approach their (near) max brightness. But I want this to be done with user intervention. I just close the switch and the brightness increases (and also the opposite must happen when I open the switch). Can this be done by a capacitor whose charging time is controlled by a resistor? Please tell me the several ways of doing this.

--thank you.

Link to comment
Share on other sites


Here's one I knocked up. The trouble with LEDs is that their apparent brightness does not change linearly with current, so this design might not be as smooth as you want. But it works.

It's a ramp generator - press the switch and the voltage at Q2's collector slowly and linearly drops, gradually powering up the LEDs, release the switch and it rises.

Choose LED current limiting resistors as you would normally, for the supply voltage in use.

As it is, this circuit's output voltage changes at about 3V/s, meaning it completely lights up after 4s with the switch pressed, and takes another 4s to completely extinguish with the switch open again. You can choose a different capacitor value to change this duration:

C = 2.5e-6 * T

where T is the time taken to fully illuminate or extinguish.

I used a darlington pair, because I have no idea what kind of current your LEDs require. Q1 can be any small NPN signal transistor. I used a BC108. Q2 will depend on the total current you need for your LEDs. If you need more than a total of 50mA for all of the LEDs, I suggest you use a chunky transistor like a TIP31.

What I'd really like to do, to make the lighting and dimming more linear, is pulse power to the LEDs and change their brightness by modifying the pulse's duty cycle, a la PWM. So I'm going away now to play with that idea.

post-20531-14279142963932_thumb.png

Link to comment
Share on other sites

Hey Cabwood, thanks for youre reply. But you said that the voltage linearly drops across the collector of Q2, do we really need to have the transistor in there. Couldnt this be accomplised by just the charging and discharging action of the capacitor? Also I dont understand the need for a dralington pair.

thanks again

Link to comment
Share on other sites

I can't imagine a way of causing the lights to slowly dim AND slowly light without the use of a huge capacitor (or two - each 20000uF or more) and a double pole switch. Even then the initial charge/discharge rate of the capacitors will be high, dropping off with time, meaning there won't be a smooth transition from light to dark and vice versa. The use of transistors simply makes everything smooth and small.

Link to comment
Share on other sites

The human eye can only detect flickering up to about 40hz at max.
Above 100hz and humans see only a solid light.  (Neon and Vapor lights flicker at 60hz)

LED's can flash on and off MUCH MUCH faster, thousands of times a second.

Set up a LED flasher that flashes the LEDs at 1000hz.
Then control the 'Apparent' brightness with the duty cycle of the on cycle.

If the LED's are only on 1% of each cycle they will 'Appear' very dim.
if they are on 99% of the cycle they will 'Appear' very bright.

LEDs were designed to work at one voltage.  While some PN effect fails due to manufacturing errors thus allowing them to dim a little at lower voltages. A perfect LED would hardly light at anything below it's Knee Voltage.

Too much voltage and the current melts the die. 

Pulse Width is the key.

-Mike

Link to comment
Share on other sites

Hey Theatronics.

That's what I said. PWM. So that's what I did. But it's two transistors, a comparator, two caps and half a dozen resistors. I think one could wrestle a 555 into doing this, too. Slackjack wants simple, so I'll leave it at that.

I was thinking of another way though, which interests me - that is to use a photodiode to feed back to some amp a measure of the light intensity from one of the diodes, and use that to straighten out the luminosity curve. Just another "way".

Link to comment
Share on other sites

Thanks for the replies guys. I've got another question about the circuit that Cabwood  drew. Can the circuit be made with only one transistor? Also why wont the LEDS come on just like that, I mean the way I see it the anode is currently more positive than the cathode - shouldnt this cause the LEDs to light up wihtout any variations in brightness?

Set up a LED flasher that flashes the LEDs at 1000hz.


Hey Theatronics , do you by any chance have an example that I can look at (that may also include the PWM circuit)?
Link to comment
Share on other sites

You could pull out Q1 and connect Q2's base where Q1's base used to be (betwen R1 and R2). This might work - though if it does the ramp probably won't be very linear, and the lighting and dimming not very smooth. Try it!

As for the LEDs being always lit, they won't if Q2 isn't conducting. The whole idea of the circuit is to slowly bring Q2 into and out of conduction, thus slowly increasing and decreasing the current through the LEDs. This all has little to do with voltage across the LEDs, and is more about controlling the current the through them.

Link to comment
Share on other sites

This all has little to do with voltage across the LEDs, and is more about controlling the current the through them.


It makes sense now. Thanks for youre help  :)

btw, I noticed that you used some dashed lines in the schematic (LED section). Does this mean that I can have as many LEDs without changing component values?
Link to comment
Share on other sites


I noticed that you used some dashed lines in the schematic (LED section). Does this mean that I can have as many LEDs without changing component values?

Each LED that is added increases the current through Q2. It is obvious that if the current in Q2 is too high then it will melt.
Link to comment
Share on other sites

Yes, you can connect as many resistor/LED pairs as you like, limited only by the current and power rating of Q2. At full brightness each resistor will have about 10V across it (12V supply - 2V across diode). Use Ohm's law to work out the resistance and current for each LED. Knowing the current, multiply by the number of LEDs, and you have the total current flowing through Q2.

Example: 8 LEDs, each @ 20mA. The current limiting resistor will be (12 - 2) / 0.02 = 500 Ohms. Total current = 8 * 20mA = 160mA.

The power disspipated by Q2 peaks about half way between fully off and fully on, when it has 6V across it. This condition doesn't last long, of course, but you need a transistor that can handle it. To calculate the maximum power, multiply total current by half the supply voltage.

Example: 160mA * 6V = 0.96W

So, for these examples, choose a transistor that can handle 160mA, 1W.

Link to comment
Share on other sites

So, for these examples, choose a transistor that can handle 160mA, 1W.


Is this parameter known as PDmax?


The power disspipated by Q2 peaks about half way between fully off and fully on, when it has 6V across it.


I dont really understand why this is so. Also why did you use half the max current?
Link to comment
Share on other sites

PDMAX is the maximum power it can dissipate when cold. Since it's likely to heat up for a few seconds as the lights come on and off, You are more interested in the maximum it can dissipate without a heatsink, in air at 25 degrees C. This figure is quoted as "PC(Ta=25)". A good transistor for up to about 200mA would be the BD135, with a PC of 1.25W. With a small heatsink, you could increase this to about 350mA.

The voltage across the transistor traverses a range of 0-12V, during which the current rises almost linearly. The power dissipated in the transistor is the product of the current through it and the voltage across it (P = I x V). If you plotted a graph of that power against voltage you would see that it peaks at about 6V. It is clear that when the transistor has all 12V across it, and no current is flowing, P = I x V = 0. When the transistor is fully on, and maximum current is flowing, it has almost 0V across it, so P = I x V = 0. The peak power must therefore be somewhere between these extremes.

Link to comment
Share on other sites

That transistor is a limiting factor, for sure, but what Theatronics and I proposed was a PWM design which would not only make the on/off change smoother visually, but would also vastly improve the power efficiency, so heat (brute force) wouldn't be such an issue.

The trick is to have that transistor permanently either fully on, or fully off, so that its I x V is always near zero. So you make the LEDs flash (too quickly to see) alternately fully bright and dark, and change the ratio of light period/dark period to give the illusion of gradual dimming. With such a design, the only limit on the transistor used would be maximum collector current. For the BD135, that limit is 1.5A!

The design is more complex, of course. Does this interest you enough to have me draw one up, test it and post it?

Link to comment
Share on other sites

The trick is to have that transistor permanently either fully on, or fully off, so that its I x V is always near zero.


So youre trying to minimize power dissipation. So now I must ask how would you choose whether to leave the transistor fully on or off?

The design is more complex, of course. Does this interest you enough to have me draw one up, test it and post it?


Yes, that would great.

Link to comment
Share on other sites

In the picture, the blue sawtooth waveform is generated by an oscillator. 1kHz should be fine. The red signal is a ramp generated when you press the switch. When the switch is released, the ramp would rise instead of fall. The green waveform is generated by comparing the blue and red - when the blue voltage is greater than the red voltage, we derive a high signal, and low at all other times. This resulting green square signal would be used to switch on and off the LEDs. As you can see, the lower the red ramp voltage, the longer the LEDs would be illuminated by the green pulse during each cycle. This is the principle of Pulse Width Modulation - PWM. In reality we would have the ramp rise and fall slowly, over hundrerds or thousands of sawtooth cycles, not just the 7 shown here.

post-20531-14279143000151_thumb.png

Link to comment
Share on other sites

Well, I've made the PWM version, and guess what - the apparent rate of brightening and dimming is very similar to the circuit I posted before, which makes me wonder - does the eye perceive brightness in the same way the ear perceives volume? If so the relationship would be non-linear (perhaps logarithmic, like the ear) - to achieve an apparent unit increase in brightness, I need to double the current. Something like that. Instead of a linear ramp, I'll need a log curve, rising slowly at first and getting faster. A capacitor charging has this behaviour, which is perfect for dimming, but for lighting up the curve must be initially slow-changing. Ideas anyone?

Link to comment
Share on other sites

Ugly, and incomplete, but hey, it's a work in progress!
This was the test circuit I messed around with. The biggest trouble with it is my opamp's limited output swing, making levels difficult to predict, and making it complicated to switch the transistor. Amongst other things.

post-20531-14279143001028_thumb.png

Link to comment
Share on other sites

Here's the last version of this that I'm going to do.

At the top left is a nearly-trianglular waveform generator. The peak and trough voltages are carefully chosen. The bottom left part is the ramp generator. I decided to be careful here because the level limits are important, given the range of the triangle wave it will be compared to - hence the use of two opamps.

The last opamp of the four available is the comparator, which switches TR1. R12 is there to compensate for the opamp output not swinging low enough.

The ramp output swings through the whole range (3V - 9V) in about 5 seconds. Change R8 or C2 to speed it up or slow it down.

It turns out that this was a waste fo time, because it doesn't do any better than the simple two-transistor dimmer I posted first. The perceived brightness of an LED seems to be proportional to the log of the power it dissipates, which means both circuits seem to change brightness quickly when dim, and slowly when bright.

So, I played with a log amplifier to do this, which worked OK, but it's severe overkill for a simple dimmer circuit.

post-20531-14279143004121_thumb.png

Link to comment
Share on other sites

Yes, the response of your vision to brightness is logarithmic, like your hearing.
The exponential charge and discharge voltages of your capacitor are the opposite to what is needed.

I made some slowly fading and brightening LEDs by including a coupling capacitor in the positive feedback loop of an opamp. The overall gain was 2 so when the cap charged 0.1V then the output was 0.2V. Then it charged another 0.1V to 0.2V and the output was 0.4V, etc. The opposite occurred during the discharge.

My Chaser projects use PWM as a brightness control for very long battery life. The width of the pulse changes more than 1000:1 for brightness control. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...