Loading...
Pages: [1] 2 3 4   Go Down
Author Topic: Control PWM fan speed depending on tempature  (Read 1939 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am looking at getting 2 80x10mm PWM fans. However, i am looking at controlling the fan speed with the arduino via the PWM pins.

I found the following diagram that seems to be what i am looking for in order to hook the fan up to the Arduino:


Does that seem correct? I will be using the DS18B20 Thermometer Temperature Sensor in order to see how fast i need to spin the fan.

Any helpful feedback would be great! smiley

David
Logged

USA
Offline Offline
Full Member
***
Karma: 3
Posts: 120
Yes, I remember
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like that would work fine.  If you wanted you could also likely read the speed of the fan back using another pin on the Arduino to connect to the sense pin, but that is probably over-complicating things.
Logged

Topsham, Vermont USA
Online Online
Edison Member
*
Karma: 15
Posts: 1465
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@StealthRT can you point to a source for this type fan??  I'd like to understand better...
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be a fan like so: http://www.frozencpu.com/products/15479/fan-968/Cooljag_Everflow_70mm_x_10mm_PWM_Fan_R127010BUAF.html

Quote
Pin 1 Black (GND), Pin 2 Yellow (PWR), Pin 3 Green (SGN), Pin 4 Blue (PWM)

I would hook the 12v (Yellow) to a power supply and ground (Black) to both the power supply and the arduino. Finally hook the PWM digital pin 9 to the PWM wire (Blue) on the fan. Do not know what to do with the signal (Green) wire?

Still looking for code to read the PWM from the fan though....

David
« Last Edit: March 19, 2013, 10:39:51 am by StealthRT » Logged

Maine
Offline Offline
Sr. Member
****
Karma: 8
Posts: 336
Caution: Explosives in use.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be a fan like so: http://www.frozencpu.com/products/15479/fan-968/Cooljag_Everflow_70mm_x_10mm_PWM_Fan_R127010BUAF.html

Quote
Pin 1 Black (GND), Pin 2 Yellow (PWR), Pin 3 Green (SGN), Pin 4 Blue (PWM)

I would hook the 12v (Yellow) to a power supply and ground (Black) to both the power supply and the arduino. Finally hook the PWM digital pin 7 to the PWM wire (Blue) on the fan. Do not know what to do with the signal (Green) wire?

Still looking for code to read the PWM from the fan though....

David

IIRC, the green wire is a tach signal, that you can use to determine the current speed of the fan.
Logged

"Anyone who isn't confused really doesn't understand the situation."

Arduino-based airsoft props -> www.nightscapetech.com

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Still looking for code to read the PWM from the fan though....

Surely the PWM is the signal you provide to the fan to adjust its speed?

The green wire is the tach, which you would presumably read if you need to know what the speed actually is.

Have you seen this?
Logged

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I gather that the PWM would be in the range of 0-255 when writing out to it from the ardunio?
Code:
int pwmPin   = 9;   // fan PWM -> connected to digital pin 9
int pwmVal   = 0;
int DEBUG    = 1; // DEBUG counter; if set to 1, will write values back via serial

void setup()
{
  pinMode(pwmPin, OUTPUT);   // sets the pin as output

  if (DEBUG) {
    Serial.begin(9600);
  }
}

// Main program
void loop()
     analogWrite(pwmPin, pwmVal);

     if (DEBUG) { // If we want to read the output
      if (pwmVal != 255) {
         pwmVal += 10;
         Serial.print(pwmVal);  // Print red value
         Serial.print("\t");    // Print a tab
      } else {
         Serial.print('at max high');  // Print red value
         Serial.print("\t");    // Print a tab
      }
    }
    delay(wait); // Pause for 'wait' milliseconds before resuming the loop
}
« Last Edit: March 19, 2013, 10:51:35 am by StealthRT » Logged

Johannesburg UTC+2
Offline Offline
Edison Member
*
Karma: 34
Posts: 1705
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I gather that the PWM would be in the range of 0-255 when writing out to it from the ardunio?

Yes.... except that the Arduino PWM is under 500Hz, and the datasheet says it needs 25kHz PWM. The other ref I gave says it must be between 21 and 28kHz....

The datasheet shows the relationship between duty cycle and speed. PWM = 0 is 0%, 255 is 100%. As you'll see, PWM duty cycle below 30% (~80) still gives 1200rpm; above that it looks more or less linear up to full speed.
Logged

IT Crowd:
Roy... "Have you tried turning it off and on again?"
Moss.. "Have you tried forcing an unexpected reboot?"

Topsham, Vermont USA
Online Online
Edison Member
*
Karma: 15
Posts: 1465
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Arduino PWM can be messed with. See the http://ArduinoInfo.Info WIKI:

http://arduino-info.wikispaces.com/Arduino-PWM-Frequency


Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


I looked at the sheet and i must say, i don't understand the code on there and what it is doing in order to produce the values needed to send to the PWM fan?

Mind throwing together some code for me to visualize it better?
Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 128
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems good, but consider geting some electronics to handle the current required for the fan and as for a termometer consider buying some thermistors:
https://www.sparkfun.com/products/250
Logged

Arduino Uno R3
Mac OSX Lion


0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Seems good, but consider geting some electronics to handle the current required for the fan and as for a termometer consider buying some thermistors:
https://www.sparkfun.com/products/250
I already have DS18B20 Thermometer Temperature Sensor as the temp sensor for it to use.
Logged

Topsham, Vermont USA
Online Online
Edison Member
*
Karma: 15
Posts: 1465
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
consider geting some electronics to handle the current required for the fan

The Fan current is controlled by the PWM signal. No Arduino added Arduino power control needed...
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

0
Offline Offline
Full Member
***
Karma: 0
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Still in need of some code to work the PWM for the fan...

David
Logged

UK
Offline Offline
Tesla Member
***
Karma: 99
Posts: 6778
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I haven't tried it myself, but the article that terryking228 linked to lists the available PWM frequencies and I don't see any listed within the 21-28 KHz range that you're looking for.

You could try searching Nick Gammon's forum for his articles on timers - he covers this area very well and I expect you'll find a definitive answer there as to whether it's possible to achieve the frequency you need.
Logged

Pages: [1] 2 3 4   Go Up
Print
 
Jump to: