Cant get the pwm working :/

Hello,

So now i am at the stage of smashing my head against the wall and still cant find the cure.
I am using Arduino NANO and
this board: ebay

Fan is 3 wire PC fan

and my test code is:

int FAN_2P = 9;
int POTENTIOMETER = 0;
int reading;
int value;

void setup() {

pinMode(FAN_2P, OUTPUT);
Serial.begin(9600);

}

void loop() {

reading = analogRead(POTENTIOMETER);
value = map(reading, 0, 1024, 0, 255);
analogWrite(FAN_2P, value);
Serial.println(value);

}

If i turn the potentiometer then the value changes, but not the fan speed. If value is 0 then fan turns off.
What is wrong?

The led's on the board are changing brightness but does not affect the motor speed.
Any ideas?

OK, I feel your pain.

Take a pain-free break from head smashing and watch my videos #14 (part 1) and #15 (part 2) all about PWM. Part two specifically uses a computer cooling type fan which may be of interest to you. URL for my videos in the signature of this post. Enjoy!

On your specific issue, using a 3-wire fan may be the issue - PWM works by modulating the 'on' time so 3 wires are not (normally) required - just the +ve and -ve of your fan. The third wire is (usually) a speed sensor wire so your PC knows to alert you if it stops. Check your connections here!

Yes, i am using only + and gnd wire on the fan.
Watched the videos, but did not get it working.
Is it something to do with the mosfets on the board?

F5305S? - http://www.irf.com/product-info/datasheets/data/irf5305s.pdf

Can you draw a schematic of how you have wired things up please.

That good is it?
I can spot one or two omissions.

???

try a different channel.

fwiw, using pwm on fan power is really just a hack. You can get 4 wire computer fan that has a dedicated pwm pin for speed control and works on 3.3v or 5v. The PWM frequency must be about 25khz, otherwise there will be an audible whine.

I connect pwm direct to fan pwm pin, fan tach pin to a pullup resistor connected to a pin with interrupt enabled. The 12v power to fan is controlled by an npn + p channel mosfet circuit so I can completely shut off the fan.




redcx:

Connecting the grounds somewhat defeats the purpose of the optocouplers.
You need a motor shield.

Seems that P-Channel fets are used, and that they are normally 'on'.
So the fan should run at full speed when nothing is connected to the input of the board.

A 'high' from the Arduino pin should turn the fet 'off', and stop the fan.

Your map function should be 0, 1024, 255, 0. Or better 0, 1024, 255, 100.
Fans need a minimum voltage to work.
Leo..

redcx:
Yes, i am using only + and gnd wire on the fan.
Watched the videos, but did not get it working.
Is it something to do with the mosfets on the board?

F5305S? - http://www.irf.com/product-info/datasheets/data/irf5305s.pdf

Well, those are not logic-level (5v gate) MOSFETs so will not switch on fully with the 5v output from an Arduino GPIO pin. The clue is in the name (IRF as opposed to IRL).
Maybe that's the issue here?