Smothing a PWM signal for use with a PC fan

I'm trying to control a 12V PC fan using a PWM signal from my Arduino, and mostly this is working okay using a fairly 'naive' pwm-driven transistor setup.

This has a couple of problems though. First of all, the fan runs a little noisier than usual, and secondly the tacho signal back from the fan is incorrect, which I think is due to the loss of power every time the PWM signal is low.

I have read (although I can't find the info now) that smoothing the PWM signal should help with these issues.

Is this the correct layout for a simple low-pass filter? I'm not sure about the correct values for R1 and C1. Is a low-pass filter even what I really need?

That circuit won't work, it supplies no more than +4.4v through a 1K resistor to the fan, which won't get it turning.

If instead you get a 4-pin PC fan that implements the Intel PWM fan spec such as http://www.scan.co.uk/products/120mm-akasa-apache-ultra-silent-fan-hdb-bearing-pwm-fan-w-4-pin-connector-and-rubber-pins-1500rpm, then you can use a 5v 25KHz signal to pwm the fan. I have done this.

Is this the correct layout for a simple low-pass filter?

No. That circuit is an emitter follower and you will not get any more voltage out of it than you put in, which looks like 5V. The problem with smoothing it after the power switching is that you need very big capacitors. Much better to smooth it first and then run a FET in linear mode to control the power. That way the value of R can be higher reducing your required C.

First, as others said, you probably want to use a MOSFET as the "switch" rather than a BJT. This is so you can switch on higher voltages. Second, what are you using for PWM? The Arduino by default runs at ... 490 Hz? Something like that. The fan may want a higher PWM frequency to run well. You can twiddle the control registers of the AVR CPU on the Arduino to make it generate PWM at much higher frequencies for some of the PWM outputs. I think the millis() and micros() functions use timer 0, so don't change that -- personally, I change timer 2.

Grumpy_Mike: That circuit is an emitter follower and you will not get any more voltage out of it than you put in, which looks like 5V. The problem with smoothing it after the power switching is that you need very big capacitors. Much better to smooth it first and then run a FET in linear mode to control the power. That way the value of R can be higher reducing your required C.

Where does the the rest of the 12V supply end up then? Is it lost in the transistor? I thought the point of a transistor is that a small voltage on the Base will 'open' the path between Collector and Emitter. Unfortunately all my (limited) education in this area was a long time ago, and most online resources I've found seem to revel in complex formulae rather than fundamental concepts :)

I'll have to have a look at some sort of FET solution then. I was hoping such a low-power load would have a simpler option.

(Incidentally, the 1k resistor value was left in error - I don't currently have any particular value in mind)

Is it lost in the transistor?

Well not lost but it doesn’t get through the collector.

I thought the point of a transistor is that a small voltage on the Base will ‘open’ the path between Collector and Emitter.

Well to start with transistors work from current not voltage.
Then in that configuration the voltage on the emitter rises as current flows down it until the voltage between the base and emitter is less than 0.7V, at which point you can’t get any more current down the base to make the collector / emitter conduct any more current. This feedback limits the usefulness of this configuration when you are stepping up the voltage. That is why you need a common emitter circuit where the emitter is ground and all of the load is in the collector. What you have is called an emitter follower where the voltage on the emitter follows (minus 0.7V) the voltage on the base.

Aah, I think I see now, thanks.

I've switched things around a bit, so now I have the load at the collector, not the emitter.

Here I've skipped off any sort of smoothing - one thing at a time :)

Yes that's right. :)

Great, thanks. Now I can move on to the smoothing issue. I imagine that'll result another question or two :)

Yes,

oddly enough to incorporate smoothing before the power output stage you have to revert to an emitter follower output. But also boost the pre smoothed signal to 12V before smoothing and applying to the emitter follower stage.

I'm not quite sure what you mean by "before the power output stage". Do you mean boost the PWM signal coming out of the Arduino to 12V, and then smooth it?

Incidentally, cranking the PWM frequency to 31kHz solves the buzzing of the fans, but not the tacho, so I think I'll still need to investigate this emitter-follower, boosted signal setup :)

Do you mean boost the PWM signal coming out of the Arduino to 12V, and then smooth it?

That is one way yes. Another is to smooth it first. One circuit I have used is this:- http://www.flickr.com/photos/33177304@N03/4745203653/

Cylindric: I'm not quite sure what you mean by "before the power output stage". Do you mean boost the PWM signal coming out of the Arduino to 12V, and then smooth it?

Or just use a MOSFET for the bottom-end driver. It doesn't have the problem of the BJT you're using with voltage.

I thought the point of a transistor is that a small voltage on the Base will 'open' the path between Collector and Emitter.

MOSFETs will conduct between drain and source if there is a voltage into the gate, somewhat proportional to the gate/source voltage (in the "linear" range, then it saturates). Because the resistance between gate and source is almost infinite, and the gate works more or less like a tiny capacitor, this is easily controlled. BJTs will conduct between collector and emitter if there is a current between base and emitter, proportional to the current. Note that the reisitance/voltage changes as current increases, which is the source of the problem with the emitter follower as a bottom-end switch.

Do yourself a favor, get a handful of BS170s, and use them for your general-purpose switching needs :-)