Crystal oscillator module accuracy test - is it really this "good"? - Page 1
Forum section: electronics / projects

author: Skimask
author_rank: Super Contributor
timestamp: March 21, 2014, 09:19:53 am
content: For the past 2 weeks, I've had a PIC running off an 8Mhz crystal oscillator module, doing nothing but marking time, counting the seconds, for grins, dumping the numbers out to an LCD, to figure out how accurate the crystal is.As of right NOW, I mean NOW, I mean NOW...ok...It's been running for 14 days, 8 hours, 23 minutes, 0 seconds... 1,239,780 seconds... and it's still dead on with GPS time. Maybe my push-button thumb was a couple milliseconds off and I've got a +1/-1 error in there, but still, is my math wrong in assuming this circuit is good to within 1PPM? Is that realistic?Input voltage to everything has remained -constant- at about 4.91v, temperature in the shop varied from about 50F-70F depending on the time of day.(Next update will be in 31.7 years, to see what it's PPB accuracy number is...)

author: Rerouter
author_rank: Super Contributor
timestamp: March 21, 2014, 11:16:28 am
content: Though i had to trim it in software by a fixed amount a 10ppm crystal I'm using has averaged out to a maximum deviation of only 0.3ppm over 15 to 35 degrees (I'm counting frequency from a device with a separate random crystal) no local references, but it took me holding an ice cube to one to actually increase the offset above the noise level (this caused a permanent shift)Though i have no idea if part of this stability was helped by going overkill on the noise isolation (grounded guard ring on both side) or why the other random one so perfectly tracks it while being a completly different model / brand(counting 0.029Hz to the microsecond really helps speed up calculating the deviation)

author: dannyf
author_rank: Super Contributor
timestamp: March 21, 2014, 12:12:36 pm
content: Most chip crystals are specified 20 - 50ppm. Most that I have tried are within 10ppm for indoor conditions.1ppm untrimmed, assuming the code is correct, is exceptionally good luck.

author: Skimask
author_rank: Super Contributor
timestamp: March 21, 2014, 06:50:52 pm
content: At any rate, gonna let it keep running at until it's off by a second, then probably let it run until it's off by 2. But at this rate, that could be weeks down the road. I think the cheapo wall wart that's powering it will give up before the count goes out of whack.And it's hooked up to a UPS.....just in case.

author: dannyf
author_rank: Super Contributor
timestamp: March 21, 2014, 07:05:18 pm
content: Crystals of 10ppm or less are very difficult to find. Oscillators of 10ppm or less are either OCXO or TCXO -> that should tell you something about how lucky you are.

author: tszaboo
author_rank: Super Contributor
timestamp: March 21, 2014, 10:57:38 pm
content: Quote from: Skimask on March 21, 2014, 09:19:53 amNow put your crystal in an oven, shake it 24/7, bend the board in two direction , and tell us, if it is still that stable.

author: JoeyP
author_rank: Frequent Contributor
timestamp: March 21, 2014, 11:53:28 pm
content: Getting a crystal that accurate at one temperature would be reasonably good luck. Having a crystal that accurate over temperature (without it being ovenized) is truly extraordinary luck. You should buy a lottery ticket TODAY.To tell the truth it sounds fishy. Not saying you are lying, but is there a possibility of accidental synchronization or a measurement error of some sort? Normally such a crystal would drift at least several PPM over that temperature range. Even temp compensated types do have a curve. In other words, it's not usually a straight-line relationship with temperature, so even the absolute very best crystals have some variation over temp.

author: ve7xen
author_rank: Super Contributor
timestamp: March 22, 2014, 12:29:46 am
content: Doesn't sound like stability was measured at all, so it's not totally out of the question to me thataveragefrequency over 1Msec was close to exactly 10MHz. Lucky, yes, but I would first suspect a drifty crystal happening upon that average value over time and temperature rather than a marvellously stable sample at exactly the right frequency.

author: Skimask
author_rank: Super Contributor
timestamp: March 22, 2014, 05:59:25 am
content: I can't argue with that logic at all.I'm not saying the 8Mhz crystal which I'm using to drive the PIC, was at 8Mhz 15 minutes ago, and will be at 8Mhz in 3 hours. After I all, I did say the temperature here in my shop has been fluctuating between 50F-70F on a daily basis. I guess over time, yes, it may have drifted up and/or down, but drifted right back the other direction to cancel itself out.Put it in an oven, shake, bake, and twist? nah... too much workIf I need something stable-r, I'll just buy another GPS module and use the time output from that. GPS isn't perfect either, but it's the stable-est and cheapest version of 'perfect' time source as I'm ever going to buy.There is no possibility of accidental synchronization with anything external. There is nothing external, aside from a push-button and power supply.The set up is very simple... A PIC running off the 8Mhz oscillator input, powered off a wall wart plugged into a UPS, a single push button input which started the counting, and hold the DISPLAYED count for a few seconds (but keeps counting in the background), and the requisite cap's, pullups, etc. TMR0 kicks an overflow interrupt. Count the number of microseconds between those interrupts. Adding everything up, divide out the seconds/minutes/hours/days. Display on a parallel LCD. Nothing more, nothing less.I started it up at ~exactly~ time X about 16 days ago using my handheld GPS's time as a reference and using that same GPS modules time output for a comparison.And thus far, every time I've checked it at various times during the day or night, it's been dead on, at least inside of one second, and/or as fast as my eyes could switch back and forth between the LCD and the GPS.I'm going to let it run for a couple more days, maybe over the weekend and see what happens.Maybe next time I run this little "experiment" (which I'm sure has been done by a thousand people and million different ways in the past), I'll hook up my GPS module, grab the time from it, start them at time X, and data log the delta-time to an SD card and let that run for a few weeks and see what happens. Maybe even put it in a box with a couple of peltier modules on it and a temp control circuit to vary the temp around as I see fit. Or just let it sit out there in the wind....It's not entirely out of the realm of possibilities that I've got a "perfect" oscillator sitting over there on the bench running...I don't believe that for a second. And if somebody told me they had a "perfect oscillator", I wouldn't believe them either.

author: VK5RC
author_rank: Unknown
timestamp: March 22, 2014, 06:21:40 am
content: If you can get hold of an Agilent 53230 GPS locked, it can do great graphs of accuracy vs time and histograms of frequency ( /period), it is similar to the 34461s graphical ability.It is the start of a never ending quest for accuracy!How good is the lag in the device that reads the GPS PPS?I think finger reaction times are rarely better than 100-200mS, I recall the brain thinks we are better.

author: Skimask
author_rank: Super Contributor
timestamp: March 22, 2014, 07:46:44 am
content: It's the LS20031 I got from sparkfun a long time ago. Has a 1 PPS output so I think I'll be using that to grab the 'latest' sentence from it and logging off that. No idea what the lag is on the PPS output vs. the latest sentence read, but I think it would be fair to assume that the lag would be fairly constant. Might have a fair amount of jitter, but over time, it would average out.I know that there'll be a fair bit of jitter between grabbing the latest sentence and having the latest update from the PIC, but I guess I wouldn't be looking for specifically millisecond accuracy for one reading. More like...ok, between readings 200 and 300, the clock was 1/2 second fast and between readings 600 and 700 it was 1/2 second slow, that sort of thing.I think basically I'm wondering if these 100ppm oscillators are actually <100ppm or what, and just how close to dead on can they really be.100ppm over a year only amounts to about 52 1/2 minutes. Compare that to an average cheapo wind up clock and that ain't bad. Even in a day, you're only off by just short of 9 seconds (at 100ppm). Get that down to 10ppm, and you're talking about 5 1/4 minutes over a year and less than a second per day.I've built a lot of projects over the years that have used the MCU and osc as a time/clock base (vs. using a real RTC chip) and have wondered if they're really that accurate. More importantly, I'm wondering if maybe, in the future, when I build something that really needs solid time, if I might have the need add a GPS module, or a Wifi module, or whatever, and really need sync up the time, if once per day will be good enough, or once per week or what.An exercise in futility? Possibly... Takes practically zero effort on my part....just sits there and runs. That's my kind of experiment.

author: kripton2035
author_rank: Super Contributor
timestamp: March 22, 2014, 08:22:29 am
content: Quotethat's a nice followup of the first experiment !

author: VK5RC
author_rank: Unknown
timestamp: March 22, 2014, 08:40:06 am
content: I suspect the 100ppm is worst case scenario, your crystal does seem to be really good, if I recall correctly they slowly "age" going out of frequency over the years, I have a little interest in time, and love retro look gear e.g. Nixies and red LED 7 segment displays, one of my best builds was a clock (LED) that read the NMEA statement from a GPS unit , added the correction for your time zone and displayed the time. It was from a Silicon Chip (Aus electronic magazine) design.I suspect if you were to try a whole bunch from the same batch of x-tals you may not always be so fortunate.Using 'GPS time' (if I recall it is 'early on' in the GPS unit's output sequence ) to really lock down time is used a lot. Another method, perhaps overkill, may be to use a GPS disciplined oscillator 10MHz source to clock the MPU, it may avoid the issues of corrections of time if you only intermittently correct your crystals time.I hope you have seen the time nuts blogg and TV Baak s Leap second pages, I found them really interesting.

author: Yago
author_rank: Frequent Contributor
timestamp: March 22, 2014, 08:42:30 am
content: I seem to remember that crystals are cut to fit a temperature profile.Roughly following a "U" shape, either cut to sit in the bottom of the "U" for least change at target temp, or at a leg of the "U" to have a linear change (like deliberate error navigation).

author: hagster
author_rank: Frequent Contributor
timestamp: March 22, 2014, 08:48:56 am
content: The GPZDA message is normally gives the time of the previous 1PPS pulse. The latency is undefined. The GPS engine datasheet will tell you the accuracy of the pulse. This probably assumes a good satalite fix with no multipath and maybe a choke ring antenna.

author: Skimask
author_rank: Super Contributor
timestamp: March 22, 2014, 11:57:57 am
content: I've had this particular 8 Mhz oscillator since roughly '96. I remember because it oscillated for one of my first PIC projects (MP3 player using a MAS3507 and a whopping 4GB hard drive!), and used the 4xPLL to get halfway decent speed out of it.If I remember right, I tore that project down sometime in '98 when I moved and it's been sitting in that same bin up until about 3 weeks ago.I've only got 1 of them so obviously not going to get to do any sort of batch testing or anything.

author: npelov
author_rank: Frequent Contributor
timestamp: March 22, 2014, 10:26:00 pm
content: I made a simple clock with some PIC18 and 32.768 kHz for the RTC. First it was drifting too much - few minutes for a week. Then I found out that the reason is the crappy chinese adapter. I changed it with a transformer and a linear regulator (don't remember if it was 7805 or an LDO). After 1 week it was still spot on. but it gets colder at night and hotter during the day. It could happen that you got lucky, but seasons change and it won't be like this forever. There is no way you can get 1-2 ppm or less from just a quartz forever. For example I used 12MHz crystal and with some math on timer interrupts I managed to make an interrupt 200 times a second and output that on a pin. Then measured it using OCXO and another controller. With the math I trimmed it to ~199.99982 Hz. If I open the window and the temperature drops with 5 degrees, the frequency drops to ~199.9993 Hz. it doesn't always go the same way. if I continue to cool it, the frequency jumps again and then drops again. So I got about 2.6 ppm for few degrees C (I didn't bother record the exact numbers, because I needed a precision controlled temperature environment).So there is no way you can get <1ppm for 24 hours. You are just lucky to have drops as much as rises in the frequency ... for the current weather conditions.You could make software TCXO if you have aand precision frequency meter. If you are making a clock a thermometer is always a good option ot it and it might help of compensating for the temperature changes.Also these things age with time. If you leave it working for an year, the speed of aging will decrease. The drift is bigger when it's brand new and then it stabilized a bit.

author: jimmc
author_rank: Frequent Contributor
timestamp: March 22, 2014, 10:59:29 pm
content: Quote from: Yago on March 22, 2014, 08:42:30 amDepends on the crystal cut, 8MHz is probably AT cut which has a cubic curve seehttp://www.hpmemory.org/an/pdf/an_200-2.pdffig 14Jim

author: Skimask
author_rank: Super Contributor
timestamp: March 23, 2014, 12:27:02 am
content: @jimmc - Good link. Good reading. I think I know enough about quartz crystals now to be slightly dangerous

author: Skimask
author_rank: Super Contributor
timestamp: April 20, 2014, 01:25:11 pm
content: Following up after a few weeks or so...Thing has been running for a little over 46 days. Checked it this morning.STILL dead on...again, at least as dead on as far as my eyes can shift back and forth between the LCD and the GPS I'm using for a reference, so I'll give it a +/- of at least 1 second.So, unless my calculations are wrong... 46 days @ 86,400 seconds per day = 3,974,400 seconds. If this oscillator is off by one second, that's still less than .25ppm.Temperatures in the shop have fluctuated between 50F-70F on a daily basis, constant 5v off a wall wart power supply plugged into a UPS, not sitting near a window so it's not being sun-baked during the day, humidity doesn't change appreciably. Can't think of any other factors that would cause it to drift one way or the other.Now watch...with my luck the thing will magically go out of whack tonight and lose it freekin' mind...