Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Make a high-accuracy frequency meter?

Status
Not open for further replies.

Mr RB

Well-Known Member
Hi, I was digging through a junk box and found some large (double scale) 1x16 backlit text LCD displays I bought a while back.

I was thinking of using a PIC 16F or 18F and making a high-accuracy frequency meter. Here's some thoughts;

1. make a precision 5v supply
2. use my zero-error 1 second PIC code that can use a "long" constant for 1 second period
3. sample frequency over 1 second
4. home made xtal oven keeps xtal at 45'C (i've already got this)
5. PIC self-calibrates its xtal constant

The idea is that the xtal oven keeps the xtal at a constant output frequency. Then my 1 second code uses a long constant (like 20.0000000002316 MHz) to generate an exact second period.

The long constant is determined by the PIC by testing against a known standard, like say 24 hours testing against the mains frequency, or maybe 24 hours testing against a serial GPS etc.

If I use the PIC TMR1 asynchronous counter mode it is good for about 60nS period (from the datasheet) so that is about 15MHz max frequency that it would be able to measure. Then use averaging and zero-error rounding so the freq measurement gets very accurate over longer number of seconds test period.

This new frequency meter would be to replace my ageing frequency meters which are just xtal standard. I would also like to be able to "sniff" PIC clock xtals and see the xtal speed exactly, where my freq meters now are only 7 digits and not very good for that.

I know a very high accuract freq meter is an ambitious project but I've already got many of the hardware and software issues solved... Any thoughts?
 

MikeMl

Well-Known Member
Most Helpful Member
One of the bugaboos of using a freq counter to measure low frequencies is the very long measurement periods required to get decent accuracy. Add a "Period" measurement mode, where the Period is determined from the signal being measured, while what you count inside the PIC is the high freq clock. If you feel like it, add a mode where the PIC does the 1/Period calculation so that the frequency of the original signal can be displayed to 6 or 7 significant figures.
 

MrAl

Well-Known Member
Most Helpful Member
Hi,


I would have to ask why you need such an accurate measurement of the
frequency? Some specific application?
 

RCinFLA

Well-Known Member
One reference that is often used is GPS receiver. The 1 pps output is used to dissipline a TCXO.

The 1 pps output has an instantaneous jitter accuracy of 1 usec (which is usually limit of particular receiver module) but the accuracy averaged over 20-30 minutes is several ppb. Principle is divide your TCXO down to 1 pps and compare it to GPS receiver 1 pps. Make small corrections and average over time.

Most cellular basestation use GPS receivers for high accuracy. All commercial TV stations use GPS for reference. Power grid uses GPS to keep track of frequency to improve time to bring a generator on-line. I once built a high stab 10 MHz reference using off the air TV gated color burst phase locking a 14.318 MHz VCXO. It had a loop bandwidth of about 0.05 Hz. (no more color burst with digital transmission though).
 
Last edited:

Mr RB

Well-Known Member
One of the bugaboos of using a freq counter to measure low frequencies is the very long measurement periods required to get decent accuracy. Add a "Period" measurement mode, where the Period is determined from the signal being measured, while what you count inside the PIC is the high freq clock. If you feel like it, add a mode where the PIC does the 1/Period calculation so that the frequency of the original signal can be displayed to 6 or 7 significant figures.


That's a good point. Measuring a period against the PIC xtal is easy enough, then I suppose since the calibration constant is known the PIC can recalibrate that period against the recaibration constant.

ie; period = (measured period * 20MHz / 20.000000003Mhz)

Working with a larger PIC and C code it handles all the long or float values so that's not going to be hard to do once the calibration constant has been determined.

MrAl- Because I would like a better freq meter than my main one which is 1980's vintage and only has 7 digits total. Since I have a nice big text LCD and a xtal oven I made earlier it just seems like a cool project. I make a lot of PIC based timers and clocks, and if I had a freq meter that can sniff the PIC xtal and tell me to 12 decimal places what the actual xtal freq is, then I can just put a calibration value in software right at the moment I make the clock or timer. Intead of testing it for days etc.

RCinFLA- Cool info! I though of using the satellite TV AV signal, as the frame rate must be sent from the satellite and any communications satellite must have a pretty nice clock. ;) Even if the horiz line rate is generated locally in my set top box the total frame rate must never be higher or lower than frames sent, so this would be a real easy way to get a satellite driven frequency.

But I might just go GPS, there's one kicking around here somewhere.

No thoughts on just using the mains freq? Any software I make for auto-calibration of xtal against against mains freq can be used in any future clock projects too, so that is attractive to me. It's the best of both worlds, a mains synched clock that would also be immune to power cuts, spikes glitches etc.
 

Mikebits

Well-Known Member
GPS is cool idea but problem is reference signal will have to be piped in from outdoors, may limit functionality. I have heard some GPS rx units work indoors but I imagine they are expensive.
 

dougy83

Well-Known Member
The point of the xrystal oven is that the frequency stays quite constant. So once the frequency of the oven's worked out the reference (e.g. GPS) is no longer required (until the next calibration is due).
 

Mr RB

Well-Known Member
could be converted to an LCD
not real sure of accuracy??
Mondo Technology - Pic Projects

Wow! I'm impressed! That Superprobe a seriously cool gizmo for just one PIC and a little display!

But i've already got lots of voltmeters, cap testers, inductance meters etc etc.

What I'd like to make is just one REALLY accurate 12 digit freq meter (ok maybe it could incorporate freq generation in some way too, even just a 1kHz standard etc). I still like the idea of using the mains frequency for the calibration.

How about this as a basic self-calibration procedure to test the idea out;

1. Have a free running timer at xtal/4 (1:1 prescaler)
2. Get a timer value for 50 mains cycles (1sec)
3. Add that into a massive digital filter
4. Display the filter result
5. Repeat for a LOT of seconds...

So after one second a 20MHz xtal (5MHz timer) might record a period of 5000034 Hz, which would be displayed. Then every second that value gets averaged with new values so after 1 hour (3600 seconds) the value would display something like this; 5000034.23182 Hz

Here's a smart thought, the averaging algorithm can be much smaller because with a xtal the top 4 or 5 digits of the value will never change, so only the lower digits need to be actually averaged.
 

Mr RB

Well-Known Member
I had a couple of hours spare today so I set up a PIC to measure it's xtal against the mains frequency. Basically used the procedure above, used 8MHz xtal and free running TMR1 at 2MHz, then measured the period of 50 mains cycles (1 second) using TMR1 at 0.5uS resolution.

I averaged the reading into a big digital filter, using a long var to give 9 digits resolution and tried a few different filter values like a 10 sec/100 sec/1000 sec average, and it's now testing on a 10000 second average.

That mains frequency drifts up and down constantly! With my 7 digit bench frequency meter it just shows a slightly different period each time so you can't see patterns. But with a 100 second average you can see it drift up by about 300 parts per million for a few minutes, then down about 300 parts per million for a few minutes. Sometimes it hovers around a value for a while, but mainly it has that slow undulation in frequency.

I'll keep testing with the 10000 second filter, currently my 2 MHz TMR1 is reading 1999969.72 Hz but there is still some obvious freq drift on a minute cycle.

Maybe it can be made to work with a big enough filter, ie over many hours or days but for that length of time I think I would prefer GPS calibration or something guaranteed.
 

bryan1

Well-Known Member
G'day Roman,
for a precision 50hz signal wont a small pure sinewave inverter do the job for you. Just for a test awhile ago I put my fluke 865 scopemeter on the inverter to test the 50hz and it was spoton. I have found my cheap clock radio wont keep accurate time with the inverter and yes I have tried several. My conclusion with those cheaper clock radios they arent designed to run off a pure 50hz main frequency.

Cheers Bryan
 

Mr RB

Well-Known Member
Hi Bryan. If your sinwave inverter is a commercial one it is probably xtal locked and using a microprocessor to generate the 50Hz frequency.

I'm not sure why the clock radios don't keep good time, most of the older ones are mains freq synced and keep excellent time, but some of the new junk ones use a ceramic resonator and keep lousy time.

Or maybe you inverter doesn't keep perfect 50Hz time, it might be a tiny bit off all the time or maybe it drops freq a bit when your batteries are low? It doesn't have to be very far out for your clocks to lose a couple minutes a week. There's 0.6 million seconds in a week, so even if it's only 200 PPM out that's 2 minutes a week out.

Anyway I left the mains calibrator on for an evening, even with the 10000 second filter there was still some drift. I checked it about every half hour and the reading was anywhere from 30 PPM high to 30 PPM low at any point in time. I didn't see any errors larger than that. With a couple of days calibration the system would be workable, so maybe it's useful for clocks but I'm not sure about use for test equipment.

Has anyone checked the frame rate of sattelite TV (pay TV)?? Any thoughts on using that as a standard?
 

MalKontent68

New Member
Did anything come out of this idea?

Hi, I'm looking here and there for a good accuracy frequency meter project.
When I read the initial post I thought - hey, this guy wants the same as I do :)

Perhaps 12 digits is overkill, it's really hard to get a good stable reference clock with an accuracy better than 10^-12 - and for 12 digits, a reference of an order of magnitude better accuracy and stability would be needed :) I would settle for 10 digits.
A good reference is a GPS-disciplined oscillator (several projects available online, and also a ready-made used Thunderbolt GPSDO is available on eBay), or a rubidium oscillator (also available used on eBay). These offer 10^-11...-12 accuracy and stability, just what's needed for a good frequency counter.

One side of things is the accuracy of MHz level measurements, and the other is tuning of quartz oscillators for real time clocks (usually 32768Hz), or 1/2Hz signals available from some RTCs.
For such low frequencies, extremely long gate times would be needed, so indeed it's much better to have a period measurement option. The 32kHz signal can be divided to 1Hz and the period measured by counting raw reference clock pulses from first rising edge to another.

I'm a poor programmer, so I won't cope with such project. How about the original poster? Anyone? :)

All the best
Stan
 
Status
Not open for further replies.

Latest threads

Top