Can a capacitor be used to smooth PWM?

Yeah, they weren’t designed for driving capacitive loads.

Thanks for the info; it makes sense when you put it that way. Now, to go look into the math. I need to play around with the idea in order to actually grasp it fully.
Edit: I understood that output with parallel capacitor behaves like the plot below (courtesy tpub.com):

versus:

though after some reading I’m not able to deduce parameters under which a switching regulator would not ‘like’ their output being filtered. I do want to know, so I guess I’ll chat up my prof about it.

It has been a long time since I have had to think about this stuff. It seems to me that because the driver for an LED acts like a current source, we must take that into consideration. An ideal current source acts as though it has in infinite internal resistance. On the other hand, an ideal voltage source acts as though it a an internal resistance of zero. It seems to me that placing a capacitor across the load is going to behave in 2 entirely different ways, depending if the load is connected to a current source or a voltage source.

For a simple PWM controlled Constant Current Linear Driver (NANJG or pretty much any AMC7135 style driver) running at low-ish speed PWM Frequency (say 200 Hz), it would take a boat-load of cap to do anything useful…

Graph shows current with a 50% duty cycle at 200 Hz. Load is a (very close to) correctly simulated XM-L emitter.

No Cap.

100uF zero ESR

1mF zero ESR

10mF zero ESR

100mF zero ESR

100mF 7.2mOhm ESR ( Mouser Part Number 36DY104F025BF2A )

In short - absolutely not worth it. The size of cap you can fit in a flashlight won’t make a hill of beans difference. You’d either need a monster cap or the PWM frequency would have to be two or three orders of magnitude faster…

PPtk

A parallel capacitor will not act like that on a linear or (most) switching drivers. That plot shows sinusoidial AC input - the graphs of LED current look nothing like that when driven from a constant current DC source…

PPtk

Did you do those plots in PSpice, or…?

I used a ‘stripped down’ Spice program called 5Spice. Its rubbish for big simulations with complex circuits, but its far simpler to setup than the full blown sim packages for less critical stuff like this…

PPtk

OK, it looks like things are well covered here now. Thanks PPtk for the sims, very nice.
The only thing I want to add is the thing about the cap on the back of a NANJG. That has no effect on the output. It’s referred to as a decoupling capacitor. It’s purpose is to filter out noise and transients on the Vcc of the MCU (Tiny13A). It’s probably a 1uF capacitor. Without it, strange behaviour can be expected from the MCU.

Actually, it and the diode are used to keep the CPU powered when you click the switch when changing modes.

It could be used for that, but they chose to use on time instead of off time… maybe they needed too large of a cap to make it work?

No, it does not keep the MCU powered throughout a half-press, it’s capacity only suffices for a rew milliseconds.

Linear drivers can PWM as fast as 20kHz and I was thinking of using capacitor to take advantage of leds better efficency at lower currents.
As we all know led shines brighter at 0,5A than at 1A with 50% duty cycle.

How about an ultracapacitor?

http://www.ebay.com/itm/8PCS-0-33F-5-5V-KAMCAP-Coin-C-Super-Capacitor-Memory-Backup/261212647729?ssPageName=WDVW&rd=1&ih=016&category=4662&cmd=ViewItem

0.33 Farad, 13mm by 5mm… small enough to fit in most big torches.

I know nothing about those ultracapacitors so why am I responding ?, but in the ebay description of these capacitors they claim a "cycle life expectancy" of >100.000, at 200Hz PWM that would be about 10 minutes. And how fast are they?

10 minutes! haha

But I think a 1/3 Ferad cap would even enable a delayed (ramping) start up and a fade out for the LED.

Those ultracaps have a very large ESR. They are meant for memory backup. They cannot supply any current.

Weird, I actually thought ultracapacitors had minimal ESR.

Nope, and BTW, ultracaps are not really true capacitors. They are more like a battery.

I thought the ultracaps that Maxwell made that were rated at 3000 Ferads had an ESR in the miliohms.

Is that just the large size of those caps that give it a low ESR?

It depends on the capacitors, I believe that all the old types have high ESR, but some of the never has very low ESR.