Measuring frequency

I need to accurately measure frequency from a pressure transducer, and make it available on a LAN. A BBB ought to be able to do this, if the PRU can be made to accurately measure the frequency.

The frequency range is 30 kHz to 42 kHz. I need better than 0.01% accuracy. Overall latency in the reading is not too much of an issue, so long as it's not more than a few seconds.

Does the PRU let me connect a GPIO to a counter internally? I can measure some cycles and compare that to a crystal-driven counter.

Has anyone done this?


Since you need about 2 nS resolution, I'd recommend using the hardware
timer capture registers and averaging several samples.

Using the PRU to read a GPIO takes about 165 nS with a fair amount of
potential jitter in the timing depending on clock synchronization and
how busy the interconnect fabric is at that moment. The hardware
capture timers will only be limited by their clock frequency, and you
can average a bunch of readings to get sub-clock cycle resolution.


I’ve got a simple frequency counting PRU example on github, might give you some ideas. It should be trivial to change the polling / reporting frequency, but not sure it will run as fast as you want?


What about the CAP modules in the PWMSS? Two header pins are available (P9_28 and P9_42, max. 50 MHz). It’s supported by libpruio, ie. check out the pwm_cap example.



I was looking at some PRU reference docs; there's a capture module (I guess the one you're referring to), but it wasn't documented.

Also, it turns out the sensor that outputs frequency is like $6000, so I probably won't be needing this after all.

It's documented, just not in the PRU section. It's the same timer
capture module used on the ARM side of the SoC, with it's own chapter in
the Technical Reference Manual.

Oh thanks, that's helpful!