Pulse Frequency Counter using Raspberry pi Pico

Last Updated on April 1, 2024

Measuring Frequency of a signal is an important task in many electronic product development and applications. We often use Oscilloscope to measure signal frequency or use frequency counter device, both are bulky and not suitable for continuous measurement and indications, they are pricey too. That’s why theorycircuit brings you simple Pulse Frequency Counter using Raspberry pi Pico. It can be used to count the input pulse frequency in Hz. If you want to use it for other signals like sine wave, triangle wave then use Schmitt trigger circuit to convert those signals into corresponding square pulse.

In this project we used Timer IC 555 to produce Square pulse signal in Astable multivibrator mode, Either you use standalone circuit or external signal source remember to make common Ground (Gnd) connection between Raspberry pi Pico board and Signal source. Then only it works properly.

If you are new to Raspberry pi Pico then read, Easy Way to Code Pico Board.

Schematic Diagram


Components Required

  1. Raspberry pi Pico board
  2. Hookup wires
  3. USB Cable (micro B)
  4. Computer with Thonny IDE

If you have external Signal source then following Components are not required.

  • Timer IC 555
  • Resistor 1KΩ, 220Ω each one
  • Variable Resistor 100KΩ
  • Capacitor 1μF
  • LED
  • Breadboard
  • Connecting Wires

Working Video

Construction & Working

As previously said, we used IC 555 Timer Astable multivibrator circuit biased with VBUS (5V) and Gnd from pico board. It produce square pulse depends on the timing Resistor RV1 and Timing Capaciot C1. By varying the RV1 we can get different frequency range pulse output. For indication of output pulse we used an LED at the ouptut of timer IC. This Output from Pin 3 of IC555 is directly connected to the GPIO pin GP2. The following microPython code gives output in shell and graph, you can use LCD for stand alone frequency measurement projects.

How to Calculate Frequency?

The following code utilizes an interrupt handler to count the number of pulses received on the Input Pin GP2. Count Pulse fuction increase pulse count for every rising edge detected on the input pin.

The ‘time.ticks_ms()’ function keeps track of the time, which returns the number of milliseconds since the board started running. and the ‘Start_time’ variable stores the time at the begining of each one second interval.

After every second the frequency is calculated as, frequency = pulse_count / 1.0 # Pulse count divided by time in one second, after that calculated frequency printed in shell as Hz.

microPython Code for Frequency counting


Leave a Reply

Your email address will not be published. Required fields are marked *