Accurate Frequency Counter (0 - 65MHz)

kranenborg

Senior Member
Dear Picaxe enthousiasts,

Since I am in need of a frequency counter for an analog electronics project I googled around and quickly ran into a nice PICAXE implementation (0 - 65MHz) that seemed to satisfy my requirements very well. Its design was published in 2006 (!) by Jeremy Leach, who has been a prolific contributor to this forum (but he has not been hanging around anymore lately I think). The thread and the original program can be found in the PICAXE archives here: Link to Jeremy's implementation

Since this implementation is really old now and on deprecated PICAXE hardware (08M) I decided to modernize it (whilst keeping Jeremy's concept and most of the implementation intact as it seems to be very well designed). I have now built it, did several tests and it appears to perform wonderfully, with a frequency (relative) accuracy of close to 0.1% (but I need to test more).

The hardware setup consists of a 28X2 (with a 16MHz crystal i.s.o. the usual resonator), running at maximum frequency (64MHz), and a 74HC4040 binary ripple counter.

The key changes I made compared to Jeremy' implementation are (as copied from the code implementation):
  • Jeremy's concept & code largely retained (>95%)
  • Adapted 08m to 28x2 with very accurate crystal (the 28X2 is the smallest PICAXE allowing the use of a crystal as its time base) -> no calibration needed anymore!
  • Significantly shorter sample times (4x - 16x) without compromising accuracy (this required a change in the divisor output selection)
  • Addition of SERTXD PC-output for testing or use (in parallel to LCD display like AXE133)
  • Minor comments changes + clarifications
All credits really go to Jeremy, I have merely polished the program towards the current hardware standards and made some performance improvements because of that.
The code is strongly documented (but also check the 2006 thread) and includes detailed information on the hardware setup needed.
I also attached a simple 08M2 frequency generator program for quick testing of the frequency counter using 4 frequencies (4KHz - 4MHz)

PS1: There is still room for significant improvement (theoretically a tenfold increase in accuracy, and the 28X2 has many more inputs to make that happen) and I am working on that right now, but for most practical applications the current program will serve very well.
In case anyone sees an issue or improvement then I am happy to be informed!

PS2: I tested using the SETXD output, as I currently do not have an AXE033/133 LCD display at hand. But I did not make any changes to Jeremy's part of the LCD code ...

BR
Jurjen
http://www.kranenborg.org/electronics
 

Attachments

Last edited:

fernando_g

Senior Member
Thanks Kranenborg, for the update of a real “classic” PICaxe project.
I have also used the 28X because of its external oscillator capability.
In one instance where I required very high precision, I actually employed the 10 Mhz signal from a GPS disciplined oscillator.
 
Top