I speculate here about building a spectrum analyzer. These ideas are mathematical and backed up with code. There are substantial hardware issues of which I am ignorant.
I presume that a sample set is taken at some time, chosen by the user. A sample set a set of 2n samples equally spaced in time taken on command of the user. A sample is a pair of b bit numbers supplied by a heterodyne circuit with the ambient electric field as its input. The intermediate frequency of the heterodyne circuit is f. I consider here only ‘quadrature heterodyne’.
The idea is to display magnitudes of the Fourier transform of a sample set annotated by frequency perhaps exactly like a commercial spectrum analyzer.
This code detects a signal hidden in noise. The signal to noise ratio is 0.01. There are 220 samples and so this is like looking for a kHz channel in a GHz band. Here are a few code comments. Here is a variant with 217 samples. It can find a signal but only with a SNR = 0.02. This variation clips heterodyne yields to 5 bits and hardly suffers thereby.
The files fft.c, rnd.c and misc.c and their respective header files are required auxiliaries. The file bb builds the auxiliary .o files and then b builds the running program.
In this section I may be over simplifying or idealizing.
A heterodyne circuit has a stable oscillator producing a frequency f near the center of the band of interest.
It produces the signal ei2πft = cos(2πft) + i sin(2πft).
I assume here that both parts are really produced.
The output of the heterodyne circuit is also analog and is the complex number:
h(t) = ∫u=0∞e−2nu/de2π if(t−u)s(t−u)du
where s(t) is the real signal from the antenna. The output of the heterodyne circuit is h(t), a complex function of t, which is digitally sampled every d2−n seconds. The factor (e−2nu/d), as a function of u, is real and nearly zero outside the sample interval. Other shapes are fine if they are nearly zero outside the sample interval. (e−2nu/d) is merely my guess about real heterodyne circuits. Its shape hardly enters into subsequent considerations. I recall a mathematical note on ‘over sampling’ that concluded that fidelity to the amplitude of high frequencies benefitted by over sampling. The same is probably true here too. That would argue for replacing (e−2nu/d) by (0 < u && u < 2−n/d) in C speak.
Schematic diagrams of heterodyne circuits seldom show the output as other than a single analog signal. I assume quadrature heterodyne here for that keeps alias frequencies from interfering and confusing things. Googling ‘quadrature heterodyne’ leads to a few papers that indicate that this is done when extra precision is needed and other hacks fail.
See thoughts on a ‘digital quadrature heterodyne’.