PWM LED control and LC networks
PWM LED control and LC networks
(OP)
First off, many thanks go to steveowens for taking time out of his busy schedule to discuss my circuit ideas, both through email and on the phone. Kudos! He has certainly helped me move from more complicated ideas to something more simplistic, but I cannot expect him to spend all of his time helping little ol' me.
What exists:I would like to hear the opinions of others as I try to lock down this piece of the circuit. I am controlling a variable number of parallel multi-color LEDs with PWM, each color independantly controlled with a separate PWM stream. Each LED has it's own current-limiting resistor. A PWM period is 32ms long with 1ms resolution, with duty cycles of 0-100%. To be honest, I could probably decrease the period by several factors of 2, but let's start with what I'm currently working with. Voltage supply will most then likely be a regulated +12V to simplify determining max LED current (but I'm all ears on other methods to solve that issue).
Problem: I would like to rid myself of the blinking visible at less than 100% duty cycle, especially at 0-50% duty cycles (I know my low PWM period is partly to blame for the visible flickering). Also, I would like better control of the brightness, especially at low brightness settings...since I'm pulsing at full on/off, even at 3% duty cycle the LED is quite bright (don't have the benefit of an incandescent bulb's filament intergrating effect).
What's been tried:It has been suggested that an LC network with a flyback diode (similar to a switching power supply design - boost/buck regulator, if you will) is the path I should be chasing. So, I've spent considerable time playing with values in an attempt to make a reaosnable circuit. This shoudl be as close to surface mount material as possible (or very small through-hole), so I set a self-imposed limit of <500uH and <20uF (since I have had trouble finding an inexpensive SM cap over 20uF).
Interesting simulation, but the voltage overshoot would blow things sky high. So, I added in a zener after the inductor to clip the voltage...worked reasonably well. Ringing could be removed with a sizeable cap (well over 20uF, though).
Where I'm at now:In doing all of this sim work, I think I lost sight of my goal...controlling the LEDs. After all was said an done, the voltage across the LEDs was still a close approximation of the square wave. If the PWM pulses controlled a FET for each LED color to begin with, slightly smoothing out the square wave train is hardly going to have any effect on the flickering. I'm sure it was thr original circuit's attempt to smooth out the incoming power (and reduce the flicker that way) rather than the PWM pulse, but I've got so many conflicting ideas running through my head I can't sort them out any longer.
Someone push me down a path that makes sense again...
What exists:I would like to hear the opinions of others as I try to lock down this piece of the circuit. I am controlling a variable number of parallel multi-color LEDs with PWM, each color independantly controlled with a separate PWM stream. Each LED has it's own current-limiting resistor. A PWM period is 32ms long with 1ms resolution, with duty cycles of 0-100%. To be honest, I could probably decrease the period by several factors of 2, but let's start with what I'm currently working with. Voltage supply will most then likely be a regulated +12V to simplify determining max LED current (but I'm all ears on other methods to solve that issue).
Problem: I would like to rid myself of the blinking visible at less than 100% duty cycle, especially at 0-50% duty cycles (I know my low PWM period is partly to blame for the visible flickering). Also, I would like better control of the brightness, especially at low brightness settings...since I'm pulsing at full on/off, even at 3% duty cycle the LED is quite bright (don't have the benefit of an incandescent bulb's filament intergrating effect).
What's been tried:It has been suggested that an LC network with a flyback diode (similar to a switching power supply design - boost/buck regulator, if you will) is the path I should be chasing. So, I've spent considerable time playing with values in an attempt to make a reaosnable circuit. This shoudl be as close to surface mount material as possible (or very small through-hole), so I set a self-imposed limit of <500uH and <20uF (since I have had trouble finding an inexpensive SM cap over 20uF).
Interesting simulation, but the voltage overshoot would blow things sky high. So, I added in a zener after the inductor to clip the voltage...worked reasonably well. Ringing could be removed with a sizeable cap (well over 20uF, though).
Where I'm at now:In doing all of this sim work, I think I lost sight of my goal...controlling the LEDs. After all was said an done, the voltage across the LEDs was still a close approximation of the square wave. If the PWM pulses controlled a FET for each LED color to begin with, slightly smoothing out the square wave train is hardly going to have any effect on the flickering. I'm sure it was thr original circuit's attempt to smooth out the incoming power (and reduce the flicker that way) rather than the PWM pulse, but I've got so many conflicting ideas running through my head I can't sort them out any longer.
Someone push me down a path that makes sense again...





RE: PWM LED control and LC networks
There are two things to consider; the nature of the human eye and time constants that can be achieved with limited L and/or C.
First. The human eye needs well over 50 Hz to not see the flicker. I would go for 16 or 8 milliseconds. As you say, you can probably double or quadruple the frequency. That would solve the problem, I think.
Second. You need time constants about three or fime times the cycle time if you want to keep the intensity fairly constant. In the simple case (L and R or C and R) the time constants will be L/R or C*R. For three times 32 ms (that is around 100 ms) you will then arrive at L/R = 0,1 second. And if you insert your L limit (500 uH) you will get an R equal to 5 milliohms. Not very practical. Totally impossible, I would say.
If you go for R and C, you will need R*C = 0,1. Your C limit (20 uF) will then make the R = 5000 ohms, which is a possible value, but that will result in very week light since LED is duty cycle driven. With 12 V available, you can get at most a couple of mA in the LED if you use 5 kohms.
So I think that increasing the frequency will solve all your problems - if your micro allows you to do it.
RE: PWM LED control and LC networks
As you desire to keep the components physically small, the obvious next step is to increase the PWM frequency. Something like 320 microseconds (3.1Khz) might be closer to what you might require.
RE: PWM LED control and LC networks
Your comments are well received.
For a 4 MHz clock, I have a cycle time of 1us, or 1k instructions between interrupts. I'm using roughly 30% of those cycles in the ISR. I'll probably increase the clock to 32 MHz, giving me an 8-times improvement, but the 32 duty cycles will be extended to 64 (or possible 128), thereby losing 2- to 4-times improvement. I could increase the ISR rate some to gain it back again, but I need to spend time outside of the ISR, as well.
As a simple test, I doubled the ISR rate to 0.5ms, which should give me a "refresh" rate of 62.5 Hz...flicker was still quite visible...better, but visible. I'm hoping another 2- to 4-fold speed increase through the use of a faster crystal will remove it completely, but I'm still leery. Anything more than a 120-150 Hz refresh rate just isn't going to happen if I still want to do any other calculations in the main routine...3 kHz is definitely out.
OK, so let's say for the sake of argument increasing my refresh rate several times removes the flicker...what can I do about even low duty cycles causing unwanted high levels of brightness? My prototype board uses BJTs to control the max current through the LEDs, but I want the ability to connect any number of LEDs to the board...this necessitates moving to something like FETs (and individual resistors on each LED). The BJTs were semi-useful in that I could put a cap on the base to lower the peak drive current at low duty cycles, thereby truly making the LED somewhat dim with lower current (and even THAT didn't work as well as I had hoped). When moving to FETs, though, I have no such option. Any suggestions?
I can draw a basic circuit, if that would help...
RE: PWM LED control and LC networks
- do you have cost constraints
- do you have manufacturing constraints?
- you plan to build one or a thousand units?
- do you care about EMI?
- do you care about the power efficiency of your circuit?
These are several things that will guide the answers that you'll receive from the community.
My inputs and questions:
- what is the rate of change that you will have in your brightness. Quick like a video display or slow like a level indicator?
- there are LED controllers that have their own charge pumps and everything to deliver precise currents to LEDs. Have you considered them? Maxim, Linear, Zetex are names that come to my mind.
- have you tried a light detector (with compatible wavelengths) to measure the light output vs the currents driven into the LEDs.
- there is also a gamma curve relationship between the perception of the eye and the light output.
- LEDs quickly induce eye fatigue, and I don't think this is because of the pulsating frequency, but the energy sent to a single wavelength, almost like a laser diode.
- a manufacturer of giant LED displays (like the one on the Nasdaq wall) uses a refresh frequency of 1KHz.
RE: PWM LED control and LC networks
Cost contraints are relative, as well. I can accept a dollar or two here and there, but if the final product is to remain competitive, I can't do much more than that.
No manufacturing constraints I can think of, other than the two listed above. I expect to make these in large batches (500+ per run), so we're not talking prototypes here...every few pennies helps.
EMI is not an overriding concern, although it wouldn't be wise to go splashing energy all over the place. I would like to keep as much of the high slewrate signals at low voltage/current levels to avoid any potential problems.
Efficiency isn't an overriding concern, either, but I can't throw away several amps just because it's simple (else I would go with a simple power resistor setup). Wasting 5-10% of my power in various components seems like a reasonable level to attain, but I would certainly prefer if it was less.
Rate of change will be near instantaneous...I could drop the duty cycle from 100% to 0% from one update cycle to the next.
Charge pumps are out of the question for several reasons, among them are sheer number required, cost at that number, etc.
Feedback from the LEDs to the controller is not a preferred method since the number of wires between controller and LEDs should be kept at a minimum, and the distance between the two could be 5-10 feet (making current sensing another problem in itself).
The light output will not be viewed directly, but by reflected light. This should dampen any eye-fatiquing effect, not to mention there will be color mixing going on.
With a 32 MHz crystal, I could only come close to a 1kHz refresh rate if the processor did nothing else but update the LEDs...it's just not an option. I'll be doing good to get the 120+ Hz refresh rate I mentioned before.
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
However, it still leaves open the case of the LEDs appearing too bright, even at low duty cycles. I'm open to ideas on how to resolve that issue.
RE: PWM LED control and LC networks
Still hoping for ideas from your guys about dimming, though.
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
=====
If you have enough CPU power to output a PWM is software, and enough refresh rate, you can modulate the PWM output to interpolate the light output. (level 1 is too bright, you can do a level 1/2 by alternating between level 0 and level 1).
=====
Now this has potential merit. Of course, it would require a speed doubling of the processor to avoid dipping below the blinking margin set beforehand, but the idea itself has real merit. I'll chase it down once some other things are settled.
RE: PWM LED control and LC networks
As a test, I halved the ISR time to 0.5ms and WOW, what a difference (even using the original 4 MHz clock). Even moving from the original 31Hz refresh rate to the doubled 62Hz, the flickering has completely disappeared. Skogsgurra was right on the money with being above the 50 Hz mark to avoid the flickering. And the great thing is no hardware was required :D
felixc, I'm aiming this next question at everyone, but also you in particular. The final piece will still move from a 4 to 32 MHz clock, thereby giving me a good bit of leeway. If I increase the ISR speed to match any increases in PWM resolution (e.g., move from 1ms interrupts and 32 PWM levels to 0.25ms interrupts and 128 PWM levels), will a single pulse offer me increasing lower brightness levels as the resolution is increased? My intuition says yes, but without a prototype sporting a 32 MHz crystal, I can't try it to be sure. If so, I'll probably stop looking for ways to lower the initial brightness and consider both of my original issues resolved.
Now that one issue has been resolved (flickering), and possibly the second (low brightness levels) without hardware, I'm a REAL happy camper. :D
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
Modulating the PWM to increase the number of levels is a technique used in LCD controllers that interface to STN panels. These panels do not have intensity greyscales, so they are produced by modulating the drive and letting the STN material itself, and the eye, do the integration. As the response time from different LCD materials vary, these controllers were allowing you to use several variations to better adapt.
RE: PWM LED control and LC networks
In my prototype design, a single pulse is 1/32 of a period, or 0.5 ms in width. Even half a millisecond is quite a long time in terms of LED brightness, so I'm hoping that decreasing the minimum pulse width will also lower the perceived brightness...if not, I need to start chasing down other solutions for this problem.
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
RE: PWM LED control and LC networks
First, with a refresh rate of 31 Hz there was significant flicker, but doubling it to 62 Hz and the flicker has completely disappeared.
Second, LEDs are square law devices, not linear. At low duty cycles the brightness makes large jumps as I move from one level to another, but as the LED becomes brighter, the changes in brightness becomes less and less with each increase in duty cycle.
RE: PWM LED control and LC networks
You must use absolutely NO filtering on the PWM or the effect will become non-linear.
As for the flickering, it depends on the human eye. SOme eyes cannot see a 60Hz flicker and some can. Computer monitors and TV sets flicker at a rate of about 60 to 70 Hz. Most people can handle this and a few cannot. I have seen it suggested that a rate of at least 100Hz be used to guarantee that all humans see no flicker.
As for the effect at low brightness, if you can see a discrete step between 1 and 2 units of your PWM, then you have too few steps. I suggest you use an 8 bit word to define the PWN rate which will give you 256 steps. Yes the difference between 1 and 2 steps is a 100% difference in brightness but how often will you be at that low a point anyway specially if you have 256 steps? However, this is an unavoidable consequence of PWM. It is reduced though by using more steps. 256 is a convenient number of steps as it fits easily into 8 bit data.
RE: PWM LED control and LC networks
To get shorter pulses I'll need to increase the ISR rate, but I've already decided that's going to happen on the final product anyway (about an 8-fold improvement). I'll definitely be increasing the resolution from 32 to 64, possibly more, so some more testing is in order.
RE: PWM LED control and LC networks
As well, the human eye behaves in a non linear manner and the linearity of pulse width to brightness depends on the background light level. The lower the ambient light, the more non-linear the LEDs brightness will appear. If the ambient is fairly high, the light will appear to change more linearly. If there is low ablient light, it takes less pulse width to make the light appear to be bright.
I have seen attempts to map perceived lamp brightness to pulse width so the pulse width for a given control signal will be non-linear in a fashion that gives equi-brightness steps. This is more a problem for incandescent lamps though than for LEDs.
RE: PWM LED control and LC networks
Thanks in advance.