??? 11/12/06 18:20 Read: times |
#127825 - You're getting into theory Responding to: ???'s previous message |
Hi Prahlad,
..., But How does FFT algoritham know what exactly is fundamental. It doesn't. Generally speaking the fundamental frequency of a chosen waveform is the lowest frequency component of the wave. But these are generally special shaped waves like sine waves, square waves, sawtooth and ramp waves. In the most general case of an arbitrary waveform there may be no component frequency that readilly presents itself as fundamental. So even if a fundamental frequency is evident, there's absolutely nothing special about it as far as the Fourier Transform is concerned. Nonetheless, in your specific case the fundamental frequency will have the greatest amplitude (unless your transformer or whatever it is that's producing the wave has gone completely out to lunch) and should be the lowest frequency (unless you've got some serious aliasing going on). ... according to the commenting in his code.
amplitude[0] = DC amplitude[1] = Fundamental amplitude[2] = 2N freq. and so on But according to some other texts I found on net. amplitude[1] = 1Hz amplitude[2] = 2Hz and so on. Now the confusion is which one of the above two is correct .... Neither of them is correct, in the strictest sense. A complete Fourier Transform should produce a set of amplitudes as a function of frequency, either discreet or continuous, which extends over the domain of -inf to +inf, and which is symmetrical about 0. But there are many ways to implement the transform, and the output of any given algorithm is pretty much up to the writer of the algorithm. Many algorithms, for example, simply discard the negative frequencies (as apparently do both of the two you're considering). You will need to make certain that this won't adversely affect your THD calculation. (I'm not being cagey, I really don't know for sure if it will or not, but you might need to double your result). Some algorithms neglect any dc bias of the time domain signal, as does the second of the two you're considering. As a result, it is also going to neglect any frequency components below 1 Hz (or whatever lower cutoff your particular algorithm employs). I really want to stress that you need to look up an article or two on the Fourier Transform and at least become familiar with the theory before you place too much trust in some code that you cut and paste into your application. Then look up an article or two on the Fast Fourier Transform. You don't need to become a math major, but you really should be somewhat familiar with these algorithms before you blindly use them. |