|
Visual Basic sample program for Discrete Fourier Transform |
|
|
|
 Fourier Transformation is used to transform data in time domain to frequency domain and vice versa. The forward fourier transform or simply fourier transform is used for time domain to frequency domain transformation. Where as Inverse fourier transform is used for reverse process. Here you can find a visual basic sample program implementing fourier transform using correlation method.
Fourier transform techniques, transform data between time and frequency domains. To transform a time domain signal to a frequency domain signal , fourier transform is used. Inverse fourier transform transforms frequency domain signal to time domain signal. Discrete fourier transform is used in Digital signal processing applications since it is the only transform that can be computed using a computer. Though the fourier techniques are comparatively easy from the mathematical perspective, it can not be used for computer based calculations. The role of fourier transform is to find the frequency components present in the input signal and the relative magnitude of each component. One of the popular method to find DFT is by using correlation. In this method, the input signal is correlated with basis functions (sin waves and cos waves) of required frequency. When we correlate the input with a basis function of certain frequency, we get a single value that represents the presence of that frequency in the input signal. To obtain the frequency spectrum , it is necessary to correlate the input signal with basis functions from DC to half the sampling rate.
How to use the sample program
The .zip file contains both source code and executable. To compile and run the source code you need to have Visual Basic 6.0 installed in your computer. To run the executable, you must download and install Visual Basic 6.0 runtime files. Run dft.exe and you will see the main window. In the main window , the top most part is the Function generator , which produces different waveforms to test the process. We can interactively change the amplitude, frequency and shape of the generated signal.
To test the program we must first generate an appropriate waveform. Here we will generate a complex waveform which consists of two different frequencies. Leave everything in default settings and click "generate" button. Now you can see a 10 Hz signal in the graph next to the signal generator. Figure below shows the waveform.
Now change the Frequency to 100 Hz and click "generate" button again. The newly generated waveform is added to the existing waveform and resulting waveform looks like a 10Hz sin wave with 100 Hz noise. See the waveform below.
This waveform contains two different frequencies. Select one of the windowing functions and display format( defaults will do for this experiment) and click "Transform button". The frequency spectrum in the selected mode will be displayed on the output graph. Once transform is completed , you can select any of the output display modes and click "display" button to display frequency domain data in that format. The figure below shows the frequency spectrum of the given input.
Note: DFT by correlation is a time consuming process, you may have to wait for a few seconds to see the spectrum.
Download Discrete Fourier Transform source code
|