Pages: [1]   Go Down
Author Topic: Two pc fan wiring/ hallsensor?  (Read 721 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to monitor two 3 wire pc fans, I have the sketch done (thanks to the Arduino forum and it's members). I have each fan wired to Arduino's 5V pin to 10k resistor, then to the sensor wire and Signal wire, then pin2
 5V pin to 10k resistor, then to the sensor wire and Signal wire, then pin3
I am getting a feedback/signal  from one signal wire to the other. Is there a way to stop that?
If I stop both fans I get (I think it called a floating pin) random numbers. How do I stop that?
 Thanks
 
Logged

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

I hope this helps
Logged

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

Code:
Thanks the code
[code//code by Crenn from http://thebestcasescenario.com
//project by Charles Gantt from http://themakersworkbench.com
//second fan added by steven m
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 13, 4, 5, 6, 7);


/*To disable interrupts:
 cli();                // disable global interrupts

and to enable them: 
 sei();                // enable interrupts
*/
                                   //Varibles used for calculations
int NbTopsFan;
volatile int NbTopsFan1;
volatile int NbTopsFan2;
int Calc1;//???
int Calc2; //???                               
int hallsensor1 = 2;       //The pin location of the sensor
int hallsensor2 = 3;        //The pin location of the sensor
                       
typedef struct{                  //Defines the structure for multiple fans and their dividers
  char fantype;
  unsigned int fandiv;
}fanspec;

//Definitions of the fans
fanspec fanspace[3]={{0,1},{1,2},{2,8}};

char fan = 1;                      //This is the varible used to select the fan and it's divider, set 1 for unipole hall effect sensor
                                   //and 2 for bipole hall effect sensor

void rpm1 ()                        //This is the function that the interupt calls
{
 NbTopsFan1++;
}
 void rpm2 ()                        //This is the function that the interupt calls
{
 NbTopsFan2++;
}
                                      //This is the setup function where the LCD is initialised,
                                   //and the interrupt is attached
void setup()
{
  lcd.begin(20, 4);                     //Set up the LCD's number of rows and columns
  pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
  pinMode(hallsensor2, INPUT);
  attachInterrupt(0, rpm1, RISING); //and the interrupt is attached mube pin 2
  attachInterrupt(1, rpm2, RISING); // must be pin 3
}
void loop ()
{
   NbTopsFan1 = 0;    //Set NbTops to 0 ready for calculations
   NbTopsFan2 = 0;
   sei();                //Enables interrupts
   delay (1000);            //Wait 1 second
   cli();                //Disable interrupts
   Calc1 = ((NbTopsFan1 * 60)/fanspace[fan].fandiv); //Times NbTopsFan (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider
   Calc2 = ((NbTopsFan2 * 60)/fanspace[fan].fandiv); //Times NbTopsFan (which is apprioxiamately the fequency the fan is spinning at) by 60 seconds before dividing by the fan's divider
   lcd.setCursor(0, 3);
   lcd.print ("Fan1:");      //Prints " Fan1:"
   lcd.setCursor(5, 3);
   lcd.print (Calc1, DEC); //Prints the number calculated above
   lcd.setCursor(10, 3);
   lcd.print ("Fan2:");      //Prints " Fan2:"
   lcd.setCursor(15, 3);
   lcd.print (Calc2, DEC); //Prints the number calculated above
}]
Logged

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

I went back to the one fan code. Tested each fan and when doing so I found A problem. The code I posted reads the two fans RPM right.  If I stop one of the fans the LCD reads the last reading taken not zero. I will STFW for a way to mod the code. My goal is if one of the fans stop working turn pin 9 and 10 low.
Thank you
Logged

Pages: [1]   Go Up
Jump to: