APPLICATION NOTE 30 DFT or FFT? A Compariso of Fourier Trasform Techiques This applicatio ote ivestigates differeces i performace betwee the DFT (Discrete Fourier Trasform) ad the FFT(Fast Fourier Trasform) from a mathematical ad practical level whe utilised for harmoic aalysis of electrical waveforms. Exploratio of the advatages ad disadvatages of each algorithm, as well as determiatio of the best approach for harmoic aalysis withi a power electroics eviromet will be covered. With may Power Aalyzers utilisig the FFT ad fewer utilisig the DFT, the applicatio ote will ivestigate the reasos for the popularity of the FFT ad the problems associated with it. Defiitio Fourier aalysis is a mathematical method of represetig a periodic waveform i terms of a series of trigoometric fuctios. The Frech mathematicia ad Physicist Mr Jea Baptiste Joseph, Baro De Fourier developed the Fourier aalysis techique i the 18th~19th ceturies. Fourier aalysis is used i may idustries, electroics, mechaical egieerig, acoustic egieerig ad much more. This applicatio ote will apply Fourier aalysis to the decompositio of AC periodic waveforms. This is commoly used withi electroics to determie the distortio of a waveform by represetig a time varyig periodic sigal as a discrete umber of "harmoics". Periodic Fuctios A periodic fuctio should be cosidered as a "repeatig patter", where at time T, for all iteger values of, ad T equal to the repetitio period the waveform, the followig is true; f(x + T) = f(x) (1) For example : y = si(x)is periodic i x with a period of 2, if y = si(ωt) the the period of the waveform is 2 where ω ω = periodic frequecy (2f) For a frequecy of 10Hz, ω = 20 rads sec 2 therefore the fudametal time period T is = 0.1secods. 20 y = si ω(t + T) (2) The magitude of the waveform at iitial time t = 0.021 is calculated, as well as the subsequet magitudes at time t + ( T) si 20(0.021 + 0.1) (3) =0 =1 =2 0.969 0.969 0.969 A sie wave is kow as a cotiuous fuctio, it does ot exhibit ay sudde jumps or breaks. Whereas other waveforms, such as the square wave exhibits fiite discotiuities. A advatage of the Fourier series is that it ca be applied to both cotiuous ad discotiuous waveforms.
Fourier Series The fudametal basis of the Fourier series is that a fuctio defied withi the iterval x ca be expressed as a coverget trigoometric series i the followig form; f(x) = a 0 + a 1 cosx + a 2 cos2x + a 3 cos3x + + b 1 six + b 2 si2x + b 3 si3x + where a 0, a 1, a 2, a 3 b 1, b 2, b 3 are real costats This ca be simplified to the followig; f(x) = a 0 + =1 (a cos x + b si x) (4) For the rage to ; a 0 = 1 2 a = 1 b = 1 f(x)dx f(x) cos x dx f(x) si x dx ( = 1, 2, 3 ) (6) ( = 1, 2, 3 ) (7) (5) A alterative way of writig the Fourier series above, which is of more relevace to digital sigal processig of complex electrical waveforms is derived from the followig relatioship; a cos x + b cos x = c si (x + α) (8) Applyig this to the Fourier series; f(x) = a 0 + c 1 si(x + α) + c 2 si(2x + α 2 ) + + c si (3x + α ) (9) a 0 is a costat c 1 = a 1 2 + b 1 2,. c = a 2 + b 2 are the magitudes of each coefficiet (10) α = arcta a b is the phase offset of each coefficiet (11) C represets the magitude of the th compoet, or th harmoic. Whe = 1, the harmoic is kow as the fudametal. α represets the phase agle of the th harmoic. It is at this poit that all of the mathematical tools required to decompose a periodic waveform have bee derived.
Mathematical Example, 2Vpk Square Wave I this example a 2Vpk (4Vpk-pk) square wave is decomposed ito its costituet harmoics. The fuctio for the above waveform is give by; Fig 1. 2, whe < x < 0 f(x) = 2, whe 0 < x < As the pure square wave fuctio is discotiuous, the itegratio will be performed i two discrete halves. Oe from - to 0 ad aother from 0 to. a 0 = 1 2 f(x)dx a 0 = 1 [ 0 2 dx + 2 2 dx] 0 (12) (13) a 0 = 1 {[ 2x] 0 2 + [2x] 0 } = 0 (14) a 0 equates to the mea value of the waveform (DC offset i electrical terms) over the complete fudametal period. 0 a = 1 [ 2 cos x dx + 2 cos x dx ] 0 (15) a = 1 2 si x 0 si x + 2 0 = 0 (16) Therefore, a 1, a 2, a 3 are all zero. 0 b = 1 [ 2 si x dx + 2 si x dx ] 0 (17) b = 1 cos x 2 0 cos x + 2 0 = 0 (18) whe is odd
b = 2 1 1 + 1 1 (19) b = k 2 + 2 = 4k as k = 2, b = 8 (20) (21) Therefore b 1 = 8, b 3 = 8 3, b 5 = 8 5 whe is eve b = 2 1 1 + 1 1 = 0 (22) b 1, b 2, b 3 = 0 Therefore, the Fourier series for the 2Vpk square wave is as follows; f(x) = a 0 + =1 (a cos x + b si x) (23) f(x) = 0 + =1 (0 + b si x) (24) f(x) = 8 six + 8 si3x + 8 si5x + (25) 3 5 f(x) = 8 (six + 1 si3x + 1 si5x + ) (26) 3 5 The magitude ad phase of each harmoic ca be computed as follows; c = a 2 + b 2 are the magitudes of each coefficiet (27) α = arcta a b is the phase offset of each coefficiet (28) For the 3rd harmoic; c 3 = 0 2 + 8 2 8 = 3 3 α = arcta 0 = 0 (30) 8 3 3rd Harmoic = 0.85V, 0 (29)
Harmoic Aalysis It is widely kow that may of the waveforms withi the electroics idustry ca be represeted by simple mathematical expressios. By utilisig the Fourier series, the magitude ad phase of the harmoics ca be derived. Some waveforms do ot fit ito this category ad aalysis of such waveforms is performed through umerical methods. Harmoic Aalysis is the process of resolvig a periodic, o-siusoidal waveform ito a series of siusoids of icreasig order of frequecy. Followig o from the mathematical expressios derived earlier i this applicatio ote, a umerical method is ow preseted which itroduces the fudametals behid the approach used withi harmoic aalyzers. Ultimately, Fourier coefficiets a 0, a ad b will eed to be determied - see equatios (5), (6) ad (7), this will require itegratio. Numerically, the itegral fuctios (5), (6) ad (7) ca be described as mea values, as follows; a 0 = 1 f(x)dx = 1 2 2 0 2 f(x)dx (5) a 0 = mea value of f(x) (31) a = 1 f(x) cos x dx = 1 2 f(x) cos x dx 0 ( = 1, 2, 3 ) (6) a = twice mea value of f(x) cos x (32) b = 1 f(x) si x dx ( = 1, 2, 3 ) (7) b = twice mea value of f(x) si x (33) This itegratio is performed withi the sigal processig elemets of a harmoic aalyzer (traditioally a DSP) with the trapezoidal rule. As most waveforms withi the realm of electroics are periodic, the period of the waveform ca be referred to as w (widow), which ca be divided up ito s (sample poits) of equal parts. Where d(time delta) is the time iterval i betwee the sample poits. A complex waveform is ow used as a example (fig.2) to illustrate how the waveform is sampled ad umerical Fourier aalysis methods are explaied. Fig 2.
Fig 3. = total umber of samples, i th sample, d = time betwee samples a 0 = Mea Value = a = 1 v[i] cos 2hi i=1 b = 1 v[i] si 2hi i=1 area legth of base = 1 2 2 v[i] i=1 = 1 v[i] i=1 (34) (35) (36) I electrical terms, a 0 is the DC offset, a is the quadrature compoet of the th harmoic, ad b is the iphase compoet of the th harmoic. Simple trigoometry ca be applied to derive the magitude ad phase of the harmoics.
As equatios 35 ad 36 represet the mea value of the harmoics, it is commo to refer to the equivalet RMS values, a scale factor of 2 is applied to achieve this. a = 2 b = 2 v[i] cos 2hi i=1 v[i] si 2hi i=1 (37) (38) Harmoic aalyzers make use of the trapezoidal rule to closely approximate the true value of the harmoic magitudes. It is logical to assume that a higher sample rate results better accuracy ad although this is the case i simplistic terms, the reality is more complicated as averagig reduces the effect of lower sample rates. That beig said, as per Nyquist's theorem, the samplig rate must be twice that of the badwidth of the measured sigal. FFT Applicatio All previous cotet withi this applicatio ote represets the DFT, this could be cosidered the purest of Fourier trasforms ad is the origial Fourier trasform. I 1965 Cooley ad Tukey published the geeric FFT algorithm ad the drive for this developmet was ot improved accuracy but it was improved computatio time. Whilst the FFT required less processig power, i a real world measuremet eviromet it is difficult for the FFT to provide the same accuracy as the DFT. The reasos for this are due to the fact that the FFT is restricted (by the ature of its "divide ad coquer" mathematical approach) to a widow size of 2 samples. If the sample rate were ifiitely variable, ad the fudametal frequecy of the waveform to be aalysed already kow - the it would be possible to vary the sample rate i order to esure a iteger umber of cycles are ecompassed withi the samplig widow. As it is ot practical i a real time measuremet eviromet to ifiitely vary the sample rate, it is almost impossible to esure a iteger umber of cycles are ecompassed by the samplig widow. Importat ote : If a exact iteger umber of cycles were able to be ecompassed withi the data acquisitio widow of the FFT the this algorithm would provide similar accuracies to the DFT. The restrictio of 2 samples ad fixed/discrete sample rates meas this is impractical ad the FFT caot offer the same flexibility ad accuracy i a real time measuremet eviromet. The result of icomplete cycles withi the samplig widow is kow as "harmoic leakage", i which harmoics "leak" ito adjacet harmoic eighbours, causig iaccuracies i the calculated results. I the aalysis below, a 1024 poit FFT was sampled at 10ks/s upo a 100Vpk, 25Hz waveform. Due to the ature of the FFT ad its restrictio to 2 samples, at this sample rate (which provides 5kHz measuremet badwidth - Nyquist's theorem) it is clear that the data acquisitio widow does ot ecompass a iteger umber of samples, the additioal udesirable samples are show i the red box i fig 4. Fig 4.
If a FFT harmoic spectrum aalysis is performed, sigificat harmoic leakage is evidet as a result of the o itegral cycle acquisitio. Fig 5. Various complex waveforms are ow aalyzed ad results from FFT ad DFT algorithms are compared. If the data acquisitio widow ecompasses a iteger umber of cycles, the harmoic leakage is sigificatly reduced. Although this is urealistic i a dyamic, real time measuremet eviromet this is performed for clarity of the mathematics i fig 6 ad fig 7. Fig 6. Fig 7. FFT Aalysis with ideal widow size
If the frequecy detectio or sample rate limitatio (ad subsequet widow size) drifts by oly 3~4Hz, the errors itroduced ito the FFT are quite sigificat. The graphs below illustrate this effect; Fig 8. Fig 9. Harmoic 1 (Fudametal) is sigificatly lower tha the 100Vpk origial compoet, there is also sigificat leakage ito other harmoics which i reality have o spectral voltage compoets. This is caused by the fact that the "sie ad cosie" multiplicatio of the FFT is ot performed at the correct harmoic frequecies, the fudametal compoet is i fact a 29.3Hz sie ad cosie multiplicatio. The FFT frequecies are derived from the sample rate ad the widow size. FFT Frequecy = fs sa = sample frequecy umber 1,2,3 1024, fs = sample rate, sa = umber of samples The FFT frequecy deotes the actual sie cosie calculatio, if the sample frequecy is ot ifiitely adjustable the FFT frequecies will be close but ot completely matchig the actual harmoic frequecies.
Error i FFT calculatio Harmoic Frequecy Actual (Vpk) Calculated with FFT Error % Fudametal 30.3Hz 100 97.25 2.75 2 60.6Hz 0 4.38 3 90.9Hz 0 2.65 4 121.2Hz 0 2.64 5 151.5Hz 20 12.68 36.59 6 181.8Hz 0 2.57 Table 1. The further the fudametal frequecies drift from the FFT frequecy, the greater the leakage ad greater the error i the measured harmoics. To Illustrate this effect, a fudametal frequecy of 31.3Hz (equatig to a drift of 2Hz) results i the followig spectral aalysis ad subsequet errors. Fig 10. Harmoic Frequecy Actual (Vpk) Calculated with FFT Error % Fudametal 30.3Hz 100 92.49 7.51 2 60.6Hz 0 7.62 3 90.9Hz 0 3.95 4 121.2Hz 0 2.67 5 151.5Hz 20 1.67 91.67 6 181.8Hz 0 2.03 Table 2. As previously metioed, it is impractical to achieve a exact iteger umber of waveform periods to fit withi the data acquisitio widow whe usig the FFT i a dyamic eviromet. It is therefore ot desirable to utilise the FFT Fourier aalysis techique i moder day power aalysis. There are widowig methods available to the egieer which will reduce the spectral leakage, these algorithms will improve values at some frequecies but also worse values at other frequecies. Ultimately, oe of the widowig algorithms available whe applied to a FFT will match the accuracy of the DFT.
DFT (Discrete Fourier Trasform) The Discrete Fourier trasform is able to resolve its samplig widow to ay iteger umber of samples, this equates to; widow resolutio = 1 fs I the time domai, this equates to a time resolutio of 100uS for a 10ks/s sample rate. If a 50Hz waveform is cosidered, its time period is 20ms. A 100us time resolutio eables the widow to perfectly ecompass both a 50Hz ad 50.25Hz, it is logical to coclude that a higher sample rate will result i greater frequecy resolutio as well as higher badwidth, if multiple cycles are used this resolutio is further improved. Newtos4th power aalyzers feature sample rates of 1Ms/s ad above, coupled with very accurate aalogue performace, this provides extremely sesitive ad accurate harmoic aalysis with fast update rates. Newtos4th Frequecy resolutio o a 50Hz waveform N4L PPA5500 widow resolutio(cycle by cycle) = 1 2Ms/s = 1 2 10 6 = 500S 1 N4L PPA5500 cycle by cycle frequecy resolutio o 50Hz waveform = 50 0.02 + 500 10 9 = 50 49.99875 = 0.001Hz The same waveform illustrated i fig.10 was used ad a DFT was performed, for a appropriate compariso the same 10ks/s sample rate was used. Whe utilisig a DFT waveform, it is possible to sychroise the data acquisitio widow to the fudametal time period with a resolutio of 1 sample poit. Oce this is performed, the DFT is able to calculate the harmoic compoets of the waveform very accurately. I this example the fudametal time period is calculated as follows; Fudametal Time Period = 1 = 1 = 0.0319 secods f fud 31.3 The umber of samples required to sychroise the data acquisitio widow to the fudametal time period is calculated as follows; No of samples required = fud time period sample time iterval = 0.0319 = 319.489 1 10000 The closest iteger umber of samples calculated is used as the data widow acquisitio size, N4L power aalyzers compute the fudametal frequecy "real-time" with a proprietary frequecy detectio algorithm withi a dedicated DSP. It should be apparet that for the DFT to be successful, frequecy detectio is of paramout importace, as all N4L power aalyzers utilise sample rates i excess of 1Ms/s, it is clear that the widow ad subsequet frequecy resolutio will be very accurate.
Fig 11. Fig 12. Figure 11 ad Figure 12 illustrate the effectiveess of the DFT eve whe utilisig low sample rates ad a sigle cycle. Higher sample rates ad multiple cycle aalysis will achieve greater accuracies through better widow sychroisatio (providig frequecy detectio is accurate) as well as greater averagig. Harmoic Frequecy Actual (Vpk) Calculated with FFT Error % 1 31.300 100.000 100.063 0.063 2 62.600 0.000 0.175 3 93.900 0.000 0.057 4 125.200 0.000 0.056 5 156.500 20.000 20.077 6 187.800 0.000 0.447 0.447 Table 3. The calculated error achieved with the DFT is sigificatly better tha the equivalet FFT, further beefits of the DFT iclude the flexibility of the data acquisitio widow providig cycle by cycle aalysis of ay waveform without the restrictios of 2 FFT widowig.
Referece Measuremets A N4L PPA5500 Precisio Power Aalyzer, which utilises a DFT Harmoic Aalysis algorithm was bech tested agaist the Fluke 6105A power stadard. The tests were carried out withi the UKAS ISO17025 Test Laboratory (Lab o. 7949) based at N4L Headquarters i the UK, results from the tests are show below; Fluke 6015A Calibratio of PPA5530 Power Aalyzer - No Adjustmet Harmoic Frequecy Applied (Vpk) Measured Error Ucertaity 1 31.3 100 99.977 0.02% 0.01% 2 62.6 0 <10mV NA NA 3 93.9 0 <10mV NA NA 4 125.2 0 <10mV NA NA 5 156.5 20 19.994 0.03% 0.03% 6 187.8 0 <10mV NA NA The errors above represet the total error of the measuremet istrumet, icludig the error of the aalogue iput chaels. This calibratio procedure demostrates the power of the DFT whe combied with extremely liear aalogue iput desig. Summary Whilst the FFT has its place withi the electrical egieerig field, for high accuracy power aalysis the FFT is ot the optimum solutio. A high ed power aalyzer will eed to meet the demads of moder idustry i which harmoic distortio of varyig fudametal frequecies is required to be measured. It is the resposibility of the power aalyzer maufacturer to itegrate sufficietly powerful processors ad iovative digital sigal processig techiques i order to meet the computatioal demads of the DFT. All N4L power aalyzers have bee developed with this approach i mid ad years of experiece fie tuig both aalogue hardware performace ad DFT sigal processig algorithms have resulted i a extremely accurate solutio uder a wide rage of iput waveforms. For more iformatio about ay of the Newtos4th Power Aalyzers, visit http://www.ewtos4th.com/products/power-aalyzers/ Author : Sales ad Applicatios Egieerig, Newtos4th Ltd, UK Refereces [1] J. Bird, Higher Egieerig Mathematics - Fifth Editio, Elsevier, 2006