PC Fan with MAX6651 (SOLVED)

Hi…
I need help for use the MAX6651 with arduino uno r3. The project is: Monitor 4 pc fan speed with tachometer cable.
I connected the i2c chip with arduino e the send and receive is ok. But read the speed always 0.
This is the datasheet: http://www.maximintegrated.com/datasheet/index.mvp/id/2296
I have connected only the tach cable to the tach0 port of the chip. Without mosfet and capacitor etc…
The fan is a pc fan 12V with 3 cables (red, black, yellow).
is there anyone who can help me?

Thank you

This is the code that I used for test.

#include <Wire.h>
byte KtachCommand=00000000;
byte ConfigCommand=00000010;
byte ConfigData= 00101000;
byte GPIODEFCommand=00000100;
byte DACCommand=00000110;
byte AlarmEnableCommand=00001000;
byte AlarmCommand=00001010;
byte Tach0Command=00001100;
byte Tach1Command=00001110;
byte Tach2Command=00010000;
byte Tach3Command=00010010;
byte GPIOSTATCommand=00010100;
byte COUNTCommand=00010110;
byte COUNTData=00000011;
int RPM;
byte Ktach=100;
int FanControllerAddress=72; 
int Tach0RPM;
int Tach1RPM;
int Tach2RPM;
int Tach3RPM;
byte TachInput;
int counter;

void setup(){
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);
  Wire.beginTransmission(FanControllerAddress); // transmit to device
  Wire.send(ConfigCommand);   // transmits command 
  Wire.send(ConfigData);     // transmits data
  Wire.endTransmission();    // stop transmitting
  delay(10);
  Wire.beginTransmission(FanControllerAddress); // transmit to device 
  Wire.send(COUNTCommand);    
  Wire.send(COUNTData);     
  Wire.endTransmission(); 
  delay(10);
}

void loop(){
  if (counter==0){
  UpdateFans();
  ScreenUpdate();}
  
 KtachUpdate();
  delay(50);
  counter++;
  if (counter==20){
    counter=0;}
}

void KtachUpdate(){
    if(Serial.available()>0){
      byte input=Serial.read();
      if (input=='u')
      Ktach=Ktach-1;
      else if (input=='d')
      Ktach=Ktach+1;
      if (Ktach<64)
      Ktach=64;
      if (Ktach>250)
      Ktach=250;
      
      RPM=59531.25/(Ktach+1);
      Wire.beginTransmission(FanControllerAddress); 
      Wire.send(KtachCommand);   
      Wire.send(Ktach);    
      Wire.endTransmission();   
      delay(10);}
      }
      
void UpdateFans(){
  Wire.beginTransmission(FanControllerAddress); 
  Wire.send(Tach0Command);     
  Wire.requestFrom(FanControllerAddress,1);
  if (Wire.available()>0){
  TachInput=Wire.receive();}
  if (TachInput>0){
    Tach0RPM=TachInput*15;}
  delay(10);
  
}
void ScreenUpdate(){
  Serial.print("RPM= ");
  Serial.println(RPM);
  Serial.print("Ktach= " );
  Serial.println(Ktach,DEC);
 /Serial.print("Tach0 RPM = ");
  Serial.println(Tach0RPM);
  Serial.println(" "); 
}

superzaffo: Hi.. I need help for use the MAX6651 with arduino uno r3. The project is: Monitor 4 pc fan speed with tachometer cable. I connected the i2c chip with arduino e the send and receive is ok. But read the speed always 0. This is the datasheet: http://www.maximintegrated.com/datasheet/index.mvp/id/2296 I have connected only the tach cable to the tach0 port of the chip. Without mosfet and capacitor etc... The fan is a pc fan 12V with 3 cables (red, black, yellow). is there anyone who can help me?

  1. Have you connected the black wire to ground (as if the mosfet in the example schematic is turned on)?

  2. Have you connected a 10K pullup resistor between the tach0 port and +5V or +12V, as shown on the datasheet?

1 Yes. But I do not use the mosfet. I use only the tach cable of the fan. This is connect to pin 1 of the chip (tach0). I need only read the speed. 2 Yes. I use the 10k resistor for pull up.

Thank you for your answer.

Give this a try:

void setup() {
byte Tach2Command=00010000;

Serial.begin(9600);
Serial.println( (int) Tach2Command, HEX );
}
void loop() {}

Then find out about binary notation of constants.

avr-gcc: http://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html
and AVR - gcc - How to specifiy binary constants ?
The “Arduino language” : http://arduino.cc/en/Reference/IntegerConstants

sorry michael_x.. but.. why this ? Is a problem with conversion ? Could you explain me ?

Thank you

The problem that I believe Michael is pointing out is that in these lines:

byte KtachCommand=00000000;
byte ConfigCommand=00000010;
byte ConfigData= 00101000;
byte GPIODEFCommand=00000100;
byte DACCommand=00000110;
byte AlarmEnableCommand=00001000;
byte AlarmCommand=00001010;
byte Tach0Command=00001100;
byte Tach1Command=00001110;
byte Tach2Command=00010000;
byte Tach3Command=00010010;
byte GPIOSTATCommand=00010100;
byte COUNTCommand=00010110;
byte COUNTData=00000011;

the constants 00000010 etc. are interpreted not as binary but as octal. Use either B00000010 or 0b00000010 instead.

Ok.. now is clear ;) Tonight try this and I will post the result. For the moment... read the conversion rule ... :~

Thank you.

btw as these are constants, you should use the 'const' keyword when declaring them. For example:

const byte ConfigCommand = 0b00000010;

Otherwise, they take up RAM, and you could unwittingly change them.

Ok. I will try. thank you so much...

Correct the problem with add the letter B. Perfect thenk you to all. The MAx6651 is a very good system for monitoring the Fans..

Hi superzaffo, I am glad you got it working. Others may learn from this thread. I see you added (SOLVED) to the last post, and that's great, but If you could go back to your original post and add (SOLVED) there, it would show up a lot better in the forum list.

PS. you can modify your own posts.

Thanks, Jack