Can a capacitor be used to smooth PWM?

My LED analyzer device (Any interest in a LED/Battery analyzer device?) has a big MOSFET on it that is driven by a PWM signal (16 kHz, 10 bit resolution) that can PWM the battery input power to the LED/load output connector. It acts like a buck converter. The control software allows it to generate a constant voltage, current, or power to the load or charge lithium batteries. These operating modes require a filter cap to be installed across the load to smooth out the PWM pulses. I have been using a 1000 uF cap for most applications. Looking at the cap voltage on a scope shows a few percent overshoot when the PWM pulse turns on.

Note that if the battery input voltage is quite a bit higher than the desired load voltage, the PWM pulse width gets too small to get fine control from. For instance, if you wanted to charge a 4.2V Li-ion cells from a 12V input, the required PWM pulse width drops to around 2. With a 5V source it uses around a 50 pulse width.

Playing with some standard LED drivers, most don’t like having their outputs filtered. This is particularly true of switching type drivers.