54316Views20Replies

# Using a 3 wire fan with Arduino? Answered

So I got a couple of 12v PC fans. They have a black wire, a red, and and yellow. So if you just hook up the red and black wires to 12v, the fan works, but you no way of controlling the speed. So this yellow wire, I'm assuming it's much like the control wire on a   servo? If I hook up this yellow wire to the Arduino should I be able to control the speed of the fan using PWM??? I just want to be sure before I fry my Arduino :D

Thanks!

Tags:

## 20 Replies

The third wire is to detect the speed of the fan. If you pull that pin up to 5V, you will see two pulses per cycle of the fan. The speed of the fan can be controlled by PWM to any speed you want.

HavocRC (author)2013-03-20

Ummmm....... So wait, I can control it using PWM? What do you mean by if you pull it up to 5v you will see two pulses per cycle? See what pulses where?

Thanks!

The Skinnerz (author)2013-03-20

Yes, 2 or 3 wire fans can be controlled using basic PWM. The circuit in the fan detects when the magnet in the motor passes a sensor, and each time it pulls the sense wire to 0V. If you connect a ~10K resistor between this wire and 5V, the wire will be at 5V when the magnet is not detected, so you see a square wave. The frequency of the output is twice the speed of the fan.

HavocRC (author)2013-03-20

Hmm so I suppose you'd need an oscilloscope for that? Wait, you said there's 5v square way? Couldn't I use Arduino to detect that HIGH and somehow find out the frequency? Then how would I have Arduino save that data and how would I figure out it's RPM from that??

Thanks!

Oh, one more question, you can't control it with PWM and view the sensor results at the same time??

hassanhabib145 (author)2015-07-08

Hallo FoamboardRC:
I was looking this post is 2 years old.. I am going to measure the speed of 3 wired fan by applying varying PWM with arduino. How you measured the RPM with Arduino ?? I also want to measure the RPM of 3 wired fan with arduino.

HavocRC (author)2015-07-08

Arduino forums can help

hassanhabib145 (author)2015-07-09

Thanks found that from arduino forum:

The Skinnerz (author)2013-03-20

You would need a scope to actually look at them, but any logic IC or microcontroller should be able to read them properly. I haven't used an arduino before, but the atmega microcontroller in it has counter/timers which will allow you to easily count 10 pulses on one counter, and use a timer to measure how long it takes (or count how many pulses in 0.1s).

Whatever language you are programming in should have a multiply/divide function available, so calculating RPM should be simple. Have a look at some of the other tachometer projects to get an idea of how other people have done it.

HavocRC (author)2013-03-20

So you just take whatever number you get and divide it by 2?
And you can't control it with PWM and view the sensor results at the same time??

The Skinnerz (author)2013-03-20

Yes, the RPM is half the output frequency.

PWM is applied to the +12V power line, and the output is on the extra wire, so if your code allows it, you can read the RPM and apply PWM simultaneously.

HavocRC (author)2013-03-20

Question. Arduino can do PWM at 5v which isn't enough for the 12v fan. I guess I would have to hook it up to a MOSFET transistor of sorts?

NathanA3 (author)2015-04-06

Hi, what resistor would you recommend in the case of the output signal from a 24V fan to an Arduino's digital input (5V)? Do I need to use two resistors in voltage divider fashion? Pardon my ignorance.

The Skinnerz (author)2015-04-07

The value of the pull-up resistor needed is dependent on the voltage that the logic is operating on, not the supply voltage to the fan. For example, if you ran the arduino on 3.3V instead of 5V, you could replace the 10K pull-up with a 5.6K resistor.

Just be sure to connect the pull-up resistor to the arduinos 5V supply, and not to the 24V for the fan.

ArcAiN6 (author)2017-05-23

I probably should have explained.. PWM == Pulse Width Modulation.. Meaning more pulses = more "on time" power to the fan, meaning it can reach faster speeds. Thick of it like a switch, when it's on, the fan receives power and spins, when it's off, it starts to slow down, a modulated series of pulses turn on and off the fan to reach the desired speed.

The digital Potentiometer method does NOT use PWM, but rather you chop the voltage, lower voltage, slower speed, higher voltage, faster speed. (Too high a voltage or current, and you'll let the magic blue smoke escape)

ArcAiN6 (author)2017-05-23

The three wires on a typical CPU fan is
Red - Vcc (+)
Black - Vdd (-)
Yellow - Sensor (Hall Effect Sensor)

You can control the fan using PWM.
PWM is basically turning on / off power , thereby increasing, or decreasing the speed of the fan. This is usually done on a special PWM capable pin on the arduino.

The third wire can then be used to read the hall effect reading.

It's important to note, that if you are using PWM, you'll need to use a stable PWM frequency, and time the reading of the sensor pin during the PWM on cycle, as the Hall effect sensor gets it's power from the same source as the fan coils.

An alternative method that should yield more reliable results is to use a digital potentiometer such as the AD5144A from Analog Devices. This will allow you to use the I²C interface to control the potentiometer, and will allow you to read the hall effect sensor any time you wish.

Hope that was helpful in some way.

.

RAGAV20 (author)2015-08-27

can i use 3wire pc fan and connect it to a ESC(ELECTRONIC SPEED CONTROLLER)

frollard (author)2013-03-20

2 wire fans are just power connections
3 wire fans have an extra OUTPUT from the fan to tell the (generally motherboard) what speed the fan is turning.
4 wire fans have that same output as 3-wire fans, but also a PWM input pin that you can drive with a regular old pwm output pin from an arduino (or motherboard).

HavocRC (author)2013-03-20

Ah ok thanks!

The Skinnerz (author)2013-03-20

You'd either need a p-MOSFET switched with an npn transistor or a small solid state relay.

HavocRC (author)2013-03-20

Okaydokey thank you skinnerz!