Frequency Counter by PIC16F628

In this project we are building a basic and low cost frequency counter circuit . It can measure from 16Hz to 100Hz signals with a maximum amplitude of 15V. The sensitivity is high, the resolution is 0.01Hz. The input signal can be a sine, a square or a triangle waveform.

The counter can be used in many applications. For instance, to observe an oscillator’s accuracy, to measure the mains frequency or to find out the rpm of a motor that is connected to an encoder.Frequency Counter by PIC16F628 schematic

The PCB file is provided in pdf format. You can apply it to the board by using the ironing method.

The components are listed below.

1 x PIC16F628 – 04/P Microcontroller
4 x Common Cathode 7 Segment Display
1 x 4N25 General Purpose Phototransistor Optocoupler
5 x BC547 NPN Transistor
1 x 7805 Voltage Regulator
7 x 330 Ohm 1/4 W Resistor
7 x 1K 1/4 W Resistor
1 x 470 Ohm 1/4 W Resistor
1 x 10K 1/4  Resistor
1 x 4.7K 1/4 W Resistor
1 x 1N4148 Diode
2 x 220nF Polyester Capacitor
2 x 22pF Ceramic Capacitor
2 x 100uF 16V Electrolytic Capacitor
1 x 4Mhz Crystal Oscillator

The CCP (Capture/Compare/PWM) module of the PIC microcontroller counts the input signal. Only the capture function is used. To learn more about the CCP module of the PIC please visit www.microchip.com.

The displays are 14.2 mm common cathode seven segment LEDs with red light.

Before measuring the frequency of the input signal, the signal must be converted to the square waveform. So an optical isolator circuitry with 4N25 optocoupler is used for this purpose. So the input signal is safely isolated from the microcontroller circuit and converted to square wave. The signal amplitude must not exceed 15V. If this happens, 1k resistor may burn. If you want to measure the mains frequency, you should use a 220V/9V transformer first.

The supply voltage should be between 8-12V. Since the circuit may be defected, you should be careful about the polarity while connecting the supply.Frequency Counter by PIC16F628

The counter circuit schematic is given in the project file. There are 4 displays that are driven by the multiplexing method. To make the measurement, the RB3 pin is connected to the output of the optic isolator. The second display’s 5 numbered pin is connected to the supply via 1K resistor so the dot after the second display brights. This connection isn’t shown in the schematic

The C code that is writen with Hi-tech PIC C compiler is available in the downloadable project file. The hex code is also included.

 
For more detail: Frequency Counter by PIC16F628

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter