FAN PWM Control

Hello to all,

Im just testing the phase of controlling a FAN with temperature and playing around with 3 different speed level.

However, i noticed that if i just connect a direct 5V to the FAN it spin to its full speed.

Whereas, when im analogWrite (FanPin,255); the Fan do not spin at its full speed likewise when directly connected to 5V supply.

Another observation is when output has been activated a small push needs to be performed on the fan for it to start spinning, and at the same time its always have a whining noise.

Below is my code for the testing, i used a potentiometer to simulate same:

Any suggestion please . .

Thanks for responses.

const uint8_t FanPin = 3;    // Fan connected to digital pin 3 with PWM capability

const uint8_t PotSim = 0;

uint8_t FanCtrl;
uint8_t FanSpd_1 = 65;
uint8_t FanSpd_2 = 128 ;
uint8_t FanSpd_3 = 255;


void setup()  { 
   
  Serial.begin (9600);
   
   pinMode(FanPin,OUTPUT);
} 

void FanCtrl_1(){
 

    analogWrite(FanPin, FanSpd_1);         
    // wait for 30 milliseconds to see the effect    
    delay(30);                            
  } 
 

void FanCtrl_2 (){
  
    analogWrite(FanPin, FanSpd_2);         
    // wait for 30 milliseconds to see the effect    
    delay(30);                            
  } 


void FanCtrl_3(){

    analogWrite(FanPin, FanSpd_3);         
    // wait for 30 milliseconds to see the effect    
    delay(30);                            
  }


void loop()  { 

  int TempSim = analogRead(PotSim);
  
  if (TempSim >=100 && TempSim <= 350){
    FanCtrl_1();}
    
    if (TempSim >=350 && TempSim <= 700){
      FanCtrl_2();}
      
       if (TempSim >=700 && TempSim <= 1024){
       FanCtrl_3();}
  
  delay (500);
  
  Serial.print ("Sim-Value = ");
  Serial.println (TempSim);
  
 // delay(1000);

}


[code/]

I strongly advise AGAINST connecting the fan directly to the 'duino
a) it will draw far too much current and PROB90 kill the pin it's connected to
b) electric motors generate back EMF that will kill the pin it's connected to

put a transistor in there, with a revrse biased diode across the motor
then you may see more sensible results
and your 'duino will survive to tell the tale!

Please search for "pwm fan control" and you'll find many suggestions on the hardware and software side.

For example have a look at this old thread:

http://arduino.cc/forum/index.php/topic,132300.0.html

taz3m:

// Fan connected to digital pin 3 with PWM capability

Stop there, switch everything off, disconnect all the wires.

There's no way an Arduino pin can drive a fan directly. The only thing you'll achieve is to break the Arduino.

As a fan is a motor you have to contend with something known as "inrush current". This is generally taken to be six times the full load current (on large motors, no idea what it is on small fans). The datasheet should tell you what the full load and starting currents will be at a voltage.

With that in mind consider that the Arduino can only source a rather small amount of current, if you put anything that's good at sinking current (motors, hint hint) you'll end up overheating and damaging your microcontroller.

What you need to do is have an external supply with the Arduino controlling that supplies path to the motor, you could use a transistor for example. You might also want to add protection like optical isolation and diodes to prevent back emf.

Hello to all,

Thats indeed right about all your post here, i have rather quite a long time not dealt with motors, where i did forget somehow all the precautions to be taken. But indeed my forgetfullness would have made me lost few things . . :slight_smile: luckily im saved . . Thanks

About the inrush current its right, i planned to PWM a brushless DC motor with a 24Vdc, but since i had a small fan 5V supply with a consumption of 0.16 A, i thought i could tinker a bit with the PWm before moving towards a bigger load.

Is there any thread or link someone can help me with in understanding the basic circuits behind connecting the load with transistors and eventually with reverse bias diode.

Thanks

Regards

Tazlim.

Hello,

I just gone through some readings and come across positive voltage regulator. I do have some in hands having reference L7805CV.

Can i use these voltage regulators to connect with my fan load.

My apologise in asking these stufss which may sound silly, as im noob in circuit designs..

Alternatively i do have 1 transistor NPN S9013.

http://www.hz-dz.net/UploadFiles/200952711452305.pdf

Meanwhile i will continue my readings and geet to my PWM objective for my fans . . :slight_smile:

Cheers . .