| Electronics > Projects, Designs, and Technical Stuff |
| Using ESP32 and Neo-7N for precise frequency measurement |
| << < (11/11) |
| edigi:
Some more update with code, screenshots, bill of materials and future plans. So why Arduino and serial output for evaluation? Naturally I use OLED/TFT in my more complete setup/code but that requires the relevant library installed etc and that adds nothing just complexity for the purpose of evaluation. Arduino is really simple, it's easy to grab the serial output and I've installed it on Linux without any trouble and probably the same applies to Windows. 50 GPS pulses (50s) are allowed between start/stop time stamping for reference compensation and as the counter is controlled by a 80 MHz signal thus it means 4 billion counts that just fits to 32 bits. If the clock source of ESP32 would be precise that translated exactly to 4 billion, if not then it can be used for compensation. Not directly but after filtering. A very simple filtering is used, maybe a more sophisticated FIR would be better (I don't know) but for a simple evaluation probably it should be OK. Filtered value is also saved to flash for convenience (as convergence of the compensating value is really slow) though I originally planned to omit it from the attached code as it's not strictly needed and also it's not necessarily the best example. Default measuring duration is set to 2.5 sec so it's not the limiting factor for 8 digits. So I've unpacked a brand new ESP32 eval board, connected it to the NEO-7N (on USB power using external antenna, both were good lessons but that's another story) and a Vanguard 0.1 ppm 25 MHz TCXO. Note: The frequency meter in this form requires CMOS compatible signal, so low value does not work and HIGHER VALUE THAN 3.3V ON ANY PIN WILL KILL THE ESP32 (a simple prescaler however makes it immediately usable for RF signals). I've made some screen shots about the convergence, using mainly the TCXO and also the 1pps signal that may sound odd but in reality not so. So the TCXO is around 1 Hz off (but that is still within spec) and the 1pps signal is mostly measured to be 1 Hz after the convergence but sometimes off with 1 in the least significant digit. What I did not like about the convergence that it's never completed (and mostly was far from that). I expected that there is a small variation at the end in the last digit of the 4 gig count, but it was more. Probably one factor is that the crystal driving ESP32 drifts a lot, but there can be many other factors as well like GPS sawtooth error, noise and jitter etc. So all in all a decent TCXO is needed for clock source of the ESP32 and after it's easier to figure out where else more improvement can be done. The need for improvement is pretty obvious after making counting duration longer and allowing for 9 digits. In the meantime however I've started to get interest for interpolating reciprocal counter. It's clear that I must raise the bar for the bill of materials so let's check the current state (obviously this is a hobby frequency meter so decent signal shaping in the front just like triggering is not much aimed and also it's not multi channel although platform has no limit for dual channel implementation and maybe even 4 is possible and also triggering is not so hard to add): 12 USD NEO-7N 6 USD ESP32 4 USD GPS antenna 20 USD TCXO (for ESP32 not for testing; still in progress) 10 USD Decent TFT (for the time being I use a smaller OLED for my more complete version) Thus altogether in the ballpark of 50 USD. New challenge for myself: doubling the budget (to the ballpark of 100 USD) for 2 more digits per sec thus in the magnitude of 10 digits/s. A quick search of how others did interpolating reciprocal counter I've found basically 2 methods: 1) Charging a capacitor and making AD conversion for the fraction ("analogue interpolation"), like this: http://n1.taur.dk/permanent/frequencymeasurement.pdf I'm admittedly not keen going into analogue direction as it usually translates to more components that kills simplicity however if it can save FPGA... 2) Phase shifting the signal via delay and using the phase shifted values to determine fractions like this: https://www.febo.com/pipermail/time-nuts/attachments/20071201/e7833af5/attachment.pdf or the more scientific version: http://www.wseas.us/e-library/transactions/circuits/2010/89-747.pdf As I'm not really familiar with FPGAs (and here it's probably hard to avoid), this will require more time and more dedication from me especially that budget for FPGA part is 50 USD (I actually have a cheaper one but that may not suit for this project). Note: I don't really have a need for this precision, this is just for fun. So as usual, what do you think? A small UPDATE: I've forgot to mention that if one is willing to settle for a fixed frequency GPSDO like 10 MHz and ready to invest 20 USD more (the price of VC-TCXO + 3 resistors one is best to be a potentiometer for course adjustment) with minimal code extension for around 70 USD not only a 8 digit frequency meter is achievable but a 1 ppb (or better since measuring time can be longer here) reference as well. VC-TCXO is actually pretty obvious choice but I was too obsessed with flexibility of DDS (cheap ones won't do as their analogue comparator has way too much jitter and better ones like AD9954 with low comparator jitter are too expensive for used just purely for this...). So I've ordered some VC-TCXO for reference but as Xmas is approaching probably I won't receive it any time soon, so no quick update on this either... (I've also noticed that someone is selling cheap VC-TCXO on e-bay but with high shipping cost so only large quantities are economical so I've skipped that as I can't do much with large quantities of VC-TCXO...) |
| Navigation |
| Message Index |
| Previous page |