Accurate Frequency Counter (0 - 65MHz)


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 ...



Last edited:


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.


Senior Member
Here is a version that should be more accurate because:
  1. It uses more 74HC4040 lines, resulting in smaller intervals (avoiding potential rounding errors due to low count figures at the lower end of an interval)
  2. #counts maximized by aligning interval boundaries with multiples of 2^16 (resulting in max count numbers registered (i.e. close to 65536) near the upper end of each interval)
The electrical circuit is documented in the code. It does not suffer from the COUNT accuracy issue as discussed > here <
I do not have equipment to validate my statement on "beautiful accuracy" , though :ROFLMAO: