# Computing stuff tied to the physical world

## Pick a frequency – any frequency

In Hardware on Mar 19, 2012 at 00:01

A week ago, there was a post about various clock options and their accuracy.

These clocks generate a stable pulse or sinewave, basically. But what if you need a different frequency?

Suppose you get a very accurate 1 pulse-per-second (i.e. 1 Hz) signal from somewhere, but you want to keep track of time in microseconds? IOW, you need a 1 MHz clock, preferably just as accurate. One way to do this, is to use a “Voltage Controlled Oscillator” (VCO). It can be any frequency really – the idea is to divide its output down to 1 Hz and then compare it with your reference clock. If it’s either too slow or too fast, adjust the voltage used to set the precise frequency of the VCO, and bingo – within no time (heh, so to speak), your VCO will be “locked” onto the reference and generate its target frequency, at just about the same accuracy as the 1 pps reference.

My Rubidium clock came with a 63.8976 MHz VCO as part of the bargain:

With no control voltage it generates a sinewave-ish very high frequency signal from just a 3.3V power supply:

That frequency is not as awkward as it looks: 638976 = 3 * 13 * 16384, so you can get 100 Hz out of it with a few simple dividers, as well as any integral fraction of that (including 1 Hz). Another way of going about this is to divide the clock by a simple power of two, say 256 or 4096, and then pass the resulting square wave to an ATmega’s timer/counter input. I haven’t hooked up this VCO to the Rb clock yet, since there’s a bit more logic involved – look up “phase locked loop” (PLL) if you’re interested.

Another source of very stable clock signals is the GPS navigation system (see also this note). Their clocks are used to be made a little bit jittery for civilian use, but this averages out over time, so you can still lock onto it and get a very accurate long-term reference. Look up Allen variance to find out more about short- vs long-term stability – it’s fascinating stuff, but as with most things: once you get into the details it can become quite complex.

To summarize: with a VCO you can produce any frequency you like given some stable reference. So I’m happy with my 10 MHz @ 10 ppt atomic clock, for those rare cases when I’ll need it. And for its geek factor, of course…

Do all these extreme accuracies matter? Well, apart from TDMA, think of it this way: an 868 MHz RFM12B wireless radio with 1 ppm accuracy may be off by 868 Hz. That’s no big deal because the RFM12B’s receiver uses Automatic Frequency Control (AFC) to tune itself into the incoming signal, but with bandwidths in the kilohertz range, you can see that all of a sudden a couple of ppm isn’t so academic any more!

1. 2^16 * 3 * 5^2 * 13 still seems like an odd factor chain to me. I’ve done a reasonable amount of research as to why I got one of these with my Rb reference as well, but couldn’t come up with anything. Is it possible someone more familiar with the cell phone specs could justify these odd prime factors?

2. I believe that civillian GPS signals are no longer subject to external jitter. This program, called “selective availability”, was discontinued in the 90s:

• Ah, yes – I’ve updated the post, thank you.

3. Why that exact frequency? “The digitizing rate of the A-D converter 41 preferably set for this example to 63.8976 MHz is carefully selected, as described in detail below, to eliminate the need for additional expensive and complex signal filtering and shielding that would otherwise be required in the RX channelizer banks 7, 8, 9 for simultaneously processing the digitized signal received by the A-D converter 41 at the common digitizing rate based on their respective CDMA, TDMA and GSM requirements.” …from U.S. Patent 6282184 “Common digitizing rate for multiple air interfaces for generic cell sites in cellular radio” http://www.ptodirect.com/Results/Patents?query=PN/6282184

• Wow – so that VCO could be the first step towards a DIY cell tower ;)