Author

Topic: Arduino powered temperature dependent fan controller (PWM) (Read 380 times)

newbie
Activity: 4
Merit: 0
Just wanted to share for those that might be interested - didn't see something like this in my immediate searches...

Code is beta...working excellent so far, though.

https://www.youtube.com/watch?v=Ff-VO6j2OTM


Supplies:

Any Arduino with PWM output and Analog input
Thermistor
Resistor that matches thermistor resistance value (100 Ohm in this example)
Fan with PWM input (PFC1212DE)

Thermistor reading dictates fan speed.

Code:
// Measured thermistor and received 80k at 80 degrees, so guessed it's a 100k
// Voltage divider resistor was then selected as 100k ohm
// (Ground) ---- (10k-Resistor) -------|------- (Thermistor) ---- (+5v)
//                                     |
//                                Analog Pin 0

int ThermistorPin = 0;
int Vo;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
int PWMpin=3;
int x=3500; // Initial X value. Higher value decreases total fan speed, lower increases.
int y=0;
void setup() {
Serial.begin(9600);
}

void loop() {

  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  T = T - 273.15;
  T = (T * 9.0)/ 5.0 + 32.0;

  Serial.print("Temperature: ");
  Serial.print(T);
  Serial.println(" F");

// Trial and error settings to drive a PFC1212DE-F00 FAN using PWM Pin 3 from Arduino
// Fan is wired to power source
// Arduino shares ground with GND from fan power source
// Arduino PWMpin connects to yellow PWM pin from fan

for(y = 0; y < 2500; y++) { // Temperature sampling rate, 2500 is about 10 second sample

digitalWrite(PWMpin, HIGH);
delayMicroseconds(x);
digitalWrite(PWMpin, LOW);
delayMicroseconds(4000-x); // Total PWM time 4000 microseconds - X value

if (T>=60 && T<=69){
 x=3950;
} else if (T>=70 && T<=79){
 x=3700;
} else if (T>=80 && T<=89){
 x=3500;
} else if (T>=90 && T<=99){
 x=2000;
} else if (T>=100){
 x=10;
}
}

}
Jump to: