PWM of 12v Fan using TIP120?

Hello, still new and looking to understand something a bit better. I am interested in fan speed control utilizing the PWM pins of the Arduino. I have poured through the forums and found a few different ways of doing this.

I have seen some fans with a 3rd PWM wire connected directly to the Arduino (as well as a 12v power source) and other diagrams utilize a darlington TIP120 (again in addition to the power source) connected to the Arduino to modulate fan speed. Is there an advantage to one method over the other or is this simply a different layout if your particular fan does not have a speed control wire?

Thank you!

Computer fans have either 2, 3, or 4 wires.

2 wire ones just spin.

3 wire ones have an extra wire carrying a speed measurement (I suspect this is logic level, or open drain, or something like that, pulsing once per revolution)

4 wire ones add a PWM speed control line, which can be controlled with logic level signal. These are marked as PWM speed control fans.

PWM speed control fans are of course the most desirable, having no external components needed to change speed. These require no external components other than the power supply. Just connect the grounds, and PWM the signal pin.

You can also PWM the normal ones using an external transistor, though I'd expect it to break their speed readout, and you need a flyback diode (if it's not integrated - it may be), and I don't expect the PWM duty cycle vs fan speed curve to be linear.

The TIP120 is an acceptable transistor, but it's a darlington BJT, which is kind of old hat. Modern MOSFETs perform much better, with less switching loss and on-state voltage drop.

NPN BJT vs N-Channel mosfet wiring as switch, simplest case. BJT vs FET Emitter / Source goes to ground. Collector / Drain goes to negative side of load. Base / Gate controls it.

On BJT, the base is connected to the arduino pin through a resistor (to limit the base current, while providing enough current to saturate the transistor)

On FET, the gate is connected to the Arduino pin directly, and the gate is also connected to ground through 10k, to keep the gate at ground when the input is tristated.

Horribly long link - any of these MOSFETs will work, and are in easy to use TO220 package.

+1 Some extra tips. 4-pin fans (with inbuild electronics), also known as CPU fans, need a 25Khz PWM signal. Not just because it's above human hearing. If you use a 2- or 3pin fan with external mosfet/transistor, you should use a ~30herz switching frequency. Just below the human hearing. Using the Arduino's ~500hz default PWM could make your fan "sing" at low RPM. 4-pin fans, controlled with 25Khz are potentially less noisy. They don't "knock", like 30hz controllers do, at low speeds. Leo..

Thank you both very much for your replies. It does seem like the MOSFET is a route I should be going. I did a bit of digging and found a few diagrams. I think that the MOSFET's support for a larger current is something I will require, but had not previously considered. If I use the MOSFET in a configuration with an external 12v power supply to the component the MOSFET is controlling am I correct in my understanding that the power supplied from the Arduino itself to the MOSFET via the PWM pin is minimal? I ask because I will require more PWM pins than are available, i have seen breakout boards and shields that are designed to increase the number of PWM pins for LED configurations but I require more PWM pins to control more MOSFET's. Would these still be an acceptable option?

Mosfets require NO drive power when "on" or "off". They only use power when switching. When their gate capacitance has to be charged/discharged. Wise to have a 220ohm between Arduino pin and Mosfet gate. Also wise to have a 100k resistor from gate to ground in case the Arduino is still tristating e.g. during bootup. Only "logic" Mosfets can be used. How many fans do you need. The Mega has 15 PWM outputs. You can expand that with e.g. this to ~1000 fans. Leo..