Make your own free website on Tripod.com
Discrete Fourier Transform
Main Software Page

harmonic = the number of harmonics
pt = the number of sample points
b(i) = matrix that holds the voltage data points, from b(1) to b(pt)

The sample points must be equally spaced over one cycle of the time domain waveform.
FOR harmonic = 1 TO 20
twopi = 2 * 3.141592654# * harmonic
sine = 0
cosine = 0
twopipt = twopi / pt
FOR i = 1 TO pt
IF i = 1 THEN
oldcos = 1
oldsin = 0
END IF
x = i * twopipt
newcos = COS(x)
newsin = SIN(x)
sine = -(newcos - oldcos) * b(i) + sine
cosine = (newsin - oldsin) * b(i) + cosine
oldcos = newcos
oldsin = newsin
NEXT i
voltage(harmonic) = SQR((sine ^ 2 + cosine ^ 2) / ((twopi / 2) ^ 2))
PRINT voltage(harmonic)
NEXT harmonic
Main Software Page