Author Topic: Filtering PWM to smooth DC  (Read 23929 times)

0 Members and 2 Guests are viewing this topic.

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Filtering PWM to smooth DC
« on: September 21, 2018, 01:34:56 pm »
Hi everyone,

My question is more or less the same as this one 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:

  • Just put a capacitor onto it
    This to me seems like a very poor solution, if you can even call it that. For one thing it messes up the PWM control, i.e. 80% PWM won't be 80% effectively. I'm also concerned about reverse current: during the off-portion of every duty cycle the capacitor will put voltage on the Arduino which is supplying the PWM power. Maybe this is fine but I'd rather ask here than find out the hard way.
  • Capacitor with resistor in series
    I've heard that the resistor is added to slow down the charging of the capacitor. Is this accurate? Again, same reverse current concerns as before.
  • Capacitor with inductor in series
    Okay, I understand that inductors resist changes in current and capacitors resist changes in voltage. I can see how those two would make a good team here. Again, worried about reverse current and also inductive spikes. Might need to add a diode in parallel with the inductor to allow the current to circulate back if the load is suddenly removed?
  • Capacitor with inductor in series and a freewheeling (schottky) diode placed in parallel over both (= buck converter)
    This seems to be best way to do it, but I wonder if it is necessary. I'll probably need to place my solution in-line on the fan wires so the more compact I can make it the better.

I am fairly new at this so please point out any mistakes or misinterpretations. Any and all feedback is greatly appreciated!
« Last Edit: September 22, 2018, 09:58:12 am by Rapsey »
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7374
  • Country: nl
  • Current job: ATEX product design
Re: Filtering PWM to smooth DC
« Reply #1 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?
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #2 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!
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 14192
  • Country: de
Re: Filtering PWM to smooth DC
« Reply #3 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.
 

Offline MiDi

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: ua
Re: Filtering PWM to smooth DC
« Reply #4 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  ;)
 

Offline vk6zgo

  • Super Contributor
  • ***
  • Posts: 7586
  • Country: au
Re: Filtering PWM to smooth DC
« Reply #5 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".
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Filtering PWM to smooth DC
« Reply #6 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.
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 9501
  • Country: gb
Re: Filtering PWM to smooth DC
« Reply #7 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
« Last Edit: September 22, 2018, 09:34:18 am by Gyro »
Best Regards, Chris
 

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Filtering PWM to smooth DC
« Reply #8 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.
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #9 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
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?
« Last Edit: September 22, 2018, 04:17:51 pm by Rapsey »
 

Online IanB

  • Super Contributor
  • ***
  • Posts: 11882
  • Country: us
Re: Filtering PWM to smooth DC
« Reply #10 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.
« Last Edit: September 22, 2018, 04:22:36 pm by IanB »
 

Online wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: Filtering PWM to smooth DC
« Reply #11 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?
 

Online wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: Filtering PWM to smooth DC
« Reply #12 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.
« Last Edit: September 22, 2018, 05:23:17 pm by wraper »
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #13 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 Ω?
« Last Edit: September 22, 2018, 06:02:28 pm by Rapsey »
 

Offline MiDi

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: ua
Re: Filtering PWM to smooth DC
« Reply #14 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  ;)
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19517
  • Country: gb
  • 0999
Re: Filtering PWM to smooth DC
« Reply #15 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.
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 9501
  • Country: gb
Re: Filtering PWM to smooth DC
« Reply #16 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.
« Last Edit: September 22, 2018, 06:38:44 pm by Gyro »
Best Regards, Chris
 

Online wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: Filtering PWM to smooth DC
« Reply #17 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.
 

Offline Gyro

  • Super Contributor
  • ***
  • Posts: 9501
  • Country: gb
Re: Filtering PWM to smooth DC
« Reply #18 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.

« Last Edit: September 22, 2018, 06:53:53 pm by Gyro »
Best Regards, Chris
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #19 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.
 

Online wraper

  • Supporter
  • ****
  • Posts: 16860
  • Country: lv
Re: Filtering PWM to smooth DC
« Reply #20 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.
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #21 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.
 

Offline MiDi

  • Frequent Contributor
  • **
  • Posts: 600
  • Country: ua
Re: Filtering PWM to smooth DC
« Reply #22 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...
 

Offline RapseyTopic starter

  • Contributor
  • Posts: 25
  • Country: be
Re: Filtering PWM to smooth DC
« Reply #23 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.
« Last Edit: September 22, 2018, 09:53:08 pm by Rapsey »
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19517
  • Country: gb
  • 0999
Re: Filtering PWM to smooth DC
« Reply #24 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.
« Last Edit: September 23, 2018, 09:03:17 am by Hero999 »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf