---
title: Measuring frequency and time
heading: Counters, time bases and jitter
eyebrow: C11 · Lesson 11 · Measuring frequency and time
xp: 40
---

::: hook
Frequency is the quantity measured most precisely of all: a good lab counter reads ten or eleven digits in a second, and the SI second itself is defined by counting cycles of a cesium atom. How many of those digits mean anything depends on how the counter counts, on the accuracy of its own clock, and on how much the signal's edges wander from cycle to cycle.
:::

::: play
- The curves are the relative resolution of two ways of counting, against the signal's frequency, for a gate time T.
- **Direct counting** counts input cycles for T: an uncertainty of ±1 count, so a resolution of $1/(fT)$, poor at low frequencies.
- **Reciprocal counting** times a whole number of input periods with a fast reference clock $f_\text{clk}$: ±1 count of the clock, about $1/(f_\text{clk}T)$, the same at every frequency. Below $f_\text{clk}$ it always wins.
:::

```sim plot
view: graph
x: f = 1..1e9 Hz log
y: r = 1e-12..1 log
slider: T = 0.01..10 step 0.01 = 1 s
slider: c = 10..1000 step 10 = 100 MHz
plot: 1/(f*T) | label: direct counting
plot: 1/(c*1e6*T) + 0*f | dashed | label: reciprocal counting
readout: reciprocal resolution, digits = log(c*1e6*T) | digits: 3
```

::: predict
## A counter with a 1 s gate counts a 1 kHz signal directly. What is its resolution?

- [ ] 1 mHz
- [x] 1 Hz, 0.1%
- [ ] 1 kHz
- [ ] 1 ppb

::: reveal
1 Hz: it counts 1000 or 1001 cycles, so ±1 count is 0.1%. A reciprocal counter with a 100 MHz clock times the same second to ±10 ns, a resolution of $10^{-8}$, 0.01 mHz at 1 kHz. That's why every modern counter is reciprocal.
:::
:::

::: nameit
## Counting

- **Direct**: count edges during a gate of length T; $f = N/T$, resolution $\pm 1/T$ in hertz.
- **Reciprocal**: count a whole number of input periods while also counting a reference clock; the frequency is the ratio. The ±1 count falls on the fast clock, so the relative resolution is about $1/(f_\text{clk}T)$. Interpolators that time the edges inside one clock period improve it further.

## The time base

Every counter compares with its own oscillator, and the reading can't be more accurate than it. A crystal with ±1 ppm accuracy makes a 10 MHz reading uncertain by ±10 Hz, however many digits are shown. Better references: a temperature-compensated crystal (about 0.1 to 1 ppm), an oven-controlled crystal (about 0.01 ppm), a GPS-disciplined oscillator, or a rubidium standard.

## Jitter

**Jitter** is the wandering of edges from their ideal times, quoted as rms (random) or peak-to-peak. It limits how precisely a single period can be measured, and averaging over N periods reduces random jitter's effect by $\sqrt N$. When a clock samples a signal, jitter turns into noise: sampling a sine of frequency f with rms jitter $\sigma_t$ limits the SNR to

$$\text{SNR} = -20\log_{10}(2\pi f\sigma_t)\text{ dB}$$

## Stability

Accuracy (how far from the true value) differs from stability (how much it changes over time). An oscillator's short-term stability is described by its **Allan deviation**, the typical change in fractional frequency between successive averages of length τ.
:::

::: example
## A reciprocal counter with a 100 MHz clock and a 1 s gate measures a 10 MHz signal, using a ±1 ppm time base. What limits the result?

::: solution
1. **Resolution.** It is about
   $$\frac{1}{10^8 \times 1} = 10^{-8}$$
   That's 0.1 Hz at 10 MHz.
2. **Time base.**
   $$10^{-6} \times 10\ \text{MHz} = 10\ \text{Hz}$$
   so ±1 ppm is ±10 Hz.
3. **Compare.** The time base is a hundred times worse, so the ninth digit the display shows is meaningless unless the counter is locked to a better reference.

**Answer:** the ±1 ppm time base limits it to ±10 Hz, a hundred times the 0.1 Hz resolution.
:::
:::

::: example
## A clock with 1 ps rms jitter samples a 100 MHz sine. What SNR does the jitter allow, and what about 0.5 ps?

::: solution
1. **SNR at 1 ps.** With f = 100 MHz and $\sigma_t$ = 1 ps, $f\sigma_t = 10^{-4}$:
   $$\begin{aligned} \text{SNR} &= -20\log_{10}(2\pi f\sigma_t) \\ &= -20\log_{10}(2\pi \times 10^{-4}) \\ &= 64.0\ \text{dB} \end{aligned}$$
2. **Effective bits.** That's about 10.3 effective bits, whatever the converter's resolution:
   $$\frac{64.0 - 1.76}{6.02} = 10.3$$
3. **At 0.5 ps.**
   $$\text{SNR} = 70.1\ \text{dB}$$
4. **What limits fast converters.** High-speed ADCs are often limited by their clock rather than their quantizer.

**Answer:** 64.0 dB at 1 ps (about 10.3 effective bits), and 70.1 dB at 0.5 ps.
:::
:::

::: example
## A period is measured with 50 ps rms jitter. How many periods must be averaged to know the mean period to 1 ps?

::: solution
1. **Averaging N periods.** It reduces random jitter's effect by $\sqrt N$:
   $$\frac{50\ \text{ps}}{\sqrt N} = 1\ \text{ps}$$
2. **Solve for N.**
   $$\begin{aligned} N &= 50^2 \\ &= 2500 \end{aligned}$$
3. **One long interval.** Measuring 2500 periods at once (a single interval) does the same, because the jitter at only the two end edges matters, divided over 2500 periods.

**Answer:** 2500 periods.
:::
:::

::: check
kind: parts
given: f = 10 | 1000 | 1e6; T = 0.1 | 1 | 10

## A {f} Hz signal is counted directly with a {T} s gate.

::: part
answer: 1/T
unit: Hz
tolerance: 0.5%

### What is the resolution?

::: misses
- [any] ±1 count over T.
:::
:::

::: part
answer: 1/(f*T)*1e6
unit: ppm
tolerance: 0.5%

### What is that relative to the frequency?

::: misses
- [any] $1/(fT)$.
:::
:::
:::

::: check
kind: parts
given: c = 100 | 500; T = 0.1 | 1; f = 1 | 10 | 100

## A reciprocal counter with a {c} MHz clock and a {T} s gate measures {f} MHz.

::: part
answer: 1/(c*1e6*T)*f*1e6
unit: Hz
tolerance: 0.5%

### About what is its resolution?

::: misses
- [any] Relative resolution $1/(f_\text{clk}T)$, times f.
:::
:::

::: part
answer: f*T*1e6
tolerance: 0.5%

### How many input periods does it time?

::: misses
- [any] f × T.
:::
:::
:::

::: check
kind: parts
given: a = 0.01 | 0.5 | 2; f = 10 | 100 | 1000

## A counter's time base is accurate to ±{a} ppm, and it measures {f} MHz.

::: part
answer: a*f
unit: Hz
tolerance: 0.5%

### What uncertainty does the time base add?

::: misses
- [any] ppm × MHz gives hertz.
:::
:::

::: part
answer: a*f*10
unit: Hz
tolerance: 0.5%

### What would it add at ten times the frequency?

::: misses
- [any] A fractional error scales with the frequency.
:::
:::
:::

::: check
kind: parts
given: f = 10 | 100 | 1000; j = 0.1 | 1 | 5

## A clock with {j} ps rms jitter samples a {f} MHz sine.

::: part
answer: -20*log(2*pi*f*1e6*j*1e-12)
unit: dB
tolerance: 0.5%

### What SNR does the jitter allow?

::: misses
- [any] $-20\log_{10}(2\pi f\sigma_t)$.
:::
:::

::: part
answer: (-20*log(2*pi*f*1e6*j*1e-12) - 1.76)/6.02
tolerance: 0.5%

### How many effective bits is that?

::: misses
- [any] $(\text{SNR} - 1.76)/6.02$.
:::
:::
:::

::: check
kind: parts
given: s = 10 | 50 | 200; t = 1 | 5

## Single periods have {s} ps rms jitter; the mean period is needed to {t} ps.

::: part
answer: ceil((s/t)^2 - 0.000001)
tolerance: 0

### How many periods must be averaged?

::: misses
- [ceil(s/t)] The error falls as $1/\sqrt N$.
- [any] $(s/t)^2$.
:::
:::

::: part
answer: s/sqrt(ceil((s/t)^2 - 0.000001))
unit: ps
tolerance: 0.5%

### What uncertainty does that give?

::: misses
- [any] $s/\sqrt N$.
:::
:::
:::

::: check
kind: derivation
vars: f = 1..1e9, T = 0.001..100, c = 1e6..1e10

## A signal of frequency f is measured over a gate T, either by counting its cycles or by timing its periods with a clock of frequency c.

::: step
answer: 1/(f*T)

### What is direct counting's relative resolution?
:::

::: step
answer: 1/(c*T)

### What is reciprocal counting's?
:::

::: step
answer: c

### Below what signal frequency does reciprocal counting win?
:::

::: right
Right. A counter with a fast enough clock counts reciprocally at every frequency it measures.
:::
:::

::: explain
## Why can a counter display more digits than its time base can support, and what does that mean for a reading?

::: model
A counter's display shows its resolution: how finely it can distinguish one count from the next, set by the gate time and the clock rate. Its accuracy is a different limit, set by how far its reference oscillator is from the true frequency, because every reading is really a ratio against that oscillator. A ±1 ppm crystal makes every reading uncertain by one part in a million, so on a 10 MHz signal any digits below about 10 Hz are resolved but not accurate: they're useful for seeing small changes in the signal, but not for its absolute value unless the counter is locked to a better reference.
:::
:::

::: practice
::: check
given: f = 100 | 50000; T = 1 | 10
answer: 1/(f*T)*1e6
unit: ppm
tolerance: 0.5%

## Direct-count resolution for {f} Hz with a {T} s gate?

::: misses
- [any] $1/(fT)$.
:::
:::

::: check
given: a = 0.1 | 1; f = 25 | 433
answer: a*f
unit: Hz
tolerance: 0.5%

## Time-base uncertainty at {f} MHz with ±{a} ppm?

::: misses
- [any] ppm × MHz.
:::
:::

::: check
given: f = 50 | 250; j = 0.2 | 2
answer: -20*log(2*pi*f*1e6*j*1e-12)
unit: dB
tolerance: 0.5%

## Jitter-limited SNR at {f} MHz with {j} ps rms?

::: misses
- [any] $-20\log_{10}(2\pi f\sigma_t)$.
:::
:::
:::
