Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] 3 wire Fan tachometer

Status
Not open for further replies.

anishpsla

Member level 2
Member level 2
Joined
Dec 15, 2013
Messages
44
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
Activity points
402
hi friends,

I want to design a RPM counter for 3 wire CPU fan. For that, I design circuit using PIC16F84 as counter. The counter is working perfectly. But when I try to connect the 3rd wire to PIC, I am getting constant 3000 RPM in display. There is no change even the fan is stopped by hand. Here is the code for PIC16F84A using MikroC. When I try to add the pull-up resistor, the reading changes to zero.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
unsigned int fan_rpm;
 
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB1_bit;
sbit LCD_D4 at RB2_bit;
sbit LCD_D5 at RB3_bit;
sbit LCD_D6 at RB4_bit;
sbit LCD_D7 at RB5_bit;
 
sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB1_bit;
sbit LCD_D4_Direction at TRISB2_bit;
sbit LCD_D5_Direction at TRISB3_bit;
sbit LCD_D6_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB5_bit;
 
char *RPM = "0000 RPM";
 
void Display_RPM(unsigned long num){
  RPM[0] = num/1000 + 48;
  RPM[1] = (num/100)%10 + 48;
  RPM[2] = (num/10)%10 + 48;
  RPM[3] = num%10 + 48;
  Lcd_Out(2,5,RPM);
 }
 
void main() {
     OPTION_REG = 0b00110000; //Timer0 Config
     TRISA = 0x01;  //PORTA Configure
     TRISB = 0x00; //PORTB Configure
     PORTB = 0x00;
     
     Lcd_Init();        // Initialize LCD
     Lcd_Cmd(_LCD_CLEAR);             // CLEAR display
     Lcd_Cmd(_LCD_CURSOR_OFF);        // Cursor off
     
     while(1)
     {
       TMR0=0;
       Delay_ms(1000);
       fan_rpm = TMR0*120;
       Display_RPM(fan_rpm);
       Lcd_Out(1,3,"RPM Counter");
     }
}

 

Can you post a schematic, and you should use pull-up res because the output of the fan is an open-collector.
 
When I put pull-up resistor to the pin, the reading will become zero. Even higher value pull-up will make the count zero. I tried all the combination of circuit I got from internet. The circuit have nothing special, the 3rd wire is connected to RA4 of PIC16F84A. The PIC will work as a counter. The code is already posted.
 

Long time ago I used PICs, so please excuse if i'm wrong: should trisa=0x01 be trisa=0x10?
 
Maybe check with an oscilloscope your fan signal and also check the voltage levels of your signal.
 
Constant display of 3000 RPM seems to indicate 50 Hz hum but no tachometer signal at the counter input. Looks like a hardware problem.
 
Post a schematic anishpsla.

Did you corrected the value of 3000rpm because of the 1:2 prescaler of the timer.
 
Last edited:
Maybe check with an oscilloscope your fan signal and also check the voltage levels of your signal.

I have no oscilloscope to confirm fan have tacho signal.



Constant display of 3000 RPM seems to indicate 50 Hz hum but no tachometer signal at the counter input. Looks like a hardware problem.

You are correct. It's caused the crap Chinese adapter. I tried with battery, 3000 RPM in display gone. But still there is no RPM Count in LCD.



Did you corrected the value of 3000rpm because of the 1:2 prescaler of the timer.

1:2 prescaler is already corrected in program. Please see 41st line of the code.
 

Please, post a schematic, maybe hand-drawn or just the connection between PIC and fan with associated voltages.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top