anishpsla
Member level 2
- Joined
- Dec 15, 2013
- Messages
- 44
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- 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.
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"); } }