Using ESP32 for precise frequency measurement
Posted: Fri Oct 05, 2018 7:16 am
I'm building with ESP32 a high precision frequency meter. Under high precision I mean 7-8 digits. Later on I plan to use Neo-7N GPS receiver to calibrate and improve precision (via 1pps output; it works, tested already).
I've used RMT to generate gating signal and PCNT to count the signal to be measured. There are several examples of this on the net.
What I've noticed is (and also documented in this way) that PCNT does not do a direct counting but basically samples the signal to be counted with 80 MHz sampling frequency.
This means that it's difficult to measure signal around 40 MHz (half the sampling frequency) but I had no trouble going above of 40 MHz in which case naturally the pulses counted reflect a mirrored image. Thus e.g. 50 MHz is counted as 30 MHz and e.g. 100 MHz is counted as 20 MHz and so on.
The input pin is so good that I had no trouble going even till 150 MHz (roughly the maximum that AD9954 square output that I've used for the testing can generate). The values counted above 40 MHz are also still surprisingly precise, thus e.g a precise 100 MHz value is counted precisely as it were a 20 MHz signal.
So this brings up the big question: Is there a way in ESP32 to make direct counting of a TTL signal instead of this sampled method which unnecessarily limits the max. frequency of the counter?
I've used RMT to generate gating signal and PCNT to count the signal to be measured. There are several examples of this on the net.
What I've noticed is (and also documented in this way) that PCNT does not do a direct counting but basically samples the signal to be counted with 80 MHz sampling frequency.
This means that it's difficult to measure signal around 40 MHz (half the sampling frequency) but I had no trouble going above of 40 MHz in which case naturally the pulses counted reflect a mirrored image. Thus e.g. 50 MHz is counted as 30 MHz and e.g. 100 MHz is counted as 20 MHz and so on.
The input pin is so good that I had no trouble going even till 150 MHz (roughly the maximum that AD9954 square output that I've used for the testing can generate). The values counted above 40 MHz are also still surprisingly precise, thus e.g a precise 100 MHz value is counted precisely as it were a 20 MHz signal.
So this brings up the big question: Is there a way in ESP32 to make direct counting of a TTL signal instead of this sampled method which unnecessarily limits the max. frequency of the counter?