Digital Signal Processing Reference
In-Depth Information
to the cosine (first input), and instead use the sine table values.
Rebuild and Animate again. Verify a large negative value at j = m = 2
(-10,232) and a large positive value at j = N - m = 18 (10,232) .For
a real-time implementation, the magnitude of X(k),k =
0,1,...can be found.
With F s =
8 kHz, the frequency generated would correspond to f
=
800 Hz.
Example 6.2: FFT of a Real-Time Input Signal Using an
FFT Function in C (FFT256C)
Figure 6.13 shows a listing of the program FFT256c.c which implements a 256-
point FFT in real time, using an external input signal. It calls a generic FFT func-
tion in C, FFT.c (on the accompanying CD). This FFT function, used with the C31
DSK and the C30 EVM, is listed and described in Refs. 13 and 14.
The twiddle constants are generated within the program. The imaginary compo-
nents of the input data are set to zero to illustrate this implementation. The mag-
nitude of the resulting FFT (scaled) is taken for output to the codec. Three buffers
are used:
1. samples : contains the data to be transformed
2. iobuffer : used to output processed data as well as acquiring new input
sampled data
3. x 1: contains the magnitude (scaled) of the transformed (processed) data
In every sample period, an output value from a buffer ( iobuffer ) is sent to the
codec's DAC and an input value is acquired and stored into the same buffer. An
index ( buffercount ) to this buffer is used to set a flag when this buffer is full.
When this buffer is full, it is copied to another buffer ( samples ), which will be used
when calling the FFT function. The magnitude (scaled) of the processed FFT data,
contained in a buffer x 1 , can now be copied to the I/O buffer, iobuffer , for output.
In a filtering algorithm, processing can be done as each new sample is acquired. On
the other hand, an FFT algorithm requires that an entire frame of data be available
for processing.
Build and run this project as FFT256c . Input a 2-kHz sine wave with an ampli-
tude of approximately 1 V p-p. Figure 6.14 shows a time-domain representation of
the magnitude of the transformed data obtained with an HP dynamic signal ana-
lyzer (you can use an oscilloscope). The two negative spikes are 256( T s )
32 ms
apart, as shown in Figure 6.14. This interval also represents the sampling frequency
F s . The location of the first positive spike then corresponds to a frequency of 2 kHz
(the mid-distance between the two spikes corresponds to 4 kHz). The location of the
second positive spike corresponds to the folding frequency of F s -
=
6 kHz. Increase
the frequency of the input signal and observe the convergence of the two spikes
toward the 4-kHz Nyquist frequency.
f
=
Search WWH ::




Custom Search