Signal Sources and Frequency Counters
Most measurements need a stimulus: a sine to measure a filter, a pulse to test a trigger, a modulated carrier to test a receiver. And frequency, the quantity electronics can measure most accurately of all, needs a counter and a good timebase. This lesson looks inside the modern function and arbitrary waveform generator (direct digital synthesis), and inside the frequency counter, with the error terms of each. The front-panel basics of the generator and its output are in EE Foundations.
Direct digital synthesis
A DDS generator holds an -bit phase accumulator clocked at . Each clock it adds a tuning word ; the top bits of the phase address a sine table, and a DAC plus a reconstruction filter turn the codes into a voltage:
With bits and , the resolution is at any output frequency, and frequency changes are phase-continuous. The output is a sampled signal, so it has images at , , …, the same spectrum as any sampler (Data Acquisition). The reconstruction filter removes them; that is why a DDS generator's sine output is limited to roughly . Spurs come from truncating the phase to bits and from DAC non-linearity; datasheets give them as SFDR (spurious-free dynamic range) in dBc, alongside harmonic distortion, amplitude flatness and phase noise or jitter.
Square and pulse outputs often come from a comparator or a separate pulse generator, with specified rise time (a few ns), jitter and duty-cycle accuracy. Arbitrary waveform generators (AWGs) play a user-defined sample memory instead of the sine table, either by DDS (variable frequency, fixed memory) or "true arb" (each sample played once per period at a variable clock).
Simulation. A DDS output is a sampled sine. With and (a scaled-down clock), the lab's line spectrum shows the wanted line at and images at , and : all of them are present at the DAC output. A reconstruction filter must pass and remove . (The lab's own filter is an anti-alias filter in front of the sampler, so leave it off here.) Move to : the first image comes down to , too close for any practical filter, which is why DDS sine outputs stop near .
import numpy as np
# Direct digital synthesis: 32-bit phase accumulator, 125 MHz clock, 12-bit phase to amplitude (truncated)
f_clk, N_acc, P = 125e6, 32, 12
df = f_clk / 2**N_acc
f_target = 1.234567e6
M = round(f_target / df) # tuning word
print(f"resolution {1e3 * df:.2f} mHz, tuning word {M}, output {M * df:.4f} Hz")
n = np.arange(2**16, dtype=np.int64) # int64: the product M*n exceeds 32 bits
phase = (M * n) % 2**N_acc # exact integer phase accumulator
idx = phase >> (N_acc - P) # keep the top 12 bits for the sine table
y = np.round(2047 * np.sin(2 * np.pi * idx / 2**P)) # 12-bit DAC codes
Y = np.abs(np.fft.rfft(y * np.hanning(len(y))))
Y_db = 20 * np.log10(Y / Y.max())
f = np.fft.rfftfreq(len(y), 1 / f_clk)
k0 = np.argmax(Y)
mask = np.abs(np.arange(len(Y)) - k0) > 8 # everything except the carrier and its window skirt
print(f"carrier at {f[k0] / 1e6:.4f} MHz, largest spur {Y_db[mask].max():.1f} dBc at {f[mask][np.argmax(Y_db[mask])] / 1e6:.3f} MHz")
print(f"first image of the DAC output at f_clk - f = {(f_clk - M * df) / 1e6:.3f} MHz (removed by the reconstruction filter)")resolution 29.10 mHz, tuning word 42419399, output 1234566.9966 Hz
carrier at 1.2341 MHz, largest spur -68.4 dBc at 1.251 MHz
first image of the DAC output at f_clk - f = 123.765 MHz (removed by the reconstruction filter)
The largest spur of this ideal 12-bit design sits about below the carrier, close to the rule of thumb of per bit of phase kept ( for 12 bits).
Frequency counters
A direct counter opens a gate for (derived from its timebase) and counts input cycles. Because the gate is not synchronised to the input, the count is uncertain by :
which is terrible at low frequencies: on a signal with a gate. A reciprocal counter instead synchronises the gate to input edges, counts an exact number of input cycles and measures their total duration with a fast clock (or interpolators). Its resolution is set by the time resolution , independent of the input frequency:
Modern counters are reciprocal, resolve tens of picoseconds and quote "digits per second" (e.g. 12 digits/s).
Error terms of a frequency measurement:
- Timebase error: the counter's reference oscillator offset since calibration, ageing (ppm per year for a TCXO, parts in to per day for an OCXO), temperature drift. A relative timebase error is a relative frequency error, whatever the gate time.
- Resolution: as above.
- Trigger error: noise on a slowly slewing edge moves the trigger instant by ; it matters most for low-frequency sines and short gates.
A GPS-disciplined oscillator or a lab's distribution feeding the counter's external reference input removes the timebase term almost entirely; it is how traceability to the SI second reaches a bench (Calibration).
Worked example: a 10 MHz oscillator on a TCXO counter
Given: a reciprocal counter with resolution, gate, TCXO timebase: within after calibration, ageing per year (one year since calibration), temperature ; trigger error per edge.
Find: the resolution and the uncertainty of a reading.
Solve: resolution , i.e. . The timebase limits sum to ; as independent limits, their root-sum-square is
Check: the display shows steps, but the reading is uncertain by about : some 150 times the resolution. Only an external reference makes the extra digits meaningful.
# Frequency counter resolution for a 1 s gate: direct counting vs reciprocal counting
f_clk = 100e6 # reciprocal counter's time-interval clock (10 ns resolution)
T_gate = 1.0
print(f"{'f':>8s} {'direct: +/-1 count':>20s} {'reciprocal':>12s}")
for f, label in ((10.0, "10 Hz"), (1e3, "1 kHz"), (1e6, "1 MHz"), (100e6, "100 MHz")):
direct = 1 / (f * T_gate) # one count in f*T_gate
recip = (1 / f_clk) / T_gate # one clock period in the measured interval
print(f"{label:>8s} {direct:20.1e} {recip:12.1e}")
# Error budget of a 10 MHz measurement with a TCXO timebase, 1 s gate, reciprocal counter
f = 10e6
tb_cal = 0.5e-6 # timebase offset limit since calibration (relative)
tb_aging = 1e-6 # aging per year (relative), one year since calibration
tb_temp = 1e-6 # temperature limit over the room range (relative)
res = 1e-8 # resolution, from the table
trig = 1e-9 # trigger error: 1 ns noise-induced timing error per edge on a 1 s gate
total = (tb_cal**2 + tb_aging**2 + tb_temp**2 + res**2 + (2**0.5 * trig)**2) ** 0.5
print(f"10 MHz reading: timebase limits summed {(tb_cal + tb_aging + tb_temp) * f:.1f} Hz, "
f"root-sum-square of the limits {total * f:.1f} Hz ({total * 1e6:.2f} ppm)") f direct: +/-1 count reciprocal
10 Hz 1.0e-01 1.0e-08
1 kHz 1.0e-03 1.0e-08
1 MHz 1.0e-06 1.0e-08
100 MHz 1.0e-08 1.0e-08
10 MHz reading: timebase limits summed 25.0 Hz, root-sum-square of the limits 15.0 Hz (1.50 ppm)
Guided lab: generator against counter
Hand calculation. A generator with a timebase set to should read within plus the counter's own timebase error.
Simulation. Change f_target and N_acc in the DDS program and see the resolution and actual frequency; change the gate time in the counter program.
What you would measure. Set a generator to , sine, and read it with a counter (or a scope's frequency counter function) at , and gates. Expect a fixed offset of a few hertz (the two timebases disagree) and scatter that shrinks with gate time. If both instruments have a reference connector, link the generator's reference output to the counter's input: the offset should collapse to the resolution. Then measure a sine of small amplitude: the reading scatters more, because the slow edge makes the trigger error large; a square wave or more amplitude fixes it.
Hazards and safe setup. Signal levels only; terminate outputs properly.
Pitfalls
- Treating displayed digits as accuracy: the timebase decides.
- Measuring low frequencies with a direct-counting instrument and a short gate.
- Ignoring DDS images and spurs when testing a wideband or mixing circuit (they are real signals at the output).
- Using a sine with a slow edge and noise at a counter input: trigger error.
Practice
- A 28-bit DDS runs at . What is its frequency resolution, and what tuning word gives ?
- A direct counter with a gate reads a signal. What is its resolution?
Answer
- ; (giving ).
- count in 5 counts: (20 %). Use a reciprocal counter or a period measurement.
Test yourself
The frequency resolution of a DDS is
- the DAC's LSB
Why does a DDS output need a reconstruction filter?
- to remove the DC offset
- to remove images at
- to increase the amplitude
- to reduce jitter only
A reciprocal counter's resolution depends mainly on
- the input frequency
- its time resolution and the gate time
- the input amplitude
- the display
The dominant uncertainty of a frequency reading on a counter with an internal TCXO is usually
- the one-count resolution
- the timebase error
- the trigger level
- the display rounding