1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Tài liệu DSP phòng thí nghiệm thử nghiệm bằng cách sử dụng C và DSK TMS320C31 (P6) pdf

30 465 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 30
Dung lượng 427,32 KB

Nội dung

ț The fast Fourier transform using radix-2 and radix-4 ț Decimation or decomposition in frequency and in time ț Programming examples The fast Fourier transform (FFT) is an efficient algorithm that is used for con- verting a time-domain signal into an equivalent frequency-domain signal, based on the discrete Fourier transform (DFT). A real-time programming example is included with a main C program that calls an FFT assembly function. 6.1 INTRODUCTION The discrete Fourier transform converts a time-domain sequence into an equiva- lent frequency-domain sequence. The inverse discrete Fourier transform per- forms the reverse operation and converts a frequency-domain sequence into an equivalent time-domain sequence. The fast Fourier transform (FFT) is a very ef- ficient algorithm technique based on the discrete Fourier transform, but with fewer computations required. The FFT is one of the most commonly used oper- ations in digital signal processing to provide a frequency spectrum analysis [1–6]. Two different procedures are introduced to compute an FFT: the decima- tion-in-frequency and the decimation-in-time. Several variants of the FFT have been used, such as the Winograd transform [7,8], the discrete cosine transform (DCT) [9], and the discrete Hartley transform [10–12]. Programs based on the DCT, FHT, and the FFT are available in [9]. 6.2 DEVELOPMENT OF THE FFT ALGORITHM WITH RADIX-2 The FFT reduces considerably the computational requirements of the discrete Fourier transform (DFT). The DFT of a discrete-time signal x(nT) is 165 6 Fast Fourier Transform Digital Signal Processing: Laboratory Experiments Using C and the TMS320C31 DSK Rulph Chassaing Copyright © 1999 John Wiley & Sons, Inc. Print ISBN 0-471-29362-8 Electronic ISBN 0-471-20065-4 X(k) = Α N – 1 n = 0 x(n) W nk k = 0, 1, , N – 1 (6.1) where the sampling period T is implied in x(n) and N is the frame length. The constants W are referred to as twiddle constants or factors, which represent the phase, or W = e – j2␲/N (6.2) and is a function of the length N. Equation (6.1) can be written for k = 0, 1, , N – 1, as X(k) = x(0) + x(1)W k + x(2)W 2k + + x(N – 1)W (N–1)k (6.3) This represents a matrix of N × N terms, since X(k) needs to be calculated for N values of k. Since (6.3) is an equation in terms of a complex exponential, for each specific k there are approximately N complex additions and N complex multiplications. Hence, the computational requirements of the DFT can be very intensive, especially for large values of N. The FFT algorithm takes advantage of the periodicity and symmetry of the twiddle constants to reduce the computational requirements of the FFT. From the periodicity of W W k+N = W k (6.4) and, from the symmetry of W W k+N/2 = – W k (6.5) Figure 6.1 illustrates the properties of the twiddle constants W for N = 8. For ex- ample, let k = 2, and note that from (6.4), W 10 = W 2 , and from (6.5), W 6 = – W 2 . 166 Fast Fourier Transform FIGURE 6.1 Periodicity and symmetry of twiddle constant W. For a radix-2 (base 2), the FFT decomposes an N-point DFT into two (N/2)- point or smaller DFT’s. Each (N/2)-point DFT is further decomposed into two (N/4)-point DFT’s, and so on. The last decomposition consists of (N/2) two- point DFT’s. The smallest transform is determined by the radix of the FFT. For a radix-2 FFT, N must be a power or base of two, and the smallest transform or the last decomposition is the two-point DFT. For a radix-4, the last decomposi- tion is a four-point DFT. 6.3 DECIMATION-IN-FREQUENCY FFT ALGORITHM WITH RADIX-2 Let a time-domain input sequence x(n) be separated into two halves: a) x(0), x(1), , x ΂ – 1 ΃ (6.6) and b) ΂΃ , x ΂ + 1 ΃ , , x(N – 1) (6.7) Taking the DFT of each set of the sequence in (6.6) and (6.7), X(k) = Α (N/2) – 1 n = 0 x(n)W nk + Α N – 1 n = N/2 x(n)W nk (6.8) Let n = n + N/2 in the second summation of (6.8), X(k) becomes X(k) = Α (N/2) – 1 n = 0 x(n)W nk + W kN/2 Α (N/2) – 1 n = 0 x ΂ n + ΃ W nk (6.9) where W kN/2 is taken out of the second summation because it is not a function of n. Using, W kN/2 = e –jk␲ = (e –j␲ ) k = (cos ␲ – jsin ␲) k = ( – 1) k in (6.9), X(k) becomes X(k) = Α (N/2) – 1 n = 0 ΄ x(n) + (–1) k x ΂ n + ΃΅ W nk (6.10) Because (–1) k = 1 for even k and –1 for odd k, (6.10) can be separated for even and odd k, or N ᎏ 2 N ᎏ 2 N ᎏ 2 N ᎏ 2 N ᎏ 2 6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 167 for even k: X(k) = Α (N/2) – 1 n = 0 ΄ x(n) + x ΂ n + ΃΅ W nk (6.11) for odd k: X(k) = Α (N/2) – 1 n = 0 ΄ x(n) – x ΂ n + ΃΅ W nk (6.12) Substituting k = 2k for even k, and k = 2k + 1 for odd k, (6.11) and (6.12) can be written as, for k = 0, 1, , (N/2) – 1, X(2k) = Α (N/2) – 1 n = 0 ΄ x(n) + x ΂ n + ΃΅ W 2nk (6.13) x(2K + 1) = Α (N/2) – 1 n = 0 ΄ x(n) – x ΂ n + ΃΅ W n W 2nk (6.14) Because the twiddle constant W is a function of the length N, it can be repre- sented as W N . Then, W N 2 can be written as W N /2 . Let a(n) = x(n) + x(n + N/2) (6.15) b(n) = x(n) – x(n + N/2) (6.16) Equations (6.13) and (6.14) can be more clearly written as two (N/2)-point DFT’s, or X(2k) = Α (N/2) – 1 n = 0 a(n)W N/2 nk (6.17) X(2k + 1) = Α (N/2) – 1 n = 0 b(n)W N n W N/2 nk (6.18) Figure 6.2 shows the decomposition of an N-point DFT into two (N/2)-point DFT’s, for N = 8. As a result of the decomposition process, the X’s in Figure 6.2 are even in the upper half and they are odd in the lower half. The decomposition process can now be repeated such that each of the (N/2)-point DFT’s is further decomposed into two (N/4)-point DFT’s, as shown in Figure 6.3, again using N = 8 to illustrate. The upper section of the output sequence in Figure 6.2 yields the sequence X(0) and X(4) in Figure 6.3, ordered as even. X(2) and X(6) from Figure 6.3 rep- resent the odd values. Similarly, the lower section of the output sequence in Fig- ure 6.2 yields X(1) and X(5), ordered as the even values, and X(3) and X(7) as the odd values. This scrambling is due to the decomposition process. The final N ᎏ 2 N ᎏ 2 N ᎏ 2 N ᎏ 2 168 Fast Fourier Transform order of the output sequence X(0), X(4), . . . in Figure 6.3 is shown to be scram- bled. The output needs to be resequenced or reordered. A special instruction us- ing indirect addressing with bit-reversal, introduced in Chapter 2 in conjunction with circular buffering, is available on the TMS320C3x to reorder such a se- quence. The output sequence X(k) represents the DFT of the time sequence x(n). This is the last decomposition, since we have now a set of (N/2) two-point DFT’s, the lowest decomposition for a radix-2. For the two-point DFT, X(k) in (6.1) can be written as 6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 169 FIGURE 6.2 Decomposition of N-point DFT into two (N/2)-point DFT’s, for N = 8. FIGURE 6.3 Decomposition of two (N/2)-point DFT’s into four (N/4)-point DFT’s, for N = 8. X(k) = Α 1 n = 0 x(n)W nk k = 0, 1 (6.19) or X(0) = x(0)W 0 + x(1)W 0 = x(0) + x(1) (6.20) X(1) = x(0)W 0 + x(1)W 1 = x(0) – x(1) (6.21) since W 1 = e –j2␲/2 = – 1. Equations (6.20) and (6.21) can be represented by the flow graph in Figure 6.4, usually referred to as a butterfly. The final flow graph of an eight-point FFT algorithm is shown in Figure 6.5. This algorithm is re- ferred as decimation-in-frequency (DIF) because the output sequence X(k) is decomposed (decimated) into smaller subsequences, and this process continues through M stages or iterations, where N = 2 M . The output X(k) is complex with both real and imaginary components, and the FFT algorithm can accomodate either complex or real input values. The FFT is not an approximation of the DFT. It yields the same result as the DFT with less computations required. This reduction becomes more and more important with higher-order FFT. There are other FFT structures that have been used to illustrate the FFT. An alternative flow graph to the one shown in Figure 6.5 can be obtained with or- dered output and scrambled input. An eight-point FFT is illustrated through an exercise as well as through a programming example. We will see that flow graphs for higher-order FFT (larg- er N) can readily be obtained. Exercise 6.1 Eight-Point FFT Using Decimation-in-Frequency Let the input x(n) represent a rectangular waveform, or x(0) = x(1) = x(2) = x(3) = 1, and x(4) = x(5) = x(6) = x(7) = 0. The eight-point FFT flow graph in Figure 6.5 can be used to find the output sequence X(k), k = 0, 1, , 7. With N = 8, four twiddle constants need to be calculated, or 170 Fast Fourier Transform FIGURE 6.4 Two-point FFT butterfly. W 0 = 1 W 1 = e –j2␲/8 = cos(␲/4) – jsin(␲/4) = 0.707 – j0.707 W 2 = e –j4␲/8 = – j W 3 = e –j6␲/8 = – 0.707 – j0.707 The intermediate output sequence can be found after each stage. 1. At stage 1: x(0) + x(4) = 1 Ǟ xЈ(0) x(1) + x(5) = 1 Ǟ xЈ(1) x(2) + x(6) = 1 Ǟ xЈ(2) x(3) + x(7) = 1 Ǟ xЈ(3) [x(0) – x(4)]W 0 = 1 Ǟ xЈ(4) [x(1) – x(5)]W 1 = 0.707 – j0.707 Ǟ xЈ(5) [x(2) – x(6)]W 2 = –j Ǟ xЈ(6) [x(3) – x(7)]W 3 = –0.707 – j0.707 Ǟ xЈ(7) where xЈ(0), xЈ(1), , xЈ(7) represent the intermediate output sequence after the first iteration that becomes the input to the second stage. 2. At stage 2: 6.3 Decimation-in-Frequency FFT Algorithm with Radix-2 171 FIGURE 6.5 Eight-point FFT flow graph using decimation-in-frequency. xЈ(0) + xЈ(2) = 2 Ǟ xЈЈ(0) xЈ(1) + xЈ(3) = 2 Ǟ xЈЈ(1) [xЈ(0) – xЈ(2)]W 0 = 0 Ǟ xЈЈ(2) [xЈ(1) – xЈ(3)]W 2 = 0 Ǟ xЈЈ(3) xЈ(4) + xЈ(6) = 1 – j Ǟ xЈЈ(4) xЈ(5) + xЈ(7) = (0.707 – j0.707) + (–0.707 – j0.707) = –j1.41 Ǟ xЈЈ(5) [xЈ(4) – xЈ(6)]W 0 = 1 + j Ǟ xЈЈ(6) [xЈ(5) – xЈ(7)]W 2 = –j1.41 Ǟ xЈЈ(7) The resulting intermediate, second-stage output sequence xЈЈ(0), xЈЈ(1), , xЈЈ(7) becomes the input sequence to the third stage. 3. At stage 3: X(0) = xЈЈ(0) + xЈЈ(1) = 4 X(4) = xЈЈ(0) – xЈЈ(1) = 0 X(2) = xЈЈ(2) + xЈЈ(3) = 0 X(6) = xЈЈ(2) – xЈЈ(3) = 0 X(1) = xЈЈ(4) + xЈЈ(5) = (1 – j) + (–j1.41) = 1 – j2.41 X(5) = xЈЈ(4) – xЈЈ(5) = 1 + j0.41 X(3) = xЈЈ(6) + xЈЈ(7) = (1 + j) + (–j1.41) = 1 – j0.41 X(7) = xЈЈ(6) – xЈЈ(7) = 1 + j2.41 We now use the notation of X’s to represent the final output sequence. The val- ues X(0), X(1), , X(7) form the scrambled output sequence. These results can be verified with an FFT function available with the MATLAB software package described in Appendix B. We will show soon how to reorder the output se- quence and plot the output magnitude. Exercise 6.2 Sixteen-Point FFT Given x(0) = x(1) = = x(7) = 1, and x(8) = x(9) = = x(15) = 0, which rep- resents a rectangular input sequence. The output sequence can be found using the 16-point flow graph shown in Figure 6.6. The intermediate output results af- ter each stage are found in a similar manner to the previous example. Eight twiddle constants W 0 , W 1 , , W 7 need to be calculated for N = 16. Verify the scrambled output sequence X’s as shown in Figure 6.6. Reorder this output sequence and take its magnitude. Verify the plot in Figure 6.7, which 172 Fast Fourier Transform 173 FIGURE 6.6 16-point FFT flow graph using decimation-in-frequency. represents a sinc function. The output X(8) represents the magnitude at the Nyquist frequency. These results can be verified with an FFT function available with MATLAB, described in Appendix B. 6.4 DECIMATION-IN-TIME FFT ALGORITHM WITH RADIX-2 Whereas the decimation-in-frequency (DIF) process decomposes an output se- quence into smaller subsequences, the decimation-in-time (DIT) is another process that decomposes the input sequence into smaller subsequences. Let the input sequence be decomposed into an even sequence and an odd se- quence, or x(0), x(2), x(4), , x(2n) and x(1), x(3), x(5), , x(2n + 1) We can apply (6.1) to these two sequences to obtain X(k) = Α (N/2) – 1 n = 0 x(2n)W 2nk + Α (N/2) – 1 n = 0 x(2n + 1)W (2n+1)k (6.22) Using W N 2 = W N/2 in (6.22) X(k) = Α (N/2) – 1 n = 0 x(2n)W N/2 nk + W N k Α (N/2) – 1 n = 0 x(2n + 1)W N/2 nk (6.23) 174 Fast Fourier Transform FIGURE 6.7 Output magnitude for 16-point FFT. [...]... programming example, the results are stored in memory, and can be verified It illustrates a complex FFT with N = 8, using a decimation-in-frequency procedure with radix-2 Figure 6.12 shows the main program FFT 8C. C in C code that calls a generic FFT function FFT .C, also in C code The input sequence, specified in the main program, represents a rectangular sequence, x(0) = = x(3) = 1000 + j0 and x(4)= = x(7)... The program TWIDGEN .C (on disk) generates the twiddle constants for a complex FFT It is to be compiled with Turbo C+ + or Borland C+ + The resulting file TWIDDLE.H con- /*FFT 8C. C - 8-POINT COMPLEX FFT PROGRAM CALLS FFT .C */ #include “complex.h” /*complex structure definition */ extern void FFT(); /*FFT function */ volatile int *out_addr=(volatile int *)0x809802; /*out addr*/ main() { COMPLEX y[8]={1000,0,1000,0,1000,0,1000,0,... general complex FFT The input must be real The resulting output is still complex In this case, computational requirements can be reduced The real-valued input FFT can be executed in about half the time as the more general complex FFT 188 Fast Fourier Transform Figure 6.14 shows a listing of the C program FFT8MC .C that calls a real-valued FFT function FFT_RL.ASM in TMS32 0C3 x code (on the accompanying... lower_leg, similar calculations are performed to obtain the final output from stage 3 4 The last section in the FFT function performs the bit-reversal procedure and produces a proper sequencing of the output data If you have the floating-point tools, compile each program, then link them with the linker command file FFT 8C. CMD (on the accompanying disk) to create the executable file FFT 8C. OUT (also on the... program SINEGEN .C that generates twiddle constants needs to be compiled using Turbo C+ + or Borland C+ + 1 Implement a 16-point complex FFT Modify the main C program FFT 8C. C in Example 6.1 using 16 sets of input samples with COMPLEX y[16] and n = 16, in the program No changes are required in the generic FFT function FFT .C or in the header file TWIDDLE.H that contains the twiddle constants With a rectangular... 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; /*rectangular input*/ int i, n = 8; FFT(y,n); /*calls generic FFT function*/ for (i = 0; i . program FFT 8C. C in C code that calls a generic FFT function FFT .C, also in C code. The input sequence, specified in the main program, represents a rectangular. file TWIDDLE.H con- 184 Fast Fourier Transform /*FFT 8C. C - 8-POINT COMPLEX FFT PROGRAM. CALLS FFT .C */ #include “complex.h” /*complex structure definition

Ngày đăng: 26/01/2014, 14:20

Nguồn tham khảo

Tài liệu tham khảo Loại Chi tiết
1. J. W. Cooley and J. W. Tukey, “An Algorithm for the Machine Calculation of Complex Fourier Series,” Math. of Computation, 19, 297–301 (1965) Sách, tạp chí
Tiêu đề: An Algorithm for the Machine Calculation of ComplexFourier Series,” "Math. of Computation, 19
2. J. W. Cooley, “How the FFT Gained Acceptance,” IEEE Signal Processing Magazine, pp.10–13, Jan. 1992 Sách, tạp chí
Tiêu đề: How the FFT Gained Acceptance,” "IEEE Signal Processing Magazine
3. J. W. Cooley, “The Structure of FFT and Convolution Algorithms, from a Tutorial,” in IEEE 1990 International Conference on Acoustics, Speech, and Signal Processing, April 1990 Sách, tạp chí
Tiêu đề: The Structure of FFT and Convolution Algorithms, from a Tutorial,” in"IEEE 1990 International Conference on Acoustics, Speech, and Signal Processing
4. C. S. Burrus and T. W. Parks, DFT/FFT and Convolution Algorithms: Theory and Imple- mentation, Wiley, New York, 1988 Sách, tạp chí
Tiêu đề: DFT/FFT and Convolution Algorithms: Theory and Imple-"mentation
5. G. D. Bergland, “A guided tour of the fast Fourier transform,” IEEE Spectrum, 6, 41–51 (1969) Sách, tạp chí
Tiêu đề: A guided tour of the fast Fourier transform,” "IEEE Spectrum
6. E. O. Brigham, The Fast Fourier Transform, Prentice-Hall, Englewood Cliffs, NJ, 1974 Sách, tạp chí
Tiêu đề: The Fast Fourier Transform
7. S. Winograd, “On Computing the Discrete Fourier Transform,” Math. of Computation, 32, 175–199 (1978) Sách, tạp chí
Tiêu đề: On Computing the Discrete Fourier Transform,” "Math. of Computation
8. H. F. Silverman, “An Introduction to Programming the Winograd Fourier Transform Al- gorithm (WFTA),” IEEE Trans. on Acoustics, Speech, and Signal Processing, ASSP-25, 152–165, April (1977) Sách, tạp chí
Tiêu đề: An Introduction to Programming the Winograd Fourier Transform Al-gorithm (WFTA),” "IEEE Trans. on Acoustics, Speech, and Signal Processing
9. P. E. Papamichalis ed., Digital Signal Processing Applications with the TMS320 Fami- ly—Theory, Algorithms, and Implementations, Vol.3, Texas Instruments, Inc., Dallas, TX, 1990 Sách, tạp chí
Tiêu đề: Digital Signal Processing Applications with the TMS320 Fami-"ly—Theory, Algorithms, and Implementations
10. R. N. Bracewell, “Assessing the Hartley Transform,” IEEE Trans. on Acoustics, Speech, and Signal Processing, ASSP-38, 2174–2176 (1990) Sách, tạp chí
Tiêu đề: Assessing the Hartley Transform,” "IEEE Trans. on Acoustics, Speech,"and Signal Processing
11. R. N. Bracewell, The Hartley Transform, Oxford University Press, New York, 1986 Sách, tạp chí
Tiêu đề: The Hartley Transform
12. R. Chassaing, Digital Signal Processing with C and the TMS320C30, Wiley, New York, 1992 Sách, tạp chí
Tiêu đề: Digital Signal Processing with C and the TMS320C30
13. H. V. Sorensen, D. L. Jones, M. T. Heidman, and C. S. Burrus, “Real-Valued Fast Fourier Transform Algorithms,” IEEE Trans. on Acoustics, Speech, and Signal Processing, ASSP-35, 849–863 (1987) Sách, tạp chí
Tiêu đề: Real-Valued Fast FourierTransform Algorithms,” "IEEE Trans. on Acoustics, Speech, and Signal Processing
14. Details on Signal Processing, Texas Instruments, Inc., Dallas, TX, Fall 1990 Sách, tạp chí
Tiêu đề: Details on Signal Processing
15. Details on Signal Processing, Texas Instruments, Inc., Dallas, TX, Winter 1992 Sách, tạp chí
Tiêu đề: Details on Signal Processing
16. TMS320C3x General-Purpose Applications User’s Guide, Texas Instruments, Inc., Dal- las, TX, 1998 Sách, tạp chí
Tiêu đề: TMS320C3x General-Purpose Applications User’s Guide
17. P. M. Embree and B. Kimble, C Language Algorithms for Digital Signal Processing, Prentice-Hall, Englewood Cliffs, NJ, 1990 Sách, tạp chí
Tiêu đề: C Language Algorithms for Digital Signal Processing
18. S. Kay and R. Sudhaker, “A Zero Crossing Spectrum Analyzer,” IEEE Trans. on Acoustics, Speech, and Signal Processing, ASSP-34, 96–104 February (1986) Sách, tạp chí
Tiêu đề: A Zero Crossing Spectrum Analyzer,” "IEEE Trans. on"Acoustics, Speech, and Signal Processing
19. P. Kraniauskas, “A plain Man’s Guide to the FFT,” IEEE Signal Processing Magazine, April 1994 Sách, tạp chí
Tiêu đề: A plain Man’s Guide to the FFT,” "IEEE Signal Processing Magazine
20. J. R. Deller, Jr., “Tom, Dick, and Mary Discover the DFT,” IEEE Signal Processing Mag- azine, April 1994 Sách, tạp chí
Tiêu đề: Tom, Dick, and Mary Discover the DFT,” "IEEE Signal Processing Mag-"azine

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w