32KHz Oscillator Calibration Standard - Page 1
Forum section: electronics / general

author: aurmer
author_rank: Regular Contributor
timestamp: November 14, 2016, 03:33:21 am
content: What do I Google for to find a kHz or MHz clock source which is suitable for calibrating a 32KiHz Real Time Clock and Calendar of my PIC24? I am aware that arubidium clockis more than enough to do the trick, but I am trying to find something ~$100 and ideally pre-assembled and sold as a "Xppm Laboratory Clock Reference Tool" where X is 1ppm or less.Can anyone point me in the right direction?Perhaps I am looking for "Signal Generator with 1ppm frequency tolerance at 32.768KHz", but then how would I know that the signal generator is even calibrated correctly?A greater degree of context can be read below.--------------I am submitting a proposal to my client (aka professor) that his widget (which keeps time with 32KiHz oscillator) needs a calibration step as a part of the assembly process. As far as I can tell, we can save money and spend extra time using the 1PPS output of a GPS device. The resolution of this calibration is 2ppm, so as soon as I measure a drift of one second, I can use the number of seconds it took to get to 1 second drift and extrapolate the ppm error E.E / 2 = C calibration units. C gets set into the calibration register value.This takes some time though because of the low frequency of the "reliable clock source". On the other hand, it is a rather cheap option.--------------Conversely, we can purchase a reliable (1ppm or lower) clock that runs at 32KiHz (or faster). This way the drift can be seen quicker because it is comparing the pulses of the oscillator not the incrementing of clock seconds.This way will surely cost more up front, but it will only take about 30 seconds maximum to properly calibrate the clock on the device.The trouble is that I am have little success googling for "Laboratory grade electronic clock source". I don't know what to call it in order to get the google results that I want.--------------

author: edavid
author_rank: Super Contributor
timestamp: November 14, 2016, 04:17:18 am
content: QuoteIt's called a frequency standard.All you need to do your calibration is a frequency counter. A good one will measure 7-8 digits per second, so you can do your measurement quickly.If you only need 1ppm accuracy, a counter's internal OCXO standard would be good enough.To do better, you would hook up an external GPSDO 10MHz standard.

author: Ian.M
author_rank: Super Contributor
timestamp: November 14, 2016, 05:50:06 am
content: You also seem to be suffering from some confusion about the frequency of the oscillator you are trying to calibrate. A PIC24 RTCC module *requires* a 32.768KHz crystal not a 32.000KHz one. It doesn't really matter if you are going to use a frequency counter with a GPSDO reference, but if you are trying to cheap-skate it with a divider chain fed from a readily available GPSDO or OCXO, followed with low-pass filtering and feeding it to a scope in XY mode to beat against the D.U.T, the difference is critical.Personally if i had to cheap-skate it, I'd add a calibration routine to the code. Feed in the 1Hz GPS derived pulse to an input capture module and use it to calibrate the primary oscillator, then continue to monitor it for drift over a period of several minutes. Over the same period, feed the RTCC's second pulse output to another input capture module and calibrate it against the primary oscillator.N.B consumer GPSes often have a lot of jitter on their 1PPS which will degrade the accuracy you can achieve. Seehttps://www.eevblog.com/forum/chat/how-accurate-is-a-gps-1pps-signal/

author: David Hess
author_rank: Super Contributor
timestamp: November 14, 2016, 06:23:48 am
content: Quote from: Ian.M on November 14, 2016, 05:50:06 amThis is what I would do. Ignoring GPS effects, a typical GPS PPS output will have anywhere from 33 to 100ns of jitter because of its asynchronous processor clock however time periods greater than 1 second can be used for greater accuracy. The calibration routine should also generated a histogram allowing bad timing pulses to be ignored.My next choice would be to find an inexpensive used frequency counter on Ebay which has a TCXO or OCXO and a reference output.

author: Dr. Frank
author_rank: Super Contributor
timestamp: November 14, 2016, 07:46:00 am
content: Quote from: zetharx on November 14, 2016, 03:33:21 amYou have some misconception about time calibration..For your purpose, you only need a stable and precise reference source and a frequency counter.The reference frequency usually is 10MHz, and may be built into this counter, but you require an OCXO, an Rb or a GPSDO, otherwise the stability requirement (also < 1ppm ) is not fulfilled.TCXOs and ordinary XTAL oscillators usually have stability AND precision specifications of > 1ppm.The frequency counter will compare the 32kHz frequency widget of your professor against the reference oscillator and will also directly display the deviation from the default 32.00000kHz.For that purpose, no reference oscillator of equal frequency is required, as the frequency counter acts as a scaling device, by its internal counter/divider chains.Get a reciprocal counter, at least!For about 100$, I think you won't get an appropriate calibrated OCXO, maybe on the 2nd hand market. Chances are good, that an OCXO is already adjusted to around 10^-9 accurate nominal frequency.Cheaper TCXOs maybe be specified around 1ppm adjustment, but that's quite tight to use that as a < 1ppm reference.If you have access to a GPSDO, like Trimbles Thunderbolt, for example, it will deliver uncertainty and stability of about 10^-10 @ 1sec, going down to 10^-13 @24h with appropriate comparison techniques.So that would be the best way to bring high uncertainty in time into your lab. (The pps jitter parameter is completely irrelevant for this purpose).The Thunderbolt had been sold for around 150$, including antenna and PSU, a few years ago, from China.These or similar units might show up from the time-nuts community, from time to timeAnother possibility is the long wave radio signal WWVB, or similar.Frank

author: bktemp
author_rank: Super Contributor
timestamp: November 14, 2016, 08:05:41 am
content: Quote from: zetharx on November 14, 2016, 03:33:21 amAre you trying to calibrate a 32768Hz watch crystal?If yes, you don't need anything much better than a few ppm, unless you have added a temperature compensation, because watch crystals have a rather large temperature dependency (much larger than crystals in MHz range).QuoteNever measure directly at the oscillator, because any additional loading will change the frequency! Always measure using a buffered output.If you only have the clock seconds output, it also works, because you can measure the phase drift between your reference 1Hz and the RTC 1Hz signal.

author: Kalvin
author_rank: Super Contributor
timestamp: November 14, 2016, 08:59:45 am
content: Do not count the frequency directly (ie. do not count how many cycles the DUT (device under test) produces in one second). Instead, make the measurement using reciprocal measurement which will give you much higher resolution and accuracy faster (for example, you may have a high accuracy 10MHz oscillator like GPSDO, thus you may want to measure how many cycles a counter will get from a 10MHz oscillator within 32768 counts of the DUT). Using analog interpolators or Vernier-techniques you can increase the resolution even further. See this application note:http://leapsecond.com/hpan/an200.pdfPIC24F has a nice set of 16-bit/32-bit timer/counters which can be used to make this kind of calibration quite easily. Just feed an accurate 10MHz external clock. The PIC24F has an internal 8MHz RC-oscillator which can be pumped up to 32MHz using the internal PLL. Although this RC is not accurate, it doesn't matter as the measurement accuracy is dependent only on the 10MHz external reference clock. The 32MHz clock is only necessary to be able to clock the on-chip counters synchronously.

author: aurmer
author_rank: Regular Contributor
timestamp: November 14, 2016, 12:35:54 pm
content: Quote from: Ian.M on November 14, 2016, 05:50:06 amIf you look closer, I said 32KiHz or 32 KIBIHERTZ not KILOHERTZ. KIBI means 2^10 not 10^3.reference32KiHz = 2^5 KiHz = 2^5 * 2^10 Hz = 2^15 Hz = 32,768Hz

author: aurmer
author_rank: Regular Contributor
timestamp: November 14, 2016, 12:40:53 pm
content: Quote from: Kalvin on November 14, 2016, 08:59:45 amThis sounds great. Where do I find an accurate 10MHz external clock? This is problem that this novice is having at the moment. Another poster suggested that I am looking for a "frequency standard" or perhaps a "frequency counter".

author: aurmer
author_rank: Regular Contributor
timestamp: November 14, 2016, 12:54:50 pm
content: Quote from: Dr. Frank on November 14, 2016, 07:46:00 amThanks! This has given me some words to put into google to learn more about what I am looking for. I just have one more question.The frequency counter makes sense! But once I read the screen of the counter, then I will have to communicate that information to my microcontroller. Wouldn't it be better to provide the uC with a 10MHz signal, press a "calibrate" button, and let it do its thing? (Basically it would just count pulses of each clock and do the math estimate error, the longer the test period, the more reliable the result)Does this idea work, or am I still misunderstanding the process?

author: Kalvin
author_rank: Super Contributor
timestamp: November 14, 2016, 01:19:42 pm
content: You can proceed with the idea and development by using a cheap 10MHz oscillator. If you want a batter stability you can use temperature / oven stabilized 10MHz oscillator. After you have the concept working, you can either measure the actual 10MHz oscillator frequency and calculate the compensation in software, or you can buy more accurate and more expensive 10MHz frequency standard if that is required. However, I wouldn't bother with the accurate but expensive frequency standard because the 32.768kHz crystal oscillator will drift anyway due to the temperature changes. The crystal may also drift slightly in frequency in the few first days / weeks it is being used.Edit: For example, TCXO Oscillators 10MHz 3.3Volt .28ppm -40C +85C costs around $10. A bit less accurate 10MHz TCXO 2.5ppm costs around $3.

author: babysitter
author_rank: Frequent Contributor
timestamp: November 14, 2016, 01:26:35 pm
content: Hi,$100canget you a decent TIC and ocxo. I got it, if you neglect shipping and tax. But you might actually not need it:Does the widget have a free GPIO and some program/data memory leftovers?During setup youcouldhook any given nice source, divided to logic level PPS or PPhalfS or such to the widget. The widget itself could compare its own clock frequency against the source and store a constant which tells the rest of the firmware what the actual clock rate during setup was.

author: Dr. Frank
author_rank: Super Contributor
timestamp: November 14, 2016, 02:15:38 pm
content: Quote from: zetharx on November 14, 2016, 12:54:50 pmIf I understand you correctly, you would set up / program a sort of frequency counter, or frequency comparator (which is practically the same) by your widget itself.Provided, your widget has the appropriate hardware, like fast enough counter registers and I/O ports and the appropriate software, yes, then that can be realized.This widget can also determine the necessary correction (calibration) factor and correct its internal clock by introducing some delays in the software.If you specify, what this widget is consisted of, i.e. which building blocks it has, it would be possible to make some proposals.Using an external counter does the same, but you would need an interface to a master PC, which would then determine the correction factor and program that in your widget.In automotive applications, the car clock (in the instrument cluster) has to be adjusted in manufacturing, so that it runs very precisely in the field, also on the order of a few ppm.This clock is realized inside an embedded controller, counting clock cycles of its XTAL. (no RTC used)To reduce current consumption when the car is standing still, 32.768kKz tuning fork type crystals are sometimes used, which have a very mediocre temperature stability.So it's regularly compared to an AT cut XTAL at 4MHz (interrupts / wake up every few minutes), which is much more stable, and which frequency has been calibrated once at the manufacturing line.Maybe such a process is also interesting for you.. everything can be done in the controller and in software, aside from the basic calibration, maybe.Frank

author: aurmer
author_rank: Regular Contributor
timestamp: November 14, 2016, 03:05:41 pm
content: There is much more to my widget than this, but the relevant components are quite few and simple.Also, I want to note that I am aware of the concept of "your crystal is fundamentally unstable at the 1ppm level so calibrating to that level is irrelevant" or in other words, "you can't calibrate beyond your precision capability". So of course this should be considered when I am spending money on a "reliable" clock source. I don't need it to be 1ppb because that value is wasted on my crystal's instability.Attached is a simple, quick drawing of my timing circuit schematic.Reference manualsays that the calibration method adds or subtracts a given number of oscillator pulses once per 15 seconds. This results in a calibration resolution of 2.64 sec/month.The crystal will ultimately be the best stability that I can find, but you will notice it is not temperature controlled. This is expected to operate in a climate controlled room at room temperature.crystalsAnother point is, I prefer to use the Secondary Oscillator within the PIC24 for this because the widget has a valid battery mode where the board's Vdd goes to 0V and the only power is supplied to the Vbat (battery backup) pin of the PIC24. This means that an external oscillator would cease to function while in low power battery mode. That is why I am just looking at crystals, not IC oscillators.

author: Kalvin
author_rank: Super Contributor
timestamp: November 14, 2016, 03:22:16 pm
content: Quote from: zetharx on November 14, 2016, 03:05:41 pmThe 32.768kHz crystal oscillator will keep working when the PIC24F is running on battery, so in that sense your RTCC will be running just fine. Using a secondary oscillator (either a crystal or IC oscillator) will be turned off anyways, being it either a crystal oscillator or a IC oscillator. The crystal oscillator will consume less power, though.I do not know your requirements for the accuracy of the secondary oscillator, but the internal 8MHz RC oscillator is quite usable for applications that doesn't require extreme timing accuracyThe internal 8MHz RC oscillator can be fine-tuned by the on-chip registers. So, if your 32.768kHz oscillator is accurate enough, in principle you could use the 32.768kHz oscillator as a frequency reference for fine-tuning the 8MHz RC oscillator on-the-fly. Of course, using an external secondary crystal oscillator or IC oscillator make thing much easier and less complicated, and you can select the accuracy more precisely per your requirements.

author: David Hess
author_rank: Super Contributor
timestamp: November 14, 2016, 07:02:33 pm
content: Quote from: zetharx on November 14, 2016, 12:40:53 pmThis is why I suggested using a frequency counter which includes a 10 MHz reference output as your source. They can be found used with TCXOs inexpensively and while I have never looked specifically for one, also OCXOs although I am not convinced that that level of precision would be required for this.An HP5316A/B for instance includes a reference output BNC and with option 001 has a TCXO and with option 004 has an OCXO.

author: aurmer
author_rank: Regular Contributor
timestamp: November 15, 2016, 04:18:11 am
content: Here is a 10MHz frequency reference for sale.The spec sheet talks about how it needs to be synchronized before it is reliable. When does it end?! I suppose what I should do is find a device that has a GPS self-synchronization feature or something.Or am I missing something else?

author: David Hess
author_rank: Super Contributor
timestamp: November 15, 2016, 07:06:31 am
content: Quote from: zetharx on November 15, 2016, 04:18:11 amA GPS disciplined oscillator is a fine solution. Even a hobby level one using a normal voltage controlled crystal oscillator would be more than sufficient. They are just not as common or inexpensive as a used OCXO although they *are* self calibrating.

author: aurmer
author_rank: Regular Contributor
timestamp: November 15, 2016, 09:46:50 pm
content: Thank you all for your assistance in my learning about this subject. I have selected some options.This may be worthy of a new thread, but Ill keep it here since there is already context.Consider thisGPS Disciplined TCXO module- and itsDatasheetIs it possible that all the needed antenna circuitry is within the IC? The spec sheet doesn't really specify.Can someone help me find a resource teaching how to construct the necessary antenna circuit for this module? What goes in this "black box" that I drew on my schematic?The idea is an active antenna; it will be indoors and always plugged into the wall.Thanks again for all the help so far.

author: Ian.M
author_rank: Super Contributor
timestamp: November 15, 2016, 10:42:45 pm
content: Possible: yes. Certain: no. When you've got it check the voltage at pin 10. if its not 5V you'll need a power injector - basically a series cap in the signal path and a choke teed off to block RF but pass DC to feed a weatherproof external active antennae . I've used consumer satellite power injectors for GPS before now e.ghttp://www.trade-works.co.uk/satellite-dishes-lnbs-c189/satellite-dish-accessories-c193/televes-power-injector-10-2150mhz-p2459or roll your own right next to the module on the PCB you mount it on.Depending on the wiring distance between the module and the nearest place you can mount the antennae with anunobstructedsky view, you may do better to use an antennae containing a GPS receiver and run power to it and signals from its NMEA0183 (for status monitoring) and 1pps outputs over CAT5 back to your bench, then use the module's 1pps input with its own GPS disabled. If using an external GPS reciever, you may need to hookup its NMEA0183 input as well so you can send configuration commands to it. Particularly long cable runs (e.g. roof to basement of a tower block) may need local regulation to 5V at the receiver + balanced line drivers and receivers for the 1pps and data signals.