EEVblog Electronics Community Forum

Electronics => Beginners => Topic started by: Rapsey on September 21, 2018, 01:34:56 pm

Title: Filtering PWM to smooth DC
Post by: Rapsey on September 21, 2018, 01:34:56 pm
Hi everyone,

My question is more or less the same as this one (https://www.eevblog.com/forum/beginners/non-pwm-fan-with-pwm-signal-(3d-printing)/) from 7 months ago, but I didn't want to gravedig.

So we have a 5015 blower fan powered by 12V PWM (on the actual power, not just signal). This obviously introduces electrical noise an audible whining noise which I am trying to eliminate.

The fan can be voltage regulated to achieve the desired result without any electrical noise audible whining noise. It is rated for an operating voltage of 4.5 - 13.8V and a current of 170mA (= 2.04W). As with the voltage the current tolerance is +-15%.

Now the question is how to convert that 12V PWM to (relatively) smooth DC power. I've seen a few solutions:


I am fairly new at this so please point out any mistakes or misinterpretations. Any and all feedback is greatly appreciated!
Title: Re: Filtering PWM to smooth DC
Post by: tszaboo on September 21, 2018, 02:49:35 pm
"This obviously introduces electrical noise which I am trying to eliminate."
Why obviously? Why is noise a problem?
Fans are brushless motors, they have a commutator, they are noisy, no matter what you do with them. On the other hand they are an inductor, so they resist the change in current. So it is possible that you already have a preatty smooth signal, depending on the PWM frequency.
Have you connected an oscilloscope to it. Do you understand electrical noise, an it's effects on the system?
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 21, 2018, 03:47:56 pm
"This obviously introduces electrical noise which I am trying to eliminate."
Why obviously? Why is noise a problem?
Fans are brushless motors, they have a commutator, they are noisy, no matter what you do with them. On the other hand they are an inductor, so they resist the change in current. So it is possible that you already have a preatty smooth signal, depending on the PWM frequency.
Have you connected an oscilloscope to it. Do you understand electrical noise, an it's effects on the system?
Maybe it's not that obvious, I always thought it was. Any motor I have seen that was controlled by PWM on the power has produced this whining noise, from small PC fans to brushless motors in RC planes and heli's. I thought it was a universal side-effect of supplying power in pulses, caused by the PWM frequency itself (unless perhaps when the frequency is outside the audible range for humans). That assumption may very well be wrong.

Noise is a "problem" because the 3D printer is located right next to the bedroom and often used for overnight printing. It's not a major issue since it's not that loud, I am simply trying to do what I can to make it as quiet as possible - and learn a thing or two in the process.

I do believe you are correct in saying it's a brushless motor. It's categorized with the brushless fans anyway. Someone once told me brushless motors are always 3-phase and thus have 3 wires (this fan only has 2) but I'm pretty sure it's brushless anyway. It's a Sunon MF50151VX.

Unfortunately I don't have an oscilloscope (yet) so I can't measure the PWM frequency that way. I can't find any reliable information on it either since it's a firmware setting and I don't have the source code for the firmware that shipped with my printer. I suspect it's a fairly low frequency to reduce load on the Arduino that generates it. I do realize that I need to determine the frequency before I can try anything. Having a scope would also be extremely useful to study the effects of different solutions. It's definitely on my shopping list.

And no, I don't know the first thing about electrical noise or its effects on the system. Maybe I used a wrong term for it. All I know is that with PWM it makes a very audible whining noise (even when the fan is not spinning, say at very low PWM %). When I connect the fan to a lab power supply and change the voltage I get the desired speed control without the annoying whining noise. If I can get the same results on the printer itself, why wouldn't I?  :)

Thanks for the reply!
Title: Re: Filtering PWM to smooth DC
Post by: Kleinstein on September 21, 2018, 05:08:04 pm
The brush-less fans usually have a capacitor inside to buffer there supply. So if there is no series resistor or inductor, there would be significant current spikes that could act back on the PWM circuit. So it is a good idea to have at least some series impedance.  The resistor way can work, though it produces some heat and does not allow full speed. The inductor method essentially needs the diode. Inductor and no diode can damage the PWM output, though there might be a diode inside.

So one could get away with just a resistor or inductor and diode. It might still help to add more capacitance.
Title: Re: Filtering PWM to smooth DC
Post by: MiDi on September 22, 2018, 12:21:59 am
Don't filter it. Reduce PWM frequency to ~160Hz, and magic may happen.

If that's not enough try with a buck-converter  ;)
Title: Re: Filtering PWM to smooth DC
Post by: vk6zgo on September 22, 2018, 03:10:43 am
"This obviously introduces electrical noise which I am trying to eliminate."
Why obviously? Why is noise a problem?

Fans are brushless motors, they have a commutator, they are noisy, no matter what you do with them. On the other hand they are an inductor, so they resist the change in current. So it is possible that you already have a preatty smooth signal, depending on the PWM frequency.
Have you connected an oscilloscope to it. Do you understand electrical noise, an it's effects on the system?

Typo?
Commutators use brushes, otherwise they wouldn't work, so by definition, motors with commutators are not "brushless  motors".
Title: Re: Filtering PWM to smooth DC
Post by: IanB on September 22, 2018, 03:23:28 am
This obviously introduces electrical noise which I am trying to eliminate.

Maybe it's not that obvious, I always thought it was. Any motor I have seen that was controlled by PWM on the power has produced this whining noise, from small PC fans to brushless motors in RC planes and heli's.

...

And no, I don't know the first thing about electrical noise or its effects on the system. Maybe I used a wrong term for it. All I know is that with PWM it makes a very audible whining noise (even when the fan is not spinning, say at very low PWM %). When I connect the fan to a lab power supply and change the voltage I get the desired speed control without the annoying whining noise.

This seems to be a language problem. What you described as "electrical" noise is apparently acoustic noise (i.e. audible noise, sound waves).

This misunderstanding would have misdirected the people who first read your post.

One way to reduce or eliminate the audible whining noise is to change the PWM frequency. You can either increase it above the audible range to 50 kHz or more, or decrease it below the audible range to 10 Hz or less (although this may produce clicking). You would have to experiment and see.
Title: Re: Filtering PWM to smooth DC
Post by: Gyro on September 22, 2018, 09:31:36 am
If it is Audible noise that you are talking about, then yes, brushless fans can certainly generate noise when the supply is PWM driven. The problem can be particularly bad if the PWM frequency interacts with the commutation frequency of the fan.

The first thing to check (you didn't say if you did this) is to run the fan on a variable DC supply and see if it is any quieter, if not, then it is just a noisy fan (wind noise or commutation). Note that you also need to check that the fan can reliably start as the DC supply is ramped up to minimum rated voltage.

You really need to know the PWM frequency to effectively understand and fix the problem. What sort of noise is the fan making? If it is a wining noise then the PWM frequency is in the low kHz range, if you are not able to change it, then a small RC or LC filter may solve the problem.

I've linked a fix that I did for a GW Instek Bench  PSU fan, this presented as an apparent 'rattling bearing' sound. In this case, the PWM frequency was very low (65Hz) meaning that the internal supply capacitor in the fan was completely unable to cope. I introduced a simple RC filter that completely solved the problem...

https://www.eevblog.com/forum/repair/cured-my-gps2032-psu-rattle/msg931131/#msg931131 (https://www.eevblog.com/forum/repair/cured-my-gps2032-psu-rattle/msg931131/#msg931131)
Title: Re: Filtering PWM to smooth DC
Post by: Audioguru on September 22, 2018, 01:57:18 pm
Of course a brushless motor has 3 wires, a brushed motor has 2 wires. Maybe you have a brushless motor with an attached electronic circuit.
A brushless motor does not run when powered by DC from a battery or power supply, its 3 coils must be fed pulses in sequence by an electronic circuit. A brushed motor runs fine when powered by DC.
Therefore you have a brushed motor or a brushless motor with an attached electronic circuit.

A whining sound is produced because the PWM frequency its too low and is audible.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 22, 2018, 04:15:56 pm
Thank you all for your replies, I have learned a lot already.

First of all, I have gone out and bought myself an oscilloscope. With that I was able to determine that the PWM frequency is 500 Hz (2ms period). The shape of it seems like a fairly good square wave although there is a bit of jitter after each downward spike.

To those suggesting that I change the PWM frequency, I'm afraid it can't be set arbitrarily. From studying the Marlin firmware source code it appears that the timers for the PWM frequency are shared by other PWM-controlled components such as the heaters and the stepper motors. The firmware does have a FAST_PWM_FAN setting (yes/no) which notes:
Quote
Increase the FAN PWM frequency. Removes the PWM noise but increases heating in the FET/Arduino
The heating is probably why the setting is disabled by default. Judging by the source code the FAST_PWM_FAN option results in the PWM frequency being calculated as follows: CPU_FREQ / 256 / 8. Since the CPU on my board runs at 16 MHz that would result in a PWM frequency of 7,812.5 Hz, which is still well within the audible range. I've also read that this setting reduces the control resolution because scaling modifiers need to be used internally. All in all it does not look like a very good solution either.

This seems to be a language problem. What you described as "electrical" noise is apparently acoustic noise (i.e. audible noise, sound waves).

This misunderstanding would have misdirected the people who first read your post.
Indeed, my apologies for the misunderstanding. I have edited it in my original post.

The first thing to check (you didn't say if you did this) is to run the fan on a variable DC supply and see if it is any quieter, if not, then it is just a noisy fan (wind noise or commutation). Note that you also need to check that the fan can reliably start as the DC supply is ramped up to minimum rated voltage.
I have indeed done that. On a DC lab supply I could control the speed by adjusting the voltage without any whining noise. The fan starts spinning at around 1.8V. I tested its ability to restart several times at 2V and it seemed to have no problems with that (even though the manufacturer specifies a minimum of 4.5V).

You really need to know the PWM frequency to effectively understand and fix the problem. What sort of noise is the fan making? If it is a wining noise then the PWM frequency is in the low kHz range, if you are not able to change it, then a small RC or LC filter may solve the problem.

I've linked a fix that I did for a GW Instek Bench  PSU fan, this presented as an apparent 'rattling bearing' sound. In this case, the PWM frequency was very low (65Hz) meaning that the internal supply capacitor in the fan was completely unable to cope. I introduced a simple RC filter that completely solved the problem...

https://www.eevblog.com/forum/repair/cured-my-gps2032-psu-rattle/msg931131/#msg931131 (https://www.eevblog.com/forum/repair/cured-my-gps2032-psu-rattle/msg931131/#msg931131)
Now I know it's 500 Hz, which seems correct for what I'm hearing. I'm convinced the noise is from the PWM frequency.

May I ask why you opted for an RC filter over LC?
Title: Re: Filtering PWM to smooth DC
Post by: IanB on September 22, 2018, 04:20:47 pm
May I ask why you opted for an RC filter over LC?

Mainly for convenience. All though an LC filter is much more efficient*, it is generally the case that resistors are small and cheap while inductors tend to be bigger and more expensive. But by all means use an LC filter if you can calculate the sizes of L and C correctly and have space to install them.

* About efficiency, an inductor stores energy and gives it back to the system, while a resistor just throws energy away.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 22, 2018, 04:31:28 pm
Someone once told me brushless motors are always 3-phase and thus have 3 wires (this fan only has 2) but I'm pretty sure it's brushless anyway. It's a Sunon MF50151VX.
Brusleless fans have 2 wires, if they have 3rd wire it's tachometric output. They have internal circuit which switches the windings. And MF50151VX is certainly a brusheless fan. PWMing it will certainly cause damage to it (although it likely will keep working). You need to make a proper buck converter.
3 wires for the motor itself is when you have BLDC motor which needs external motor driver which will switch windings.
Don't filter it. Reduce PWM frequency to ~160Hz, and magic may happen.
Like blowing up electrolytic capacitor inside the fan?
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 22, 2018, 05:21:24 pm
May I ask why you opted for an RC filter over LC?

Mainly for convenience. All though an LC filter is much more efficient*, it is generally the case that resistors are small and cheap while inductors tend to be bigger and more expensive. But by all means use an LC filter if you can calculate the sizes of L and C correctly and have space to install them.
Given heat dissipation on that resistor, proper buck converter likely will be smaller in size. Total component count needed is almost the same. Also you won't be able to go near to full voltage unless using very low resistance, which will mean huge current spikes. I don't see any good reason using MOSFET + large resistor + cap vs MOSFET + diode (or second MOSFET) + small inductor + cap. If avoiding buck converter for any reason, instead of using RC filter, just smooth PWM before pass element and go linear.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 22, 2018, 05:57:01 pm
I've started by trying a low pass RC filter, mainly because I have plenty of resistors and capacitors lying around but no diodes or inductors. This is my maiden voyage into filter circuits so... brace for newbie mistakes.

I calculated my resistor value based on a cut-off frequency of 10 Hz and a 330 μF capacitor (16V electrolytic). This may be too big a capacitor for the job but it does arrive at a convenient resistor value:

R = 1 / (2×π×fc×C) = 1 / (2×π×10×330×10^−6) = 48.2 Ω => I used a 47 Ω resistor.

The oscilloscope now shows a fairly constant voltage: a zigzag shape (linear up & down ramps) with 10mV peak-to-peak. So far so good I think.

Controlling the fan through this now works without any whining noise. However... It doesn't get up to full speed anymore. Some voltage measurements:

1/8 duty cycle: ~2.8V
1/4 duty cycle: ~4.8V
1/2 duty cycle: ~6.8V
1/1 duty cycle: ~8.7V

So yeah, quite a long way off 12V at "full" speed.

Best guess: I should increase my cut-off frequency to result in a lower resistor value? Maybe 50 Hz for 10 Ω?
Title: Re: Filtering PWM to smooth DC
Post by: MiDi on September 22, 2018, 06:18:13 pm
This is the problem with rc filter: they have an attenuation dependent of the current through resistor - it is a loaded rc-filter, forming a voltage divider...
So the resistance has to be so low, that negligible voltage drop due to current occurs at dc, which can lead to unreasonable high capacitor.
LC filter would be an option, but has its own problems with resonance and this depends on input and output impedance as well...
You should take the suggestions as serious, but it is always the best to make your own experience  ;)
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 22, 2018, 06:23:48 pm
As mentioned above, an RC filter will result in some voltage drop and power wastage. In this case, the current is 0.17A and the resistor is 47R, so that's a loss of 8V. In reality, the motor will just draw less current, so the voltage drop won't be that high, but it will still be significant, so the fan will be unable to run at top speed.
Title: Re: Filtering PWM to smooth DC
Post by: Gyro on September 22, 2018, 06:32:24 pm
Yes, as IanB said, I used RC for convenience, at that low a frequency (65Hz) I think a decent inductance conveniently small inductor would probably have had >10R DCR anyway. The fan being 24V fan made supply current lower too.

It looks as if you've had a nice quiet first stab. A 47R series resistor is going to result in a fair voltage drop. As your PWM frequency is 500Hz, you have quite a lot of leeway. You only need to get rid of the nasty edges, so, yes, I'd shift to 10R (2V drop or less) and then tune it down further by ear.

EDIT: From your ripple readings, it sounds as if the fan drive is an open collector output, but best to double check that it isn't push-pull. You wouldn't want to blow it.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 22, 2018, 06:39:31 pm
Yes, as IanB said, I used RC for convenience, at that low a frequency (65Hz) I think a decent inductance conveniently small inductor would probably have had >10R DCR anyway. The fan being 24V fan made supply current lower too.

It looks as if you've had a nice quiet first stab. A 47R series resistor is going to result in a fair voltage drop. As your PWM frequency is 500Hz, you have quite a lot of leeway. You only need to get rid of the nasty edges, so, yes, I'd shift to 10R (2V drop or less) and then tune it down further by ear.
But why would you use low frequency for LC (it's just a buck converter really) to begin with? Just use timer in MCU to generate high frequency PWM.
Title: Re: Filtering PWM to smooth DC
Post by: Gyro on September 22, 2018, 06:45:49 pm
In my case (see my linked thread) I was stuck with a primitive 555 + opamp based thermistor sensing speed control on the Instek PSU board. I suppose I could have messed around with capacitor values to increase the 555 switching frequency, but that would have involved debugging and it was simpler to leave the PCB with heatsinks, thick transformer connections etc. in situ and just mod the fan lead.

(https://www.eevblog.com/forum/repair/cured-my-gps2032-psu-rattle/?action=dlattach;attach=221419;image)
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 22, 2018, 08:12:48 pm
A couple of follow-up observations:

With the 10 Ω resistor the fan is able to get up to 11V at 100% PWM. Evidently this does not scale linearly with the PWM: even at 1/32 duty cycle I was still getting ~4.7V.

The output isn't quite as smooth anymore but still, no whining noise so that's alright. Wave forms are very interesting to see. At low PWM it's a sawtooth pattern (near-vertical up, ramp down) with 500-600mV peak-to-peak. At 50% PWM it's a nice zigzag ramp up & down, and at 100% it's... I don't even know. See attachments.

Kinda surprising to see that, I guess 100% PWM isn't the same as continuous 12V DC after all.

Apologies for the crappy portable scope, I don't have room for a big one right now.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 22, 2018, 08:29:14 pm
Kinda surprising to see that, I guess 100% PWM isn't the same as continuous 12V DC after all.
Even when you directly connect the fan through that resistor, you still will have a voltage drop over it.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 22, 2018, 08:39:19 pm
Kinda surprising to see that, I guess 100% PWM isn't the same as continuous 12V DC after all.
Even when you directly connect the fan through that resistor, you still will have a voltage drop over it.
I wasn't talking about the voltage drop, rather the ripple in the output. Then again I don't know how much of that is from the PWM + RC LPF and how much is from the power supply itself.
Title: Re: Filtering PWM to smooth DC
Post by: MiDi on September 22, 2018, 08:42:54 pm
If the PWM frequency is around 500Hz and as the screens show ~300Hz ripple, I would suggest that this ripple is not from PWM (100%) and is the commutating frequency of the fan.
As they are quite near together this could be the cause for the noise, would suggest it was at around 200Hz and/or 800Hz...
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 22, 2018, 09:00:22 pm
If the PWM frequency is around 500Hz and as the screens show ~300Hz ripple, I would suggest that this ripple is not from PWM (100%) and is the commutating frequency of the fan.
As they are quite near together this could be the cause for the noise, would suggest it was at around 200Hz and/or 800Hz...
The rated speed for the fan I used there (a MF50151V1 this time) is 5000 rpm (or ~83 Hz), though at 11V it would be a little less than that. I'll continue to experiment with different resistors/capacitors/fans, probably try an LC or RLC filter too.

EDIT: Looks like you were right. Adding friction to slow the fan down widens the period of the entire wave form (both the sine and the spike) so they certainly don't have anything to do with the PWM frequency.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 22, 2018, 09:15:45 pm
More than one RC stage can be used for a smoother output.

A smaller value of R could be used to reduce the voltage drop, but make it too small, compared to the load and the PWM will no longer work. The capacitor will simply charge up with huge current spikes and the output will sit near to the full supply voltage, even with a fairly low duty cycle. Attached is a simulation which takes things to the extreme R = 1R, C = 1000µF and a load resistance of 80R to be close to the 170mA. The PWM frequency is a bit higher at 2kHz and a duty cycle of 20%. The voltage across the load settles at 13V, with 830mA current spikes being drawn each pulse.

Rsw is a voltage controlled resistor which goes open circuit, well not quite but 1GΩ, when V1 drops below 13.8V and nearly closed circuit i.e. 1µΩ, when V1 is 13.8V. It's there to mimic the switching action of the PWM transistor. Without it, V1 will look like a low impedance and discharge back into it via R1, when the voltage drops. I could have used a voltage controlled switch or MOSFET but this is quicker to simulate and it's good to teach people about this. I could have also combined R1 with Rsw by changing the statement to R = if(V(PWM)<13.8,1G,1), but having a separate resistor makes the schematic easier to read.
(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=528761;image)
Title: Re: Filtering PWM to smooth DC
Post by: IanB on September 22, 2018, 09:57:31 pm
Attached is a simulation which takes things to the extreme R = 1R, C = 1000µF and a load resistance of 80R to be close to the 170mA. The PWM frequency is a bit higher at 2kHz and a duty cycle of 20%. The voltage across the load settles at 13V, with 830mA current spikes being drawn each pulse.

If you were to replace the resistor with an inductor, what size inductor would produce reasonable performance?
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 22, 2018, 10:57:20 pm
Attached is a simulation which takes things to the extreme R = 1R, C = 1000µF and a load resistance of 80R to be close to the 170mA. The PWM frequency is a bit higher at 2kHz and a duty cycle of 20%. The voltage across the load settles at 13V, with 830mA current spikes being drawn each pulse.

If you were to replace the resistor with an inductor, what size inductor would produce reasonable performance?
Big, especially if the frequency is 500Hz as per the original poster's circuit, not the 2kHz I used in my simulation. Without calculating anything properly, just plugging figures into the simulation, I get around 47mH, which would need to be rated to 200mA.
(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=528848;image)
Of course a resistor is much more economical, but it depends on what voltage drop and performance at low duty cycles is acceptable.

There is another possibility: filter the PWM to pure DC using a rectifier and capacitor and use an emitter follower with a higher value RC circuit to drive the load. I'll post a schematic tomorrow.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 23, 2018, 09:00:37 am
And here it is. It will drop nearly 2V at full output but that can be minimised by replacing D1 with a MOSFET rectifier and R3 with a current source. Another possibliity is to change it to low drop-out configuration, with a P device for Q1, but it will be difficult to stabilise.
(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=529163;image)
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 24, 2018, 02:36:48 pm
Wow, thank you so much Hero999, you are really going above and beyond!

I've spent a few hours playing around with different RC vaues and studying the results. Getting a good feel for how it all fits together now. It seems that for the specific scenario of feeding PWM through an RC LPF you could say that:
Therefore in practice it seems best to do a balancing act choosing your resistor (as low as possible for the upper limit but not so low that it destroys your control curve) and then choose an appropriate capacitor based on how much ripple you can tolerate. Of course all of the above depends on how great the load is. Greater loads will require smaller resistors and larger capacitors to maintain similar results.

A few questions about your RC circuit:
And the LC circuit:
As for the rectifier circuit... I think I have some more studying to do. :)
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 24, 2018, 08:40:26 pm
And the LC circuit:
  • Would, say, a B82791H2251N020 be a good inductor here? (47mH, max 250mA / 2.4R, 30% tolerance)
  • How would the characteristics differ from an RC circuit? Why is this better?
    If these big inductors have resistance values in the same ballpark as the resistors we used for RC, is there still a point in using them?
As for the rectifier circuit... I think I have some more studying to do. :)
No, it's stupid. Also that inductor is large and made for mains filters, has two 47mH coils, that thing likely would experience tremendous losses. Viable would be like 30kHz PWM and inductor in hundreds of uH range. If done decently there will be barely any energy losses and 100-220uF capacitor would be more than enough.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 24, 2018, 10:02:48 pm
 
Wow, thank you so much Hero999, you are really going above and beyond!

I've spent a few hours playing around with different RC vaues and studying the results. Getting a good feel for how it all fits together now. It seems that for the specific scenario of feeding PWM through an RC LPF you could say that:
  • Capacitor value primarily affects ripple (smaller cap will drop more in voltage during off-portion of PWM cycles)
  • Resistor value primarily affects control range in two ways:
    • Limits the top end of your PWM control (smaller resistor will drop less voltage and thus get closer to the 12V max)
    • Shifts your control curve (smaller resistor will charge the capacitor faster, e.g. 10% pulses could be enough to fully charge the capacitor and if it is big enough to carry through the remaining 90% this would shift your effective control curve to ~0-10% PWM)
Therefore in practice it seems best to do a balancing act choosing your resistor (as low as possible for the upper limit but not so low that it destroys your control curve) and then choose an appropriate capacitor based on how much ripple you can tolerate. Of course all of the above depends on how great the load is. Greater loads will require smaller resistors and larger capacitors to maintain similar results.

A few questions about your RC circuit:
  • Is that LTSpice?
  • How do you arrive at a load resistance of 80R?
    Do you simply use Ohm's law and divide the voltage by the rated current? If so, then judging by my volt/amp measurements this remains fairly constant at lower speeds.
    Can you measure the ESR of a component like this by simply measuring resistance with a multimeter?
  • You mention 830mA current spikes but the graph shows the spike going as high as 14A and eventually settling at 830mA?
And the LC circuit:
  • Would, say, a B82791H2251N020 be a good inductor here? (47mH, max 250mA / 2.4R, 30% tolerance)
  • How would the characteristics differ from an RC circuit? Why is this better?
    If these big inductors have resistance values in the same ballpark as the resistors we used for RC, is there still a point in using them?
As for the rectifier circuit... I think I have some more studying to do. :)
Yes, I simulated it in LTSpice.

80R was calculated using the load's current and voltage ratings and applying Ohm's law. I assumed it was a resistive load, which could be incorrect. If the current doesn't reduce much, when the voltage drops, use a constant current load.

The 14A spikes, during start-up don't matter, as they don't last for long. The peak current can be calculated from the supply voltage and resistor value.

Yes, tyhe ESRT of an inductor can be measured with a meter.

As mentioned above, it makes more sense to use a higher frequency and smaller inductor, but if you can't change the frequency, then a large inductor is unavoidable. The losses won't be that high at the low frequency of 500Hz.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 24, 2018, 10:16:07 pm
As I said before, I see barely any sense going resistive PWM as well. Just use something like LM1117-ADJ and put smoothed PWM on it's ADJ pin. No current spikes, no large cap needed. As a bonus, output voltage will be independent from the load.
Title: Re: Filtering PWM to smooth DC
Post by: David Hess on September 24, 2018, 11:58:11 pm
The buck regulator structure using a capacitor, inductor, and diode is the best way.  Some old motherboards worked this way to control the speed of non-PWM capable fans.

Essentially it becomes a buck regulator without feedback control so the output voltage becomes the supply voltage * duty cycle.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 25, 2018, 07:45:07 am
As I said before, I see barely any sense going resistive PWM as well. Just use something like LM1117-ADJ and put smoothed PWM on it's ADJ pin. No current spikes, no large cap needed. As a bonus, output voltage will be independent from the load.
Assuming there's a permanently live conductor, then that would work perfectly. When I designed the previous circuit, I made the assumption that it was just a two wire connection: one 0V and one PWM.

I wouldn't even bother with the regulator, just use an emitter follower. Remove D1 and C1 from the circuit I previously posted and connect 13.8V directly to Q1's collector.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 25, 2018, 02:09:12 pm
The peak current can be calculated from the supply voltage and resistor value.
How would you calculate that?

Assuming there's a permanently live conductor, then that would work perfectly. When I designed the previous circuit, I made the assumption that it was just a two wire connection: one 0V and one PWM.
That's correct, at present there's only those two wires going to the fan. I could always lay an additional 12V line from the PSU but the simpler the solution the better.


Now I'd like to try an LC filter but I'm getting completely lost in the massive spectrum of inductors that are available. My local hardware store has 2 radial 47mH inductors (both shielded), one with an RDC of 82 (Q=70) and one with an RDC of 52 (Q=100). Both have an IDC of 8mA.

Is the RDC value really the series resistance I can expect in a DC circuit? If so, then values this high render it completely useless here.
Is the IDC value really the max DC current it can handle? If so, then values this low are equally useless here.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 25, 2018, 02:29:42 pm
Now I'd like to try an LC filter but I'm getting completely lost in the massive spectrum of inductors that are available. My local hardware store has 2 radial 47mH inductors (both shielded), one with an RDC of 82 (Q=70) and one with an RDC of 52 (Q=100). Both have an IDC of 8mA.
Don't bother with that. It's a completely non viable solution. And with those small inductors even non working. Unless you get into 10+kHz range, forget about LC.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 25, 2018, 03:38:01 pm
Now I'd like to try an LC filter but I'm getting completely lost in the massive spectrum of inductors that are available. My local hardware store has 2 radial 47mH inductors (both shielded), one with an RDC of 82 (Q=70) and one with an RDC of 52 (Q=100). Both have an IDC of 8mA.
Don't bother with that. It's a completely non viable solution. And with those small inductors even non working. Unless you get into 10+kHz range, forget about LC.
There's no reason why an LC filter won't work. It will just need an inductor 50 times the size of the equivalent circuit, working at 25kHz. Now this may not be ideal, but it's certainly possible and the current is under 200mA, which helps to make it easier too.

The peak current can be calculated from the supply voltage and resistor value.
How would you calculate that?
Ohm's law. It's no coincidence the peak current is nearly 14A, the supply voltage is nearly 14V and the series resistor is 1Ohm.

Quote
Assuming there's a permanently live conductor, then that would work perfectly. When I designed the previous circuit, I made the assumption that it was just a two wire connection: one 0V and one PWM.
That's correct, at present there's only those two wires going to the fan. I could always lay an additional 12V line from the PSU but the simpler the solution the better.


Now I'd like to try an LC filter but I'm getting completely lost in the massive spectrum of inductors that are available. My local hardware store has 2 radial 47mH inductors (both shielded), one with an RDC of 82 (Q=70) and one with an RDC of 52 (Q=100). Both have an IDC of 8mA.

Is the RDC value really the series resistance I can expect in a DC circuit? If so, then values this high render it completely useless here.
Is the IDC value really the max DC current it can handle? If so, then values this low are equally useless here.
Those inductors are completely unsuitable. The DC current rating is far too low.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 25, 2018, 04:27:54 pm
Don't bother with that. It's a completely non viable solution. And with those small inductors even non working. Unless you get into 10+kHz range, forget about LC.
There's no reason why an LC filter won't work. It will just need an inductor 50 times the size of the equivalent circuit, working at 25kHz. Now this may not be ideal, but it's certainly possible and the current is under 200mA, which helps to make it easier too.
Looks like you aren't kidding about that size. Maybe I'm looking in the wrong places but after browsing DigiKey and Mouser I still haven't been able to find an inductor that would be even remotely usable for this. Anything with sufficient inductance, current capacity and a low enough DC resistance is massive and often insanely expensive. So far the closest I could find was this thing (https://www.digikey.be/product-detail/en/hammond-manufacturing/193T/HM4797-ND/455243)... I guess this will remain a thought experiment after all.

Does it really need to have that much inductance though? I don't need to smoothen my DC output that much. Even with 2V ripple it would still be good enough to eliminate the PWM noise. Then again I don't think I fully understand the impact of inductance in an LC circuit.

The peak current can be calculated from the supply voltage and resistor value.
How would you calculate that?
Ohm's law. It's no coincidence the peak current is nearly 14A, the supply voltage is nearly 14V and the series resistor is 1Ohm.
So then you divide your resistor voltage drop by the resistor value? ~0.8V / 1Ohm seems like the only way I can arrive at ~830mA.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 25, 2018, 04:29:32 pm
Now I'd like to try an LC filter but I'm getting completely lost in the massive spectrum of inductors that are available. My local hardware store has 2 radial 47mH inductors (both shielded), one with an RDC of 82 (Q=70) and one with an RDC of 52 (Q=100). Both have an IDC of 8mA.
Don't bother with that. It's a completely non viable solution. And with those small inductors even non working. Unless you get into 10+kHz range, forget about LC.
There's no reason why an LC filter won't work. It will just need an inductor 50 times the size of the equivalent circuit, working at 25kHz. Now this may not be ideal, but it's certainly possible and the current is under 200mA, which helps to make it easier too.
I said it won't fork with particular inductors. And such circuit is just not feasible even if it works (with big inductor and capacitor) due to size and price.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 25, 2018, 05:41:52 pm
As I said before, I see barely any sense going resistive PWM as well. Just use something like LM1117-ADJ and put smoothed PWM on it's ADJ pin. No current spikes, no large cap needed. As a bonus, output voltage will be independent from the load.
I've gone over the LM1117's data sheet and I don't think it would work well for this. I only have 12V to work with and at my target current of 170mA the LM1117 has a dropout voltage of 1.1V, so unless I misunderstand linear regulators that means I'll never get much higher than 10.9V out. An RC circuit with 5R drops less than that, and with 2.5R I can get up to 11.5V in practice (at the expense of squishing my control curve into the bottom of the PWM range).

As far as I know linear regulators are also no more efficient than resistors so the only benefit I can see is that they give you linear control over the output voltage, whereas with RC it's a logarithmic curve where most of the control is between 0 and 30% PWM (depending on R/C values).
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 25, 2018, 06:35:47 pm
Nobody prohibits using LDO with lower voltage drop. As of 2.5R, it's on border with insane circuit design, my condolences to the smoothing capacitor. No sane engineer would ever place something like this into actual product.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 25, 2018, 06:59:12 pm
Nobody prohibits using LDO with lower voltage drop. As of 2.5R, it's on border with insane circuit design, my condolences to the smoothing capacitor. No sane engineer would ever place something like this into actual product.
That's what I thought. I suppose I should not expect too many years out of that capacitor before it blows up like a balloon? On the bright side, it's "only" cycling at 500Hz.

Also, I just made a rather worrying observation... The control box of my printer (which houses all the electronics) can be powered in two ways: either from the printer's own power supply or via 5V USB.

I wanted to do a test with a different power supply so I powered off the printer (unplugged both mains and USB) and then hooked up a 12V wall wart to my testing breadboard. Of course being the newb that I am I forgot that the printer's fan connector was still connected to the breadboard power rails as well. Guess what, the damn thing powers on. Apparently putting 12V on those fan leads somehow goes back through the FET to supply power to the internals. Guess that answers that, there's no diode in there.

Now I'm even more concerned about having a capacitor discharge into those fan leads during the off-portion of the PWM cycles...
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 25, 2018, 08:57:04 pm
Don't bother with that. It's a completely non viable solution. And with those small inductors even non working. Unless you get into 10+kHz range, forget about LC.
There's no reason why an LC filter won't work. It will just need an inductor 50 times the size of the equivalent circuit, working at 25kHz. Now this may not be ideal, but it's certainly possible and the current is under 200mA, which helps to make it easier too.
Looks like you aren't kidding about that size. Maybe I'm looking in the wrong places but after browsing DigiKey and Mouser I still haven't been able to find an inductor that would be even remotely usable for this. Anything with sufficient inductance, current capacity and a low enough DC resistance is massive and often insanely expensive. So far the closest I could find was this thing (https://www.digikey.be/product-detail/en/hammond-manufacturing/193T/HM4797-ND/455243)... I guess this will remain a thought experiment after all.

Does it really need to have that much inductance though? I don't need to smoothen my DC output that much. Even with 2V ripple it would still be good enough to eliminate the PWM noise. Then again I don't think I fully understand the impact of inductance in an LC circuit.
Yes, to get smoothing at low frequencies, a big fat inductor is required.

Quote
The peak current can be calculated from the supply voltage and resistor value.
How would you calculate that?
Ohm's law. It's no coincidence the peak current is nearly 14A, the supply voltage is nearly 14V and the series resistor is 1Ohm.
So then you divide your resistor voltage drop by the resistor value? ~0.8V / 1Ohm seems like the only way I can arrive at ~830mA.
Look at the voltage, when the 14A peak is drawn.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 28, 2018, 01:36:02 pm
By the way, at 100% PWM that LC filter you provided shows a voltage spike before stabilizing. Is that something I should be concerned about? I'm not sure if ~20ms is long enough for such a spike to be dangerous.

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=533955;image)


EDIT 1: Changing the placement of the diode seems to cut off the spike as it should:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=533970;image)

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=533976;image)


EDIT 2: Because I do not need the smoothing to be perfect I tried an LC filter with a smaller inductor. This actually seems to work quite well. The control curve is much better than an RC filter while also getting closer to 12V. The question remains: is this a sane thing to do?

I'm using a 1N5819 here because I have a few of those lying around. For the inductor values I used a 5900-222-RC (axial, 2.2mH, 1.7RDC, 500mA).

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534063;image)

10% PWM: (this would be the lowest setting for practical use)

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534069;image)

20% PWM:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534075;image)

30% PWM:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534081;image)

50% PWM:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534087;image)

100% PWM:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534093;image)


EDIT 3: This is probably a better way to do the flyback diode:

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534171;image)

Having the diode in this configuration does raise the output voltage at low duty cycles: 10% PWM has gone from 3.3V to 5V.


EDIT 4: Added a resistor to the flyback diode to dampen the effect of the inductor during the off-portion of the PWM cycles. Mostly to improve the control curve, so I can have access to low voltages (3-4V) without resorting to ultra-low PWM duty cycles (<=5%).

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=534192;image)

Control curve now looks like this:

Code: [Select]
PWM% => Vout
   5 =>  1.3
   6 =>  1.7
   7 =>  2.1
   8 =>  2.6
   9 =>  3.0
  10 =>  3.5
  11 =>  3.9
  12 =>  4.3
  13 =>  4.7
  14 =>  5.1
  15 =>  5.5
  16 =>  5.9
  17 =>  6.2
  18 =>  6.5
  19 =>  6.8
  20 =>  7.0
  25 =>  8.2
  30 =>  9.0
  35 =>  9.6
  40 => 10.0
  50 => 10.6
  60 => 11.0
  80 => 11.3
 100 => 11.8
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on September 29, 2018, 06:48:56 pm
Did you model the ESR of the inductors?

Why do you want the inductor over the plain RC circuit? If it's efficiency, then in the first two edits, the diode is dissipating quite a bit of the power. In the fourth and final edit, R1 is dissipating a lot of power. Of course, if you're not bothered about efficiency, then this isn't a problem.

Another approach is to build a PWM circuit, running at a much higher frequency, run off a diode and capacitor rectifier and use much smaller inductors and capacitors.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 30, 2018, 07:18:54 am
Yes, I took the ESR or the inductor into account. The reason for using an inductor is that compared to a resistor, it seems to do a much better job of slowing down the capacitor charging while having less ESR, thus getting closer to 12V. The resulting ripple is more like a sine and less like a sawtooth.

R1 is indeed dissipating a lot of power in edit 4 but only during the off-portion of the PWM cycle. That way it does not hamper the max voltage at 100% duty cycle but the lower the duty cycle, the more it reduces the average output voltage. This way it's not like 10% duty cycle results in 90% output voltage.

An additional PWM circuit was my next option to explore. I haven't been able to find any PWM IC's that are also PWM-controlled (hardly surprising), they all seem to be voltage-controlled. Which brings me back to my original problem of how to convert the 500Hz PWM to a linear scaling voltage.

Do you have any examples of that diode+capacitor rectifier? I thought these things were for AC-to-DC conversion. Not entirely sure what there is to rectify when the wave function has no negative portion...
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 30, 2018, 10:33:00 am
An additional PWM circuit was my next option to explore. I haven't been able to find any PWM IC's that are also PWM-controlled (hardly surprising), they all seem to be voltage-controlled. Which brings me back to my original problem of how to convert the 500Hz PWM to a linear scaling voltage.
Resistor + capacitor. What you've seen so far was not linear because pulling only to one side, not up/down and because of the load attached.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 30, 2018, 02:55:36 pm
Resistor + capacitor. What you've seen so far was not linear because pulling only to one side, not up/down and because of the load attached.
I don't understand, without a load any DC supplied to the capacitor through a resistor would eventually charge it to 12V, regardless of the PWM duty cycle. What do you mean with pulling to one side vs up/down? It sounds like DC vs AC but that's probably not what you meant?
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 30, 2018, 02:57:08 pm
Resistor + capacitor. What you've seen so far was not linear because pulling only to one side, not up/down and because of the load attached.
I don't understand, without a load any DC supplied to the capacitor through a resistor would eventually charge it to 12V, regardless of the PWM duty cycle. What do you mean with pulling to one side vs up/down? It sounds like DC vs AC but that's probably not what you meant?
It means pulling to GND as well, not leaving open circuit.
Title: Re: Filtering PWM to smooth DC
Post by: Gyro on September 30, 2018, 03:44:13 pm
It sounds like a really fun discussion but are you sure you're not going a little OTT just to stop a fan whining?  :)

Presumably the PWM changes in response to some kind of temperature sensing, so as long as the fan control range is able to keep up, then is there a problem?

Just asking.  :)
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 30, 2018, 04:32:13 pm
It means pulling to GND as well, not leaving open circuit.
Sorry, I still don't get it. I thought my last 2 circuits were closed. I only put the GND in because LTSpice requires it.

It sounds like a really fun discussion but are you sure you're not going a little OTT just to stop a fan whining?  :)

Presumably the PWM changes in response to some kind of temperature sensing, so as long as the fan control range is able to keep up, then is there a problem?

Just asking.  :)
On the contrary, I'm sure I'm going completely over the top. At this point it's mostly just a fun learning exercise.  ;)

The PWM doesn't actually adjust to temperature, it's purely software-controlled and it can be configured at will. This is the part cooling fan of a 3D printer, it blows air over the molten filament exiting the nozzle.

A common example would be to print the bottom layer with no cooling to improve adhesion to the print bed. After that you would use a middle-of-the-road fan speed depending on the temperature you're printing at and the material you're using. The bottom few dozen layers would still be printed at a higher fan speed to compensate for their proximity to the heated bed. If there is any bridging in your model you would use 100% fan speed for those lines because the faster they cool and become solid, the less hanging there will be. So yea, it varies throughout the print.

The bottom line is that pretty much the entire spectrum of the speed control gets used, and that most of the time you're not running at 100% which means the whining noise is always there. It doesn't matter what the duty cycle is, the noise is caused by the PWM frequency so it makes a constant ~500Hz tone at any speed below 100%. Not ideal to have next to your bedroom during a 24h+ long print.
Title: Re: Filtering PWM to smooth DC
Post by: wraper on September 30, 2018, 05:01:24 pm
It means pulling to GND as well, not leaving open circuit.
Sorry, I still don't get it. I thought my last 2 circuits were closed. I only put the GND in because LTSpice requires it.
Your last 2 circuits are LC. What I mean is that you both charge and discharge the capacitor through resistor. If there is no any significant load at the output, like when controlling IC as you mentioned, output voltage will be completely proportional to PWM duty cycle.

(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRUWKlf6GIgd3Aq5_cRhwlPYtZiANETemQsiXPUI3OcY6OyTpWP)
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on September 30, 2018, 07:29:43 pm
Aha, I think I get what you're saying now. But then you do need something to switch that GND discharge on & off inversely to the PWM duty cycle. I've used another one of these conditional resistors to simulate it here, not sure which solution would be best for that.

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=535617;image)

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=535623;image)

EDIT: In hindsight, better to use a much smaller capacitor and a much larger resistor. (plot remains the same)

(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=535674;image)
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on October 01, 2018, 08:10:52 am
Aha, I think I get what you're saying now. But then you do need something to switch that GND discharge on & off inversely to the PWM duty cycle. I've used another one of these conditional resistors to simulate it here, not sure which solution would be best for that.
To make it shorting, simply remove the Rsw component. The default behaviour of the pulsed voltage source is shorting and Rsw was added to make it non-shorting. Unfortunately this will not model your circuit correctly, which will just be a single transistor in series with the fan, which leaves it open circuit, when off. Another transistor will need to be added to short the output, when the input goes low.
Title: Re: Filtering PWM to smooth DC
Post by: Rapsey on October 01, 2018, 05:19:16 pm
I also came across this article (https://origin-www.maximintegrated.com/cn/app-notes/index.mvp/id/3530) which offers a more complex circuit to convert PWM to linear voltage to reduce acoustic noise. I'm still trying to wrap my head around it. It's interesting that he was able to do it without resorting to large capacitors even though his PWM frequency is a measly 93.5Hz. I'm not sure why he inverted the output though (100% PWM = 0V), that's something I could do without.

(https://origin-www.maximintegrated.com/cn/images/appnotes/3530/3530Fig02.gif)
Title: Re: Filtering PWM to smooth DC
Post by: wraper on October 01, 2018, 06:09:12 pm
I also came across this article (https://origin-www.maximintegrated.com/cn/app-notes/index.mvp/id/3530) which offers a more complex circuit to convert PWM to linear voltage to reduce acoustic noise. I'm still trying to wrap my head around it. It's interesting that he was able to do it without resorting to large capacitors even though his PWM frequency is a measly 93.5Hz. I'm not sure why he inverted the output though (100% PWM = 0V), that's something I could do without.
This is what I was suggesting. Convert PWM to DC for control and go linear. In your case you can do it simpler. You don't have tachometric output from the fan so you can control voltage on the GND side as well.
Quote
It's interesting that he was able to do it without resorting to large capacitors even though his PWM frequency is a measly 93.5Hz
Nothing interesting. Just normal design contrary something abnormal you tried to do.
Title: Re: Filtering PWM to smooth DC
Post by: Zero999 on October 01, 2018, 10:53:27 pm
I also came across this article (https://origin-www.maximintegrated.com/cn/app-notes/index.mvp/id/3530) which offers a more complex circuit to convert PWM to linear voltage to reduce acoustic noise. I'm still trying to wrap my head around it. It's interesting that he was able to do it without resorting to large capacitors even though his PWM frequency is a measly 93.5Hz. I'm not sure why he inverted the output though (100% PWM = 0V), that's something I could do without.

(https://origin-www.maximintegrated.com/cn/images/appnotes/3530/3530Fig02.gif)
It also requires an extra power wire, which I thought you wanted to avoid.

Here's another possibility which will give as lower voltage loss as possible, using only jelly-bean parts. It does this by using a common emitter amplifier on the output and a differential pair input. The simulation says it can go from 0.6V to 11.58V, with a 12V input. If lower loss is required, the Schottky diode can be replaced with an ideal diode MOSFET rectifier circuit.
(https://www.eevblog.com/forum/beginners/filtering-pwm-to-smooth-dc/?action=dlattach;attach=536502)