2

I'm trying to input the frequency of a 3.3V square wave on a GPIO pin as a program feedback parameter. The input frequency range would be 1000 to 100,000 Hz and data polling would happen at 30 Hz. Its important to minimize processor overhead.

We got the dedicated PWM pin on the GPIO working fine. Is there a similar dedicated frequency counting / timer GPIO pin that could do the low overhead counting?

Thanks Jim

goldilocks
  • 60,325
  • 17
  • 117
  • 234
Jim Sears
  • 21
  • 1
  • 1
  • 3

2 Answers2

6

There is no hardware support for frequency counting via the Pi gpios. You will have to monitor the gpios in software.

Given your upper end is 100kHz I suspect my pigpio library is most likely to give reliable results. pigpio works by sampling and doesn't have the significant overhead involved with interrupts at these frequencies.

Two frequency count methods are given in these examples.

joan
  • 71,852
  • 5
  • 76
  • 108
0

Pigpio is a good library to use up to 20 KHz but at 100KHz it's accuracy seems to be dropping to about 40% (according to our recent benchmark test on a RPi 3B). Still, it is the best one we know.

Khalil Khoury
  • 61
  • 1
  • 3