Show Posts
Pages: [1]
1  Using Arduino / General Electronics / Re: Two pc fan wiring/ hallsensor? on: August 16, 2011, 10:16:30 pm
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
2  Using Arduino / General Electronics / Re: Two pc fan wiring/ hallsensor? on: August 14, 2011, 01:50:05 pm
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
}]
3  Using Arduino / General Electronics / Re: Two pc fan wiring/ hallsensor? on: August 14, 2011, 12:23:16 pm
I hope this helps
4  Using Arduino / General Electronics / Two pc fan wiring/ hallsensor? on: August 14, 2011, 10:45:30 am
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
 
5  Using Arduino / Programming Questions / Re: hallsensor? on: August 13, 2011, 09:06:26 pm
Pin 2 and interrupt 0 go together. Pin 3 and interrupt 1 go together.

When you changed the pin 3, did you change the value in attachInterrupt to match?
No, just changed it now works.
Thank you
6  Using Arduino / Programming Questions / hallsensor? on: August 13, 2011, 08:26:08 pm
I am trying to under stand the code for reading 3 wire PC fan RPM, should work on pin 2 and/or 3.
 The code below works on  int hallsensor = 2; // pin 2 location of the sensor  Prints the same fan RPM in two spots.
When I change to  int hallsensor = 3; // pin 3 location of the sensor , wont read RPM- It still reads pin 2.
 I changed the code to  int hallsensor = 11; // pin 11 location of the sensor,  Should not work at all and it still reads pin 2.
Is it some part of the code or is it the Duemilanove that is not letting me change from pin 2 to pin 3?
Can someone point me to some reading/reference to this piece of code?
  //Definitions of the fans
fanspec fanspace[3]={{0,1},{1,2},{2,8}};

Thank you, Steve

Code:
//code by Crenn from http://thebestcasescenario.com
//project by Charles Gantt from http://themakersworkbench.com

#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;
int Calc;
                                  //The pin location of the sensor
int hallsensor = 2;
                       
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 rpm ()                        //This is the function that the interupt calls
{
 NbTopsFan++;
}
                                   //This is the setup function where the LCD is initialised,
                                   //and the interrupt is attached
void setup()
{
  pinMode(hallsensor, INPUT);      //Sets RPM pin to input
  lcd.begin(20, 4);                     //Set up the LCD's number of rows and columns
  attachInterrupt(0, rpm, RISING);
}
void loop ()
{
   NbTopsFan = 0;    //Set NbTops to 0 ready for calculations
   sei();                //Enables interrupts
   delay (1000);            //Wait 1 second
   cli();                //Disable interrupts
   Calc = ((NbTopsFan * 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 (Calc, DEC); //Prints the number calculated above
//      NbTopsFan = 0;    //Set NbTops to 0 ready for calculation
//   Calc = ((NbTopsFan * 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(10, 3);
   lcd.print ("Fan2:");      //Prints " Fan2:"
   lcd.setCursor(15, 3);
   lcd.print (Calc, DEC); //Prints the number calculated above
}
Pages: [1]