7
\$\begingroup\$

I am trying to measure the frequency of a 32.768 kHz watch crystal which is connected to my AVR MCU. This is so that I can fine-tune the crystal's capacitor values to get a correct frequency. However, I don't seem to be getting any output on my oscilloscope (a Rigol DS1052E with the factory probes).

I have tried measuring between both crystal legs and also between one leg and ground and don't get any output. I have set the fuses correctly for the external crystal, and the MCU is working.

Also, even if I could measure the frequency, could I be sure that the measured frequency is what it would run at, or would the oscilloscope probes end up giving me a distorted reading somehow? If so, how can I tune the caps to get a stable 32.768 kHz frequency?

\$\endgroup\$
3
  • \$\begingroup\$ What crystal you are using, pls add datasheet and capacitor values currently on board.? \$\endgroup\$
    – AKR
    Nov 4, 2013 at 8:40
  • \$\begingroup\$ It's a 30 PPM crystal with 22 pF caps. I don't have a datasheet as the web site I purchased them from don't have one. \$\endgroup\$ Nov 4, 2013 at 8:50
  • 2
    \$\begingroup\$ Hint: You can also correct for constant drift in software, once you have measured the crystal's actual frequency over some time, like 24h or so. No need to long-term measure, adjust capacitor, measure, adjust capacitor, ... \$\endgroup\$
    – JimmyB
    Nov 4, 2013 at 15:49

4 Answers 4

18
\$\begingroup\$

If the AVR or any MCU has a way to output the clock to an external pin, even if it divides it down, I would measure that pin. Measuring at a clock pin will interfere with the clock frequency due to capacitance of the scope probe. This way it’s buffered.

\$\endgroup\$
9
\$\begingroup\$

Actually I somehow doubt that the accuracy of the oscilloscope will be enough in order to adjust the frequency of the quartz crystal that to be used as a clock.

For example 1s difference in 24h is equal to 0.001% accuracy. 1s in a week is 0.00016%.

The calibration can be done with frequency meter. If you have one with 1Hz resolution, you will get 3s per 24h accuracy.

Frequency meter with 0.1Hz resolution (and properly calibrated of course) can provide 300ms per 24h accuracy.

There is an easy way (but takes longer) leave the clock to count the time for a 24h or even more and to synchronize to radio clock signals.

An alternative is to use Internet accessible time servers with the same method.

\$\endgroup\$
8
  • \$\begingroup\$ I have a 50 MHz scope. So in one period of oscillation in the crystal, my scope should take 50000000/32768 = 1525 samples. I don't see how it could possibly miscalculate the frequency unless I'm missing something fundamental? \$\endgroup\$ Nov 4, 2013 at 9:53
  • \$\begingroup\$ Because of the accuracy of the XTAL of your scope itself. Should be an OCXO by the way... \$\endgroup\$
    – Blup1980
    Nov 4, 2013 at 9:58
  • 1
    \$\begingroup\$ Check your scope specification. What is the frequency measurement accuracy? Compare it with the numbers from the answer. \$\endgroup\$
    – johnfound
    Nov 4, 2013 at 9:59
  • 4
    \$\begingroup\$ @David: I suppose you want to measure the frequency by measuring the period length and then calculating $$f=1/T$$. But if your scope's crystal is way off, it will tell you the wrong period length. Example: Let's say you have a 1 MHz scope that is so broken that it only samples at 500 kHz. If this scope is used to measure a 1 ms interval, it will perform 500 samples. But because it doesn't know it is wrong, it will think that the interval is $$T=\frac{500 \text{ samples}}{1 \text{ MHz}}=500 \text{ µs}$$ long. So you can't reliably measure frequency if your scope's frequency is unreliable. \$\endgroup\$
    – Geier
    Nov 4, 2013 at 11:42
  • 1
    \$\begingroup\$ If more accuracy is needed than the scope's built in oscillator, consider using or calibrating to a GPS reciever with a 1 pulse per second output, which is more accurate than most oscillators. \$\endgroup\$
    – Justin
    Nov 4, 2013 at 15:26
7
\$\begingroup\$

The probe will disturb the measurement, and might be why the circuit isn't oscillating. Microchip actually has an application note which explains a recommended method of confirming the frequency of the crystal oscillator. I comes with a special firmware which outputs the clock frequency (or a divided version of it depending on the chip.)

https://www.microchip.com/wwwAppNotes/AppNotes.aspx?appnote=en592059

As for your oscilloscope's precision, I would refer to any calibration documents that came with it. They should mention something about the timing precision.

\$\endgroup\$
4
\$\begingroup\$

You're correct that the capacitive loading from the probes can affect the crystal frequency and in your case it sounds like it may be stopping the oscillator altogether. Depending on the chip and what I/O lines you have available a better method is likely to be using a timer interrupt to toggle a GPIO line that you can measure that without affecting the oscillator.

Another advantage is that as long as you're careful to make sure that the timer is setup correctly you could toggle the I/O line after a longer period of time and compare to an external reference that will give better accuracy than a scope. But whether that's worthwhile depends on your accuracy requirements and how long you're prepared to spend trimming the oscillator.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.