hello everyone I am trying to measure frequency using PIC16f886. I am using simple comparator for Sine wave to square wave conversion. And I have attached the input of comparator with RA4/T0CLK to use Timer0 as a counter.I have also copied code for it but my LCD displays counts from 0-9 and then again roll overs to 0 and starts counting again. The code I copied is:
Post full code. I don't have that code. The code you have posted is Rajendra Bhatt's code. I will write a code for you. It seems you are using mikroC and hence I will write mikroC code.
I made two frequency counters using PIC16F877A and mikroC PRO PIC Compiler. I have not measured the max frequency that the counters can measure. Do the maths.
The ver1 measured 1000 Hz and ver2 measured 10000 Hz. So, if they are used for tachometer then they can easily measure 60 K RPM and 600000 RPM.
- - - Updated - - -
Change the resistor value from 220K to 270k 1/2W.
- - - Updated - - -
I tested the ver2 and it also measured 50 KHz exactly. So, if it is used for tachometer then it can measure 3000000 RPM without problems. In proteus it took some 10 seconds to display the data on LCD. Maybe it is simulation problem. Test in hardware and reply.
I will make a frequency counter using STM32 running at 200 MHz. I will see if it can measure MHz and GHz signals.
Edit: Tachometer image attached. Please somebody test the working in hardware. I don't have a signal generator.
- - - Updated - - -
Proteus took 20 seconds to display data on LCD. See last image.
Frequency counter version 5 which uses T1CKI. It is not precise. For 50000 Hz it shows some 49973 Hz. Proteus took 25 seconds to display data on LCD. Proteus time was running very slow. I know its because Proteus has to simulate a lot of things. I have ordered 50 MHz signal generator. I will test in hardware and reply soon.
The data is displayed on LCD every 1 sec. It displays properly on hardware. Just in Proteus if frequency input is high Proteus time will be slow like to simulate 1 second actual time Proteus takes 20 to 30 seconds.