How do I control fan speed on 12V DC fan?

Hey guys, i'm providing 12v external power to 3 12V DC fans that have a 3rd control line...what code should I use to control the fan speed? Thanks

Each fan has 3 wires(Red, Black, and the Yellow reserved for control) btw

Let's look at it this way...i have 1 fan with a red, black, and yellow wire coming out of it... i put the yellow wire into the arduino and the black and red into a power supply...what code do i need in order to control pin 7 to change the duty cycle...

i found this code but don't understand what variables to change:

void setup()
{
Serial.begin(9600);
pinMode(7, OUTPUT);
}

unsigned char speed;
unsigned int low = 1;
unsigned int high = 10;
unsigned int baseTime = 10;

void loop()
{

digitalWrite(7,LOW);
delayMicroseconds(low10);
digitalWrite(7,HIGH);
delayMicroseconds(high
10);

if (Serial.available())
{
speed = Serial.read() - 48;
low = speed;
high = baseTime - speed;
}

}

That code is doing PWM control on digital pin 7, so either connect your fan control wire to digital pin 7, or change the "7" in the code to another pin.

my control line is connected to digital 7...do i need to use GND? or should the circuit be just control line to the arduino and + & - to the power supply?

what's the advantage of changing the pins?

Yes, you'll need to connect the fan ground to the Arduino's ground. There's no special advantage to changing the pins, but that was what you asked about!

Lol, my apologies what i'm really asking is how to get this code to work...I have now connected the fan ground to the arduino ground...and i'm still not able to discern which variables i should change in order to change the fan speed...any thoughts?

are you sure the yellow line is for control? most fans i've seen put a pulse per revolution signal so you can measure the fan RPM.

labeled with a"C" so i assumed control...is there a way to do this with this mosfet: http://www.steelnerve.com/2N3771-D.pdf and wiring the arduino through the fet so as to provide 12V to the fan?

what's the best way to do this? the project i'm trying to achieve is this: PIC based laser spirograph - YouTube

I haven't seen any fans with separate control signals - certainly all PC fans with 3-wire interfaces have pulse-per-rev strobe on yellow ("Count"?). Control is via DC voltage level or PWM (the latter is better for low-speed control). Do a search for "3-wire fan", and look through some of the stuff returned.

Yep, every 12v fan I've ever seen with a yellow lead has been for RPM.

Ok well then in that case here are the fans i have

2 x Innovative. DC Brushless Fan Motor. Model BS501012V. DC 12 Volt 0,13A.
1 x CoolerMaster (50x50x10mm) Model: EFB0512HA Case Fan with 3-Pin

and i have the FET http://www.steelnerve.com/2N3771-D.pdf

given the code provided, how SHOULD i be wiring things up and what do i need?

nd i have the FET http://www.steelnerve.com/2N3771-D.pdf

That is not FET it is a transistor. Connect the base to the Arduino pin through a 1K resistor. Connect the emitter to ground, the -ve of the fan to the collector and the +ve of the fan to the 12v supply. Connect the -ve of the 12V supply to the Arduino ground.

As has been said the third wire is to measure the fan speed. If you want this can be incorporated into a feedback loop so that the measured speed controls the PWM but this requires more complex software.

Ah, again to my aid Grumpy Mike, thank you :-p ...i shall work on this setup and get back as to the progress this evening
ttyt

-Ray-

Hey, Don't have a 1K handy but i've got about 50 330s lol at 5% tol and 1/4W...no reason 3 of them in series won't work for now, right? Thanks

330 x 3 = 990ohms which is ~1K

It will indeed work as you said. It's 1% off of the target. Of course, all those resistors being 5% you could be off by an additional 15% but it's pretty unlikely. :wink:

It doesn't matter much about the absolute value of the base resistors just use what you have 330R will be fine.

That transistor will stand 7.5A base current!, far more than you can provide.

Putting in more base current than is needed is only an issue when it comes to turning the transistor off rapidly. It will be slow in turning off due to base charge storage current, but only slow in the mill seconds sense of things.

It's an 8A power supply at 12V and 20A at 5V so 8A at the voltage i'm working with

would it be better to add another 50ohm resistor on to err on the side of caution or just not worry?

post details in a little when i wire it up

How big is this fan? Most 12v fans take about 120 to 300 mA. The point I was making is that all the current your Arduino could supply wouldn't be anywhere close to too much. Just stick with what you have.

lol sorry it's 3 12V fans...yeah they're prob 100ma a piece it's the power supply i'm running the circuit with that's 12V at 8A...regular computer power supply, i've got a ton of them around so i use them for everything