On Mon, 3 Apr 2000, Tom Handley wrote: > Scott, thanks for the excellent insight. I have a PIC-based DAQ project > as well as an `on-going' Logic Analyzer/DSO project. I've been very > interested in this subject as I will want to implement FFTs and a spectrum > analyzer amongst other things. I'm working from two old books; "The Fourier > Transform and it's Applications" 2nd edition, Ronald Bracewell. And; > "Digital Signal Processing", Alan Oppenheim / Ronald Schafer. > > I would like to get your thoughts on a general purpose spectrum analyzer > where the frequency can vary from a few Hz to 40MHz. I can do it via the > `brute strength and ignorance' method using classic math. Note, my hardware > includes frequency synthesis/stimulus. The hardware is based on a PIC16F877 > with a custom CPLD that interfaces to a 512K NVSRAM (Dallas DS1647) with a > RTCC and Lithium Battery. The CPLD provides the SRAM interface as well as > external chip selects and 8 dedicated SPI bus chip selects. > > I should mention that post processing will be done on a PC though I have > some potential applications such as low frequency vibration analysis on > machinery, using an accelerometer, where your comments apply directly to the > problem. In this case, the math would be implemented in a PIC. Thanks, > Tom, I know hardly anything about how spectrum analyzers are designed. I'm sure there are others here to provide better suggestions. But, I can offer a few. First, one important feature of spectrum analyzers is their huge dynamic range. It's important in some cases to see frequencies 100dB down or more (relative to some other signal). This is hard to achieve! I'd go as far as saying that for a pure digitizing system it's impossible with today's technology. Why? Well a 16-bit A/D converter can provide only 96dB of dynamic range and these are generally limited to a few 100khz at best. I suspect that this is the approach taken by SRS in their low frequency spectrum analyzers (which are limited to about 120khz). The high frequency spectrum analyzers use a very low noise sweeping oscillator to down-convert the signal to a lower frequency. You mention synthesis; is this what you're talking about? Once the signal has been down converted, you can then use a low pass filter and digital signal processing techniques to analyze it further. If you really need a few Hz to 40MHz, then I'd probably try to design a really low noise programmable (analog) oscillator and a low noise down converter. The output of this would drive a low pass filter whose attenuation is on the order of the dynamic range you seek (e.g. if you want 80db then at least a 4th-order analog filter would be required - a 5th-order filer is just an R and a C more expensive than a 4th-order one). The cutoff frequency of the analog filter can more or less be arbitrary, but I'd suggest something below 60Hz just to be safe. The output of this filter can drive an amplifier and an A/D converter. If you made the low pass filter with a higher cutoff (say 1khz) then you could use digital filters to resolve finer frequencies. In other words, you could combine the best of both worlds (big caveat below) As an example on how the sweeping oscillator thing works, recall the trig identity: sin(x)sin(y) = [cos(x-y) - cos(x+y)]/2 If your programmable clock can be represented as: f(t) = A*sin(w1*t+phi1) and the signal you wish to spectrally examine: g(t) = B*sin(w2*t+phi2) then the product f(t)*g(t) = A*B*cos( (w1-w2)t + phi1-phi2) - A*B*cos( (w1+w2)t + phi1+phi2) The first cosine term is the difference between your clock and the signal that you're examining. If these two are about the same frequency, then the difference is close to zero, but their sum is large. If you passed this product through a low pass filter that had a cutoff greater than w1-w2, then you would be able to examine g(t). Now if you abstract g(t) to an arbitrary wave, then you'll still be able to extract the small frequency bin centered at your clock and with a width of twice your low pass filter. But you do have to be careful (as always). Suppose that the unknown signal contains two frequencies equally spaced from your clock (e.g w1 + delta1 and w1 - delta1). These two would get aliased onto one another: g(t) = B*sin( (w1+delta)t + phi2a) + C*sin( (w1-delta)t + phi2b) f(t)*g(t) = A*B*cos( (-delta)t + phi1-phi2a) - A*B*cos( (2*w1-delta)t + phi1+phi2a) + A*C*cos( (delta)t + phi1-phi2b) - A*C*cos( (2*w1-delta)t + phi1-phi2b) and after the carrier get's knocked out by the low pass filter you're left with: f(t)*g(t) = A*B*cos( (-delta)t + phi1-phi2a) - A*C*cos( (delta)t + phi1-phi2b) - The frequency -delta and delta will generate identical cosine waves. So how do you differentiate these? Well, maybe this is where our HAM guys can jump in. Certainly if you made the low pass filter very narrow then you could resolve them. Now if you step back and look at this from a practical point of view, it's going to be very difficult to design a high frequency clock with very low jitter. Consequently, the spectrum analyzer's frequency resolution is a strong function of the stability of the sweeping oscillator. But as far as devising a modulation technique to single out only one of these frequencies, I don't have an answer. There is one observation to be made, however. Suppose we return to analyzing a single frequency again. As the oscillator sweeps pass this frequency the demodulated version of the signal will be converted to a sine wave with a low frequency. Let's say that the low pass filter has a cutoff of 1kHz. If we looked at the demodulated signal after the low pass filter and let the oscillator sweep from low to high frequencies then this is what we'd see: First the sine wave would appear at 1kHz. Then as the oscillator increases in frequency, the demodulated sine wave would decrease. When the oscillator and the sine wave are the same frequency then we'd get DC. And finally, as the oscillator passes the sine wave's frequency, then the demodulated version would begin to increase again. Perhaps this observation can be put to use? Scott