Pages: [1]   Go Down
Author Topic: Conecting cpu fan?  (Read 2341 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
today I took the cpu fan from an older computer and connect it to my arduino to control it.
It has 4 pins and I discovered the vcc, graund and signal (I think), the other must be for rpm readings, so I connect vcc to 5v, the graund to gnd and the signal to pin 6.

It work perfectly, my question is if can I damage my arduino uno r3 by connecting the signal directly into pin 6??

Thanks in advance.
Logged

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This shows the connections
http://www.thebestcasescenario.com/forum/showthread.php?p=292131#post292131

This shows the connections for a 4 pin fan
http://www.allpinouts.org/index.php/Motherboard_%28CPU%29_4_Pin_Fan

You probably don`t need to use the control pin, just connect it as in the first link I`ve posted.


Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 44
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, it work better that way (the fan was able to spin faster)!
But my fan has 4 pins, I connect the vcc, gnd, and control, where should I connect the sense pin for readings?
an analog pin or a digital pin?

Thanks for replying.
Logged

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the diagram of the first link, its shows you (Arduino pin2) where to connect the sense wire.

This allows you to read the RPM of the fan, you then use this to control an arduino PWM output pin to an FET transistor to control the speed of the fan motor.

There`s loads of tutorials on how to drive a motor with an FET, here`s just one of them
tutorials
http://bildr.org/2012/03/rfp30n06le-arduino/

For your four pin fan you can ignore the (Control) Blue wire connection.



Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For your four pin fan you can ignore the (Control) Blue wire connection.

Not if you want to PWM the speed and read the RPM simultaneously.  In that case you need to supply the fan thru the regular power and control the speed with the BLUE control wire.  That way, the RPM sense wire circuitry will always be powered and able to give you reliable information.
Logged

Experience, it's what you get when you were expecting something else.

Offline Offline
Sr. Member
****
Karma: 6
Posts: 429
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Control wire PWM Frequency: Target frequency 25 kHz,acceptable operational range 21 kHz to 28 kHz

You`d have to change the Arduino`s PWM frequency to control the fan this way or write a custom PWM function into the sketch.

You can do this
http://playground.arduino.cc/Code/PwmFrequency
but it messes with other functions.

Depends on what the OP needs, for example, for manual control connect a pot to A0 and use that to control the PWM (Fan Speed)

Logged

texas
Offline Offline
God Member
*****
Karma: 27
Posts: 862
old, but not dead
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Control wire PWM Frequency: Target frequency 25 kHz,acceptable operational range 21 kHz to 28 kHz

You`d have to change the Arduino`s PWM frequency to control the fan this way or write a custom PWM function into the sketch.

You can do this
http://playground.arduino.cc/Code/PwmFrequency
but it messes with other functions.

Depends on what the OP needs, for example, for manual control connect a pot to A0 and use that to control the PWM (Fan Speed)



Or you could do this, it hijacks Timer2.  It will PWM a fan at exactly 25kHz and run a sample showing how to read the fan RPM and print it out:

Code:
const int PWMPin = 3;

void setup() {
// generate 25kHz PWM pulse rate on Pin 3
  pinMode(PWMPin, OUTPUT);   // OCR2B sets duty cycle
// Set up Fast PWM on Pin 3
  TCCR2A = 0x23;     //0x23 COM2B1, WGM21, WGM20
// Set prescaler 
  TCCR2B = 0x0C;   //0x0A WGM21, prescaler = /8
// Set TOP and initialize duty cycle to zero(0)
  OCR2A = 79;    // 79 TOP DO NOT CHANGE, SETS PWM PULSE RATE
  OCR2B = 79;    // duty cycle for Pin 3 (0-79) generates 1 500nS pulse even when 0 :(

  Serial.begin(57600);
}

void loop() {
 
  unsigned long x;
  unsigned int rpm;
 
  if((unsigned)OCR2B > 79){
    OCR2B = 79;
  } 
  delay(1000);
  Serial.print(OCR2B);
  Serial.print(" ");
  x = pulseIn(11, HIGH);
  Serial.print(x);
  x += pulseIn(11, LOW);
  Serial.print(" ");
  Serial.print(x);
  rpm = (1000000 * 60) / (x * 2);
  Serial.print(" ");
  Serial.println(rpm);
  OCR2B--;
}

You connect the Blue fan CONTROL wire to Pin 3 and the Green SENSE wire to pin 11.  You set OCR2B to a value from 0 to 79 to set the PWM duty cycle.  The loop() will start the fan at full RPM and then gradually decrease it while constantly reporting the RPM.  Fans run on 12V, not 5V and you may need a pull-up to +5V on the Green RPM sense wire.
Logged

Experience, it's what you get when you were expecting something else.

Pages: [1]   Go Up
Jump to: