1
\$\begingroup\$

I am designing a small testing unit to automate production testing for my company's main boards. One of the tests to be done is to verify that an 8MHz external crystal oscillator for a PIC MCU is running. Is there a recommended way to do this in a cheap and reliable way?

My thinking at the moment is to sample above 16 Msps (Nyquist frequency = 8MHz x 2 = 16MHz). This would give me enough information to reconstruct the wave and determine the frequency. The problems I see with this is the ADC I am currently using is only 500ksps. I would need to alot extra cost for a higher performance ADC as well as board space for an anti-aliasing filter to get rid of any higher harmonics that might be picked up. This solution feels bulky just for testing if a sine wave is present or not. Any suggestion appreciated.

\$\endgroup\$
12
  • 2
    \$\begingroup\$ If it runs, the PIC will too, and if it does not run, the PIC won't either. Can you use that as a signal if it works or not, by for example dividing the clock down to 1 kHz inside the PIC? \$\endgroup\$
    – Justme
    Jul 25, 2020 at 5:55
  • \$\begingroup\$ I may not have access to the firmware in the PIC as it was developed by a third party contractor. At the least, there would be a wait before they could provide a firmware update to support a test like this. \$\endgroup\$
    – jholdaw2
    Jul 25, 2020 at 5:57
  • 2
    \$\begingroup\$ That's bad, you depend on the contractor for every little change in the software on your important product. Well, you can always write your own test firmware and load it during board testing, then finally program the normal binary. \$\endgroup\$
    – Justme
    Jul 25, 2020 at 6:23
  • \$\begingroup\$ When you say 8MHz external crystal oscillator, are the only external parts a crystal and two capacitors ? i.e., PIC provides the internal amplifier to sustain the oscillations ? Or is it a full fledged stand alone external oscillator ? \$\endgroup\$
    – AJN
    Jul 25, 2020 at 6:34
  • \$\begingroup\$ Yea, it is not a good situation. We are working towards transitioning future design to our own engineers so we have full access. I may look into programming test firmware as you suggested. Thanks \$\endgroup\$
    – jholdaw2
    Jul 25, 2020 at 6:38

5 Answers 5

1
\$\begingroup\$

Since you have an external crystal, not an external crystal oscillator, it is extremely sensitive for connecting any measurement equipment to it. External crystal oscillator outputs logic level square wave and it would be much easier to measure.

The frequency is too high to measure with your DAQ directly, it would be necessary to write a test program to PIC that outputs a divided down logic level signal based on the crystal frequency.

It still would not tell how good the crystal circuitry is. It might still be barely oscillating or have startup issues due to some manufacturing error like missing or wrong parts in the crystal circuitry.

\$\endgroup\$
1
\$\begingroup\$

If you want to see whether the PIC oscillator runs with the crystal, then turn it on and see whether it runs.

Design is the time to be doing margin testing, to see whether a spread of crystals and a spread of PICs at a spread of voltages all start up and run reliably, not production. By production, you've established a crystal supplier and a PIC supplier that you know can be soldered together onto the board and work.

If you're still in late development / early production, and you're doing the margin tests, then it's not really something that's possible to automate. You put a range of capacitors onto the board, you run the voltage up and down, you use high impedance probes and an oscilloscope to measure the oscillation amplitude, and a counter for the frequency.

If the frequency is critical for the application, then it's worth checking the frequency. The two main ways to do that are with a bench counter, or using test firmware in the PIC to read an external standard frequency with its internal counter peripherals

\$\endgroup\$
1
  • \$\begingroup\$ Spot on, it can be as simple as a functional test program to verify the functionality of the pic, and if needed it can include a frequency counter routine to verify the clock frequency . \$\endgroup\$
    – crasic
    Jul 25, 2020 at 22:36
0
\$\begingroup\$

You probably should verify the actual frequency as well as the presence of the oscillator, at least approximately, in order to detect the situation where, say, a 4MHz or 10MHz crystal (or external oscillator) is populated.

In general to do that you can use an adequately sensitive input circuit that it doesn’t unduly affect the oscillator output node, and a frequency counter circuit. That could be a Keysight or whatever rack-mount unit with LXI or GPIB communications or you could build something with a PIC, Arduino or whatever and supply the frequency measurement over a serial link to whatever you are using to automate the testing. At 8MHz you don’t need a very long gate time to get more resolution than you likely need.

There are various open-source designs that you can use as a base rather than starting from scratch. Replacing the (usually crude) input circuit with a boutique-y fast CMOS comparator with self-biasing RC on one input would minimize loading.

\$\endgroup\$
0
\$\begingroup\$

Your best approach for determining the frequency is to use the earlier suggestion of having some software on the MCU produce a low frequency output and measure that with a (calibrated) frequency counter.

However, your most likely issue is the magnitude of the oscillation -- this is determined by the quality of the crystal and the parasitics and components around it. Connecting a probe directly to it WILL affect the frequency (during the measurement by perhaps 0.1 %), and will also affect the amplitude. However, connecting a probe via a small capacitor (e.g. 1 pF) will (after calibration) allow you to determine, or at least compare the amplitudes between different units and detect abnormal ones.

Note that if you are trying to measure the amplitude of the 8 MHz, you might be able to use an ADC with a slower sampling frequency -- as long as its input filter allows 8 MHz in, and its aperture allows 8 MHz to be sampled. Basically, you can aliases the sampling rate and oscillation. Choose a sampling rate that is not an integer submultiple of the 8 MHz -- you will get an output that is a subsampled version of the original signal, just at a different frequency.

e.g. if the XTAL is at 8 MHz and you sample at 300 kHz, you will be subsampling at 8M/300k = 26.667x; the integer cycles are skipped, and you will have an apparent signal of 0.667*300k = 200 kHz.

\$\endgroup\$
0
\$\begingroup\$

Depending on the application of your crystal, if its connected to a microcontroller with configurable clocks, you might be able to divide the clock with the MCU with a large divisor and then have it toggle a testpoint-gpio. Say divide by 128, you get a 62.5KHz signal that would be pretty easy to measure with almost any ADC/frequency counter during factory testing.

We did this to a batch of ~6k devices after SMT, because half of the crystals that were already soldered were cut with wrong capacitance (though only very few actually failed QC).

\$\endgroup\$

Your Answer

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

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