Daqarta for DOS Contents
Unknown .-------. .---------. Sine In ----->| | | Average | | X |---->| Value |----> Amplitude Reference --->| | | x2 | Sine In `-------' `---------'
This is basically sound, but there is a slight complication: The sine product formula works for sine waves "in phase", which means that both waves must start from zero at the same time. The averaged product only tells us about the amplitude of a signal with that exact same alignment. If the signal starts a little earlier or later than the reference wave, even if its frequency is the same, the constant value will be reduced and likewise our measurement of the signal amplitude. If the signal is a cosine wave, the measured amplitude will be zero. Since in general the reference wave won't have any fixed phase alignment with the signal wave, this is a serious problem.
formula for the product of two cosine waves, which differs only in that the cos(A+B) term of the product is positive instead of negative. We can thus analyze the unknown signal via two pathways: One multiplies the signal by a reference sine wave as before, while the other multiplies by a reference cosine wave of the same frequency. Each path performs a separate averaging and doubling operation, so we get two separate outputs which are the sine and cosine components of the input amplitude. We can find the true amplitude or "magnitude" at each reference frequency by taking the vector sum of the sine and cosine components.
Signal .-----. .-------. In --o----------------->| | | Avg | | | X |--->| Value |---> Sine | .-------->| | | x2 | Value | |Sine `-----' `-------' | .-----^-----. | | Reference | | | Source | | `-----.-----' | |Cosine .-----. .-------. | `-------->| | | Avg | | | X |--->| Value |---> Cosine `----------------->| | | x2 | Value `-----' `-------'
This is the essence of an ordinary "continuous" Fourier Transform, which according to standard formulations would entail using an infinite number of reference frequencies and averaging for an infinite time at each one to get infinite frequency resolution of our unknown input. If we are in a hurry, however, we might settle for somewhat less resolution by using fewer frequencies and shorter averaging times.
formula, the multiplier will give a component with a difference frequency of 1 Hz under these conditions.
We know that a sinusoid averages to zero due to symmetry, so we must average over at least one full cycle to take advantage of this. (In fact, if we are not going to average over a really long interval, we should always make sure we at least have an integer number of cycles.) The take-home message here is that the averaging interval must always be at least as long as the reciprocal of the desired frequency resolution. (1 sec for 1 Hz resolution, 0.1 sec for 10 Hz resolution, etc.)
In our Virtual Source example, try setting AM Hz to 501 while Freq is still 500 Hz. The product will show the expected 1001 Hz sum frequency, but the 1 Hz difference frequency will cause it to slowly ride up and down. A short-term average might catch this at a peak or valley, and would thus not give the desired zero output.
Several types of measuring instruments use these continuous Fourier Transform methods, including Wave Analyzers (now nearly extinct), Swept Spectrum Analyzers (still used for radio frequencies), and Lock-In Amplifiers (used for high resolution and sensitivity at single frequencies). But for most spectral analysis work at frequencies under about 100 kHz, digital methods now dominate.
ADC). This takes samples of the input at regular intervals and gives a digital number proportional to the instantaneous voltage.
Here is an example of a sampled sine wave. Points above the horizontal line are positive numbers, while those below are negative:
o o o o o o o o o o o o o o o o o o o o -----o-----o-----o-----o-----o-----o-----o-----o o o o o o o o o o o o o o o o o o o o o
The time between samples is called the SAMPLE PERIOD, and the rate of sampling is called (surprise!) the SAMPLE RATE or SAMPLING FREQUENCY. No information is available about what the input does between samples, so we must make sure that we sample often enough to adequately represent its behavior.
o o o o ------------------------------------------------ o o o o
Clearly, this does not give a proper representation of the true signal amplitude, although in this case it does give the proper frequency. In fact, if the relative phase between the signal and the sampling were changed (by starting on another sample of the original, or at any other point on the wave), we could get any amplitude from the proper value down to zero. This signal is at exactly half the sampling rate, which is a special limit called the NYQUIST FREQUENCY. If we sample even more slowly, so that the signal is above the Nyquist frequency, we can get bizarre results. Here is the same 1 kHz signal sampled at 1.714 kHz (1/7 of the original 12 kHz rate):
o o o -----------------------------------o----------- o o o
The apparent frequency turns out to be "reflected" about the Nyquist frequency, in that it appears to be below the Nyquist by the same amount that it is actually above. In this case the Nyquist frequency is 1714 / 2 = 857 Hz, so the real signal is 1000 - 857 = 143 Hz above the Nyquist... but it looks like it is at 857 - 143 = 714 Hz. This phenomenon is called "aliasing", and the reflected frequency is a "alias".
In the real world, we typically set the sample rate at some reasonable value to handle the expected range of inputs, such that no input frequency component is more than half the sample rate.
You can demonstrate the effects of aliasing by setting the Virtual Source Wave to Sine and running its Freq up past the Nyquist limit. (Make sure that AM Hz and AM Pct are set to 0 after the prior experiment.) Since the waveform display will get rather crowded near the limit, Xpand the trace to better see the details. Try changing to Line0 points-only display mode to see just where the samples fall.
Hit the F-key to observe the spectrum display. Run the test Freq up and watch the spectral response line "bounce" off the right end of the (unexpanded) frequency display, then move down as you continue to raise the frequency. Eventually, the response frequency will go down to zero and bounce back in the proper direction, but the indicated frequency will be lower by the amount of the sampling frequency. The bouncing continues for ever-higher test frequencies.
It should be clear from the above that the sample rate should be set so that it is more than twice the highest component frequency of interest, to prevent desired components from aliasing to other frequencies.
But what about other components that we don't really care about? Unfortunately, they can alias down and clutter up or confuse the desired spectrum with extraneous peaks and background trash. If you can't avoid the presence of these components by a different design of your experiment, and if you can't raise the sample rate high enough to avoid problems with them, you may need to use an ANTI-ALIAS FILTER to remove them before they reach the ADC.
Anti-alias filters must be carefully chosen in order to avoid other problems with your data. A filter which sharply reduces frequencies above its "cutoff" will usually also cause phase shifts which can alter the appearance of the waveform, even if they don't affect the spectrum. Further, transient inputs may provoke waveform overshoot and ringing behavior.
Naturally, the types of filters that are least prone to these problems also don't have very sharp cutoffs unless they are made very complex. Here complexity is measured by filter "order", which is the number of tuned stages required.
For information about constructing your own filters, a good place to start is the Active Filter Cookbook by Don Lancaster. If you must use an anti-alias filter, be sure to check its effect on known test inputs before conducting any real experiments.
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
25 Years of Innovative Instrumentation
© Copyright 1999 - 2006 by Interstellar Research