arduino controlled computer fan controller

hi, i have designed a fan controller using a bjt and an opto-isolator connected to a pwm pin on an arduino. the circuit seems to work when i put varying duty cycles through it (0-255). however, anything less than 255 gives a really annoying whine in the fan and the fan refuses to spin. does anybody have any reasons for this, or solutions? I have designed this so that i can make my fans quieter when there is less load on the computer. Posted below is the picture of the schematic being used.

Thank you very much

fan circuit.png

I guess the standard PWM frquency is to low for your fan.
Try creating custom PWM signals of higher frequencies, for example 25KHz) by bit banging the pin:

You might not get rid of the whining completely but you can reduce it. There are also fans that are supposed to be PWM compatible, you could try to find one of those if you don't have any luck with the one you have.

i will have to check out the bit banging method, but since the mega will be doing many other things this seems like a difficult option, but at least an option, thanks!

also, i connected a 220uF cap in between the motor leads and that seems to work pretty well. is this not a good thing to do long term or at all?

Smoothing the PWM to your fan should be fine and should eliminate the noise.

You might want to look at using a MOSFET rather than a BJT.

See here for previous discussion:

thank you for that, at first glance, that should be very helpful. unfortunately the pcb has already been made so there isn't much hardware tweaking i can do

There was a discussion awhile ago where expert dc42 gave me some advice.

http://arduino.cc/forum/index.php/topic,132300.0.html