• Increase font size
  • Default font size
  • Decrease font size

Fast Fourier Transform Source code in Visual Basic - FFT

E-mail Print PDF

Though discrete fourier transform can convert time domain data in to frequency domain accurately, it has an unavoidable drawback. It is the inefficiency of the algorithm which makes the processing much time consuming. As a solution to this problem, Fast Fourier Transform (FFT) is invented. FFT is much faster and efficient than DFT. the sample program written in Visual Basic lets you generate different waveforms, and examine its spectrum.

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. Fast Fourier Transform is a complex algorithm to find DFT in a computationally efficient way. The DFT obtained by correlation and FFT are exactly same. But FFT is many times faster than DFT by correlation. The efficiency increases with the number of samples involved in DFT. For small number of samples (say 8,16), the speed difference between DFT by correlation and FFT is not apparent. But for a large number of samples ( say 1024 , 2048) the computational efficiency of FFT is tremendous.

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 fft.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.


Download Fast Fourier Transform source code