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.
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.