Fan w/PWM stalling under analogWrite (fanPin,250)

First post..Arduino Newbie!! Horray.... First project Reef/LED Controller..anyways

"trying" to control a 12vdc 150mA fan using pin 9 PWM. PWM is feeding a 1K resistor feeding the base of a transistor (NTE 375). All is fine for anything over 250 PWM but below that the fan just stops and buzzes and looks like it wants to start but doesn't. Fan is a typical 3 wire (red/black/yellow for RPM reading that I'm not using yet) Sunon w/maglev brearing. Help..??

Just reading a temp sensor and performing the Write. As soon as I change it to 249 or lower the fan stalls.

if (tempc >= 23) analogWrite(fanPin, 255);

There is no way the arduino alone is going to be able to power that. You are going to have to have an alternate power source such as a nine volt.

To get your self into powering motors and such take a look into buy or building this:

http://www.adafruit.com/index.php?main_page=product_info&products_id=81

Genernal consensus seems to be that PC fans do not work well with PWM. Rather you need a varying DC voltage. One option is to convert PWM to DC. You can find more information in this topic:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1242516621

If you want to experiment, you could also try to increase PWM frequency (as high as possible). I have a 12V DC fan controlled with high frequency PWM directly using a MOSFET. This has worked reliably with no apparent ill effects for more than a year. Don't expect the fan to work through the full 0-255 range however. They need a minimum RPM (e.g. 600-700) in order not to stall.

If you want to experiment, you could also try to increase PWM frequency (as high as possible).

I found that 30Hz to be good too, especially for noise/clicking that you get at the default 500Hz of the Arduino.

vampist, I have a 12vdc supply hooked to the red wire of the fan, black wire to NTE375 collector, emitter to ground (diode reversed across the motor for emf). Tried a 1uF ceramic cap across the motor too. No luck. Something ain't right or there is LOADS of BS on the internet about how easy it is to run a fan with PWM. I was going to try a mosfet but not sure if that will really make a difference.

BenF, Funny you say that as there are thousands of posts about running fans via pwm pin 9. and only 1 or 2 guys who says it's no good. This is the setup I'm duplicating http://www.uchobby.com/index.php/2007/09/23/arduino-temperature-controlled-pc-fan/ (I removed the optocoupler though to try to rule that out as the cause for the stall)

there are thousands of posts about running fans via pwm pin 9. and only 1 or 2 guys who says it's no good.

It depends on what fans they are using. older fans tend to be DC and work quite happily with PWM. However newer motors actually generate PWM from the DC you feed them. This allows them to have better internal speed regulation. The problem is that if you feed them with PWM this beats with the internal PWM and results in periods where the motor wants to apply voltage to the coils but at that instant there is no voltage to apply because the source is having a down period with it's PWM It sounds like this is what you are experiencing. You can try dropping the frequency of the arduino's PWM or smoothing the PWM with a filter:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html

...and only 1 or 2 guys who says it's no good

You may have to count yourself in then.

You could try with your circuit as is and a higher PWM frequency. Add the following statement to your setup function:

  // increase PWM frequency by a factor of 64 (digital 9 and 10)
  TCCR1B &= ~(_BV(CS12) | _BV(CS11));

I will try (when I get home again) increasing PWM freq, decreasing PWM freq, smoothing PWM.
and yes add me to the list of people who cannot PWM a fan for some odd reasons. The fan just wobbles and tries to start.

for some odd reasons.

I thought I have told you the exact reason?