Data AcQuisition And Real-Time AnalysisScope - Spectrum - Spectrogram - Signal Generator
Software for Windows
Science with your Sound Card!
Contact us about
Discrete Sine and Cosine References
Imagine a big circular table holding sine values for all angles around a full circle, as though we had replaced the numerals and tick-marks on a round clock face with the sine of the angle of the second hand at each position. If we then step through this table and read each value in order, we will generate a sine wave. (See Sine Wave Basics.)
Since the table is circular, after we read the last value we proceed to wrap around and read the first again, and so on to generate a continuous wave. We can use the same table to generate a cosine wave just by starting at the 90 degree position and proceeding around as before.
The frequency of the generated wave depends upon how many complete cycles we step around per second. But we don't actually need to do this in "real" time, with actual seconds, since we can have a copy of the sampled input signal in memory somewhere. We can use this copy over and over for each different reference frequency, for both sine and cosine waves, and perform the necessary multiplications and averages as fast as we can. We only need to insure that each input sample is multiplied by the same value as would happen in real time. We can thus take a single set of samples and multiply it by many different frequencies "at once", or at least "pretty darn quick", before the next set of input samples.
Suppose we have collected 1024 samples of our signal, and further suppose our sine table divides the whole circle into the same number of steps. If we multiply each sine value from the table with each signal value in order, we will in effect be multiplying by a frequency that is one cycle per 1024 samples, or 1/1024 of the sample rate that was used to acquire the signal.
To multiply by other frequencies, we can just move around the sine table with bigger steps. For example, to get 2/1024 of the sample frequency, we skip every other step in the table. Of course, we will need to make two circuits of the table while we work through our set of 1024 signal data samples. For 3/1024 of the sample rate, we take every 3rd table value and make 3 circuits per 1024 samples, and so on up through 511/1024. We don't need to bother with 512/1024 of the sample rate, since that would be the Nyquist frequency and we already know we can't believe what we get with that!
We also need to average the results of our multiplications. For each frequency, we will have 1024 multiplications as we work through the input sample set, so we just add each of these products into one total, then divide by 1024 to get the average value for that frequency. We need to do this separately for sine and cosine waves at each frequency.
We can also determine the 0 frequency (DC) component of the signal just by averaging all the input samples. This is the same as if the reference waves were generated by taking 0 steps per sample: All the sine values would stay at the initial value of 0, so we can ignore them. All the cosine values would stay at 1, so we can skip the multiplication by them and just average the input samples directly.
See also Spectrum (Fourier Transform) Theory
Questions? Comments? Contact us!We respond to ALL inquiries, typically within 24 hrs.
Over 30 Years of Innovative Instrumentation
© Copyright 2007 - 2020 by Interstellar Research
All rights reserved