Fast Fourier Transform Computation Using a C8051 MCU
Fan Wang
Huazhong University of Science & Technology
Photo of the System
Abstract
☼ A method of calculating FFT using a C8051 MCU is
introduced in this paper. The software is aimed at
computational efficiency and accuracy.
☼ By three key techniques: (1)avoidance of multiplication
whenever possible; (2)16-bit integer storage; (3)on-chip
PLL, a real-time audio spectrum is achieved.
☼ The results are displayed on a LCD screen and carefully
analyzed. Basic theories of FFT and common problems in
practice are discussed in detail.
BACKGROUNDS
A. Discrete Fourier Transform and Fast Fourier Transform
B. FFT Bit-Reversal Algorithm
C. Anti-aliasing Filtering and Windowing
D. Function Overview of the C8051 MCU
A. Discrete Fourier Transform and Fast Fourier Transform
,
)
(
)
(
1
0




N
n
nk
N
W
n
x
k
X 1
,...
2
,
1
,
0 
 N
k N
j
N e
W /
2


☼ For a length N complex sequence x(n), n=0,1,2,…N-1,
the discrete Fourier transform(DFT) is defined by
where
☼ According to periodicity and symmetry
)
(
)
(
)
( k
H
W
k
G
k
X k
N


1
2
/
,...
2
,
1
,
0 
 N
k
)
(
)
(
)
2
/
( k
H
W
k
G
N
k
X k
N



1
2
/
,...
2
,
1
,
0 
 N
k




1
2
0
2
/
)
2
(
)
(
N
n
kn
N
W
n
x
k
G 




1
2
0
2
/
)
1
2
(
)
(
N
n
nk
N
W
n
x
k
H
where
,
.
)
0
(
)
0
(
)
0
( 0
4 H
W
G
X 

)
1
(
)
1
(
)
1
( 1
4 H
W
G
X 

)
0
(
)
0
(
)
2
( 0
4 H
W
G
X 

)
1
(
)
1
(
)
3
( 1
4 H
W
G
X 

A. Discrete Fourier Transform and Fast Fourier Transform
We have the FFT process as the following:
(N=4)
(N=8)
B.FFT Bit-Reversal Algorithm
Previous
Data
Previous
Index
New Index
Desired
Data
x(0) 000 000 x(0)
x(1) 001 100 x(4)
x(2) 010 010 x(2)
x(3) 011 110 x(6)
x(4) 100 001 x(1)
x(5) 101 101 x(5)
x(6) 110 011 x(3)
x(7) 111 111 x(7)
C. Anti-aliasing Filtering and Windowing
☼ Anti-aliasing Filtering
Solution: A passive low-pass filter.
C. Anti-aliasing Filtering and Windowing
☼ Windowing
C. Anti-aliasing Filtering and Windowing
☼ Windowing
Type Equation
0: None(Rectangular) W(n)=1
1: Triangular W(n)=n/(N/2) (0≤n≤N/2)
W(n)=2-n/(N/2) (N/2<n<N)
2: Hanning W(n)=0.5-0.5cos(2πn/N)
3: Hamming W(n)=0.54-0.46cos(2πn/N)
4: Blackman W(n) = 0.42 - 0.5cos(2πn / N)
+0.08cos(4πn / N)
D. Function Overview of the C8051 MCU
☼ A high performance
C8051 MCU by Silicon
Laboratories™—
C8051F120.
☼ On-chip PLL, the peak speed of the
chip can reach as high as 100MIPS.
☼ A 2-cycle 16×16 MAC engine
accelerates the computation
☼ Pipelined instruction
architecture 8051 core
enables it to execute
most of instruction set in
only 1 or 2 system clocks.
☼ Rich analog on-chip
sources a 12-bit, 8-
channel, 100kHz sample
rate ADC, two 12-bit
DACs, two analog
comparators, a voltage
reference, etc.
SOFTWARE DESIGN
A. ADC0_ISR( )
B. WindowCalc( )
C. Bit_Reverse( )
D. Int_FFT( )
E. Spectrum_Display( )
A. ADC0_ISR( )
☼ Conversation is initiated when a Timer3 overflow happens.
☼ The data is then stored in the ADC0H :ADC0L registers.
☼ The overflow interval of Timer3 is determined by a configurable
macro variable SAMPLE_RATE .
B. WindowCalc( )
☼ Pre-calculated
The window coefficients are pre-calculated and stored in the header
file FFT_Code_Tables.h. The type define variable WINDOW_TYPE
can be selected from 0 to 4.
☼ Single-ended to differential
The function also converts the single-ended data collected by ADC0
into differential, in order to remove the DC component of the input
signal. The process is carried out by XOR the input data with 0x8000,
which has the same effect with subtracting 32768 from the input
data, so that the data ranges from 32752 to -32768.
C. Bit_Reverse( )
☼ To save data storage space, only half of the bit-reverse
array is stored, the other half is useless for the data will be
exchanged by the first half of operation.
☼ For example, an 8-point FFT may use the following bit-
reverse array:
BRTable[ ]={0,2,1,3};
And the sentence NewIndex=BRTable[PreviousIndex]*2
will help us location the nth reversed index.
D. Int_FFT( )
Start
Stage=0
Group=0
Butterfly=0
Butterfly
Computation
Butterfly
finished?
Group
Finished?
Stage+=1
Group=0
Stage
Finished?
End
Y
N
Butterfly+=1
Group+=1
Butterfly=0
Y
Y
N
N
Butterfly
loop
Group
loop
Stage
loop
Re2)
sin(x)
-
Im2
(cos(x)
-
Im1
Im2
Re2)
sin(x)
-
Im2
(cos(x)
Im1
Im1
Im2)
sin(x)
Re2
(cos(x)
-
Re1
Re2
Im2)
sin(x)
Re2
(cos(x)
Re1
Re1
















where Re1 = ReArray[indexA]
Re2 = ReArray[indexB]
Im1 = ImArray[indexA]
Im2 = ImArray[indexB]
x =2×pi×(sin_index/NUM_FFT), in radians.
E. Spectrum_Display( )
The FFT result is in complex form, of which the real part is stored in
Real[], and the imaginary part is stored in Imag[]. Based on the
two arrays, the magnitude spectrum and phase spectrum can be
easily obtained. This software only calculates power spectrum of the
input signal. The spectrum is displayed on a 128×64 point LCD
screen.
EXPERIMENT RESULTS AND DISCUSSION
A. Function Change
B. Software Configuration Change
C. Property of Symmetry
A. Function Change
☼ Magnitude and Frequency Change of a Sinusoidal Signal
Fig.TR.1. A 2.5kHz 1.3V sine. Fig.TR.2 A 2.5kHz 2.0V sine.
Fig.TR.3 A 2.5kHz 2.0V sine. Fig.TR.4 A 5kHz 2.0V sine.
A. Function Change
☼ Wave Form Change
Fig.TR.5. Triangular signal. Fig.TR.6. Rectangular signal.
B. Software Configuration Change
Name of variable Function
NUM_FFT Number of points of FFT algorithm
SAMPLE_RATE Sampling rate of ADC0 in Hz
WINDOW_TYPE Type of windows
RUN_ONCE Program runs once when the value is 0,many times when
the value is non-zero.
B. Software Configuration Change
☼ NUM_FFT Change
Fig.TR.7. A 256-point square wave Fig.TR.8. A 128-point square wave
B. Software Configuration Change
☼ WINDOW_TYPE Change
Fig.TR.9. Rectangular without windowing. Fig.TR.10.Rectangular with Blackman window.
B. Software Configuration Change
☼ SAMPLE_RATE Change
Fig.TR.11. 5k sine at 40kHz sampling rate. Fig.TR.12. 5k sine at 20kHz sampling rate.
B. Software Configuration Change
☼ RUN_ONCE Change
To check the speed of the system, RUN_ONCE is set to zero. For
all audio signals at a sampling rate of 40kHz, the LCD screen
never blinks and a steady frequency spectrum of the input time
domain signals can be read without any obstacles. This proves the
real-time property of the system.
C. Property of Symmetry
Fig.TR.13. 2kHz square wave at full range. Fig.TR.14. 13kHz square wave at full range.
The real part of FFT output exhibits even symmetry and imaginary
part of FFT output exhibits odd symmetry. This results in the
symmetry of frequency spectrum. That is, for N-point FFT products,
point N/2+1 is the same as point N/2-1, point N/2+2 is the same as
point N/2-2, etc. To illustrate this property, set the full range of the
screen to 40kHz. Here are the results.
REFERENCES
[1] Edward W. Kanmen and Bonnie S. Heck,
Fundamentals of Signals and Systems: Using the Web
and MATLAB, 2nd ed. Pearson Education, 2002.
[2] Julius O. Smith Ⅲ, Mathematics of the Discrete
Fourier Transform (DFT) with Audio Applications, 2nd
ed. http://ccrma.stanford.edu/~jos/mdft/
[3] Junli Zheng, Signals and systems, 2nd ed. Higher
Education Press, 2000.
[4] AN142 “FFT Routines for the C8051F12X Family”,
Rev.1.1. Inc. ©Silicon Laboratories, 2003.
[5] “FFT Library-Module user’s Guide C28x Foundation
Software”. Inc. ©Texas Instruments, 2002.
Thank you!

More Related Content

PDF
IRJET- Low Complexity Pipelined FFT Design for High Throughput and Low Densit...
PDF
Res701 research methodology fft1
PDF
3 f3 3_fast_ fourier_transform
PDF
Design and Construction of Musical Lighting Water Fountain
PPT
PDF
Ff tand matlab-wanjun huang
PDF
Ff tand matlab-wanjun huang
PDF
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid
IRJET- Low Complexity Pipelined FFT Design for High Throughput and Low Densit...
Res701 research methodology fft1
3 f3 3_fast_ fourier_transform
Design and Construction of Musical Lighting Water Fountain
Ff tand matlab-wanjun huang
Ff tand matlab-wanjun huang
Fourier transforms & fft algorithm (paul heckbert, 1998) by tantanoid

Similar to 13486500-FFT.ppt (20)

PDF
IRJET- VLSI Architecture for Reversible Radix-2 FFT Algorithm using Programma...
PDF
IRJET- Implementation of Reversible Radix-2 FFT VLSI Architecture using P...
PDF
Dft and its applications
PDF
Synchronous Time and Frequency Domain Analysis of Embedded Systems
PDF
Welcome to International Journal of Engineering Research and Development (IJERD)
PPTX
07 lecture
PPT
Fast Fourier Transform (FFT) Algorithms in DSP
PDF
Bm33388392
PDF
Bm33388392
PPT
fft.ppt MATHEMATICS FOR ENGINEERING
PDF
Design of FFT Processor
PPT
Ch15 transforms
PPT
unit 11.ppt
PDF
journal for research
PPTX
1_4_propertiesOfDFT.pptx
PPT
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbdsp1.ppt
PPT
3. convolution fourier
PPT
Fft
PPTX
Fft analysis
IRJET- VLSI Architecture for Reversible Radix-2 FFT Algorithm using Programma...
IRJET- Implementation of Reversible Radix-2 FFT VLSI Architecture using P...
Dft and its applications
Synchronous Time and Frequency Domain Analysis of Embedded Systems
Welcome to International Journal of Engineering Research and Development (IJERD)
07 lecture
Fast Fourier Transform (FFT) Algorithms in DSP
Bm33388392
Bm33388392
fft.ppt MATHEMATICS FOR ENGINEERING
Design of FFT Processor
Ch15 transforms
unit 11.ppt
journal for research
1_4_propertiesOfDFT.pptx
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbdsp1.ppt
3. convolution fourier
Fft
Fft analysis
Ad

More from Pratik Gohel (20)

PPTX
introduction to ARM C programming language
PPT
EDGEDETECTION algorithm and theory for image processing
PPT
Introduction to Asic Design and VLSI Design
PPT
Information and Theory coding Lecture 18
PPT
introduction to machine learning 3c.pptx
PPTX
introduction to machine learning 3c-feature-extraction.pptx
PPTX
introduction to machine learning 3d-collab-filtering.pptx
PPTX
Introduction to embedded System.pptx
PPT
Lecture 3.ppt
PPT
710402_Lecture 1.ppt
PPTX
UNIT-2.pptx
PPTX
Interdependencies of IoT and cloud computing.pptx
PDF
Chapter1.pdf
PPTX
6-IoT protocol.pptx
PPTX
IOT gateways.pptx
PPTX
AVRTIMER.pptx
PPTX
C Programming for ARM.pptx
PPTX
ARM Introduction.pptx
PDF
PPT
machine learning.ppt
introduction to ARM C programming language
EDGEDETECTION algorithm and theory for image processing
Introduction to Asic Design and VLSI Design
Information and Theory coding Lecture 18
introduction to machine learning 3c.pptx
introduction to machine learning 3c-feature-extraction.pptx
introduction to machine learning 3d-collab-filtering.pptx
Introduction to embedded System.pptx
Lecture 3.ppt
710402_Lecture 1.ppt
UNIT-2.pptx
Interdependencies of IoT and cloud computing.pptx
Chapter1.pdf
6-IoT protocol.pptx
IOT gateways.pptx
AVRTIMER.pptx
C Programming for ARM.pptx
ARM Introduction.pptx
machine learning.ppt
Ad

Recently uploaded (20)

PDF
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
PPTX
MAD Unit - 3 User Interface and Data Management (Diploma IT)
PDF
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
PPTX
Software Engineering and software moduleing
PPTX
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
PPTX
CT Generations and Image Reconstruction methods
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
20250617 - IR - Global Guide for HR - 51 pages.pdf
PPTX
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
PDF
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
PDF
Cryptography and Network Security-Module-I.pdf
PPTX
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
PDF
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
PDF
Present and Future of Systems Engineering: Air Combat Systems
PPTX
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
PPTX
Principal presentation for NAAC (1).pptx
PPTX
Cisco Network Behaviour dibuywvdsvdtdstydsdsa
PDF
Unit1 - AIML Chapter 1 concept and ethics
PPT
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
PDF
Principles of operation, construction, theory, advantages and disadvantages, ...
AIGA 012_04 Cleaning of equipment for oxygen service_reformat Jan 12.pdf
MAD Unit - 3 User Interface and Data Management (Diploma IT)
Unit I -OPERATING SYSTEMS_SRM_KATTANKULATHUR.pptx.pdf
Software Engineering and software moduleing
Chemical Technological Processes, Feasibility Study and Chemical Process Indu...
CT Generations and Image Reconstruction methods
distributed database system" (DDBS) is often used to refer to both the distri...
20250617 - IR - Global Guide for HR - 51 pages.pdf
A Brief Introduction to IoT- Smart Objects: The "Things" in IoT
LOW POWER CLASS AB SI POWER AMPLIFIER FOR WIRELESS MEDICAL SENSOR NETWORK
Cryptography and Network Security-Module-I.pdf
Chapter 2 -Technology and Enginerring Materials + Composites.pptx
VTU IOT LAB MANUAL (BCS701) Computer science and Engineering
Present and Future of Systems Engineering: Air Combat Systems
CN_Unite_1 AI&DS ENGGERING SPPU PUNE UNIVERSITY
Principal presentation for NAAC (1).pptx
Cisco Network Behaviour dibuywvdsvdtdstydsdsa
Unit1 - AIML Chapter 1 concept and ethics
Chapter 1 - Introduction to Manufacturing Technology_2.ppt
Principles of operation, construction, theory, advantages and disadvantages, ...

13486500-FFT.ppt

  • 1. Fast Fourier Transform Computation Using a C8051 MCU Fan Wang Huazhong University of Science & Technology
  • 2. Photo of the System
  • 3. Abstract ☼ A method of calculating FFT using a C8051 MCU is introduced in this paper. The software is aimed at computational efficiency and accuracy. ☼ By three key techniques: (1)avoidance of multiplication whenever possible; (2)16-bit integer storage; (3)on-chip PLL, a real-time audio spectrum is achieved. ☼ The results are displayed on a LCD screen and carefully analyzed. Basic theories of FFT and common problems in practice are discussed in detail.
  • 4. BACKGROUNDS A. Discrete Fourier Transform and Fast Fourier Transform B. FFT Bit-Reversal Algorithm C. Anti-aliasing Filtering and Windowing D. Function Overview of the C8051 MCU
  • 5. A. Discrete Fourier Transform and Fast Fourier Transform , ) ( ) ( 1 0     N n nk N W n x k X 1 ,... 2 , 1 , 0   N k N j N e W / 2   ☼ For a length N complex sequence x(n), n=0,1,2,…N-1, the discrete Fourier transform(DFT) is defined by where ☼ According to periodicity and symmetry ) ( ) ( ) ( k H W k G k X k N   1 2 / ,... 2 , 1 , 0   N k ) ( ) ( ) 2 / ( k H W k G N k X k N    1 2 / ,... 2 , 1 , 0   N k     1 2 0 2 / ) 2 ( ) ( N n kn N W n x k G      1 2 0 2 / ) 1 2 ( ) ( N n nk N W n x k H where , .
  • 6. ) 0 ( ) 0 ( ) 0 ( 0 4 H W G X   ) 1 ( ) 1 ( ) 1 ( 1 4 H W G X   ) 0 ( ) 0 ( ) 2 ( 0 4 H W G X   ) 1 ( ) 1 ( ) 3 ( 1 4 H W G X   A. Discrete Fourier Transform and Fast Fourier Transform We have the FFT process as the following: (N=4) (N=8)
  • 7. B.FFT Bit-Reversal Algorithm Previous Data Previous Index New Index Desired Data x(0) 000 000 x(0) x(1) 001 100 x(4) x(2) 010 010 x(2) x(3) 011 110 x(6) x(4) 100 001 x(1) x(5) 101 101 x(5) x(6) 110 011 x(3) x(7) 111 111 x(7)
  • 8. C. Anti-aliasing Filtering and Windowing ☼ Anti-aliasing Filtering Solution: A passive low-pass filter.
  • 9. C. Anti-aliasing Filtering and Windowing ☼ Windowing
  • 10. C. Anti-aliasing Filtering and Windowing ☼ Windowing Type Equation 0: None(Rectangular) W(n)=1 1: Triangular W(n)=n/(N/2) (0≤n≤N/2) W(n)=2-n/(N/2) (N/2<n<N) 2: Hanning W(n)=0.5-0.5cos(2πn/N) 3: Hamming W(n)=0.54-0.46cos(2πn/N) 4: Blackman W(n) = 0.42 - 0.5cos(2πn / N) +0.08cos(4πn / N)
  • 11. D. Function Overview of the C8051 MCU ☼ A high performance C8051 MCU by Silicon Laboratories™— C8051F120. ☼ On-chip PLL, the peak speed of the chip can reach as high as 100MIPS. ☼ A 2-cycle 16×16 MAC engine accelerates the computation ☼ Pipelined instruction architecture 8051 core enables it to execute most of instruction set in only 1 or 2 system clocks. ☼ Rich analog on-chip sources a 12-bit, 8- channel, 100kHz sample rate ADC, two 12-bit DACs, two analog comparators, a voltage reference, etc.
  • 12. SOFTWARE DESIGN A. ADC0_ISR( ) B. WindowCalc( ) C. Bit_Reverse( ) D. Int_FFT( ) E. Spectrum_Display( )
  • 13. A. ADC0_ISR( ) ☼ Conversation is initiated when a Timer3 overflow happens. ☼ The data is then stored in the ADC0H :ADC0L registers. ☼ The overflow interval of Timer3 is determined by a configurable macro variable SAMPLE_RATE .
  • 14. B. WindowCalc( ) ☼ Pre-calculated The window coefficients are pre-calculated and stored in the header file FFT_Code_Tables.h. The type define variable WINDOW_TYPE can be selected from 0 to 4. ☼ Single-ended to differential The function also converts the single-ended data collected by ADC0 into differential, in order to remove the DC component of the input signal. The process is carried out by XOR the input data with 0x8000, which has the same effect with subtracting 32768 from the input data, so that the data ranges from 32752 to -32768.
  • 15. C. Bit_Reverse( ) ☼ To save data storage space, only half of the bit-reverse array is stored, the other half is useless for the data will be exchanged by the first half of operation. ☼ For example, an 8-point FFT may use the following bit- reverse array: BRTable[ ]={0,2,1,3}; And the sentence NewIndex=BRTable[PreviousIndex]*2 will help us location the nth reversed index.
  • 17. E. Spectrum_Display( ) The FFT result is in complex form, of which the real part is stored in Real[], and the imaginary part is stored in Imag[]. Based on the two arrays, the magnitude spectrum and phase spectrum can be easily obtained. This software only calculates power spectrum of the input signal. The spectrum is displayed on a 128×64 point LCD screen.
  • 18. EXPERIMENT RESULTS AND DISCUSSION A. Function Change B. Software Configuration Change C. Property of Symmetry
  • 19. A. Function Change ☼ Magnitude and Frequency Change of a Sinusoidal Signal Fig.TR.1. A 2.5kHz 1.3V sine. Fig.TR.2 A 2.5kHz 2.0V sine. Fig.TR.3 A 2.5kHz 2.0V sine. Fig.TR.4 A 5kHz 2.0V sine.
  • 20. A. Function Change ☼ Wave Form Change Fig.TR.5. Triangular signal. Fig.TR.6. Rectangular signal.
  • 21. B. Software Configuration Change Name of variable Function NUM_FFT Number of points of FFT algorithm SAMPLE_RATE Sampling rate of ADC0 in Hz WINDOW_TYPE Type of windows RUN_ONCE Program runs once when the value is 0,many times when the value is non-zero.
  • 22. B. Software Configuration Change ☼ NUM_FFT Change Fig.TR.7. A 256-point square wave Fig.TR.8. A 128-point square wave
  • 23. B. Software Configuration Change ☼ WINDOW_TYPE Change Fig.TR.9. Rectangular without windowing. Fig.TR.10.Rectangular with Blackman window.
  • 24. B. Software Configuration Change ☼ SAMPLE_RATE Change Fig.TR.11. 5k sine at 40kHz sampling rate. Fig.TR.12. 5k sine at 20kHz sampling rate.
  • 25. B. Software Configuration Change ☼ RUN_ONCE Change To check the speed of the system, RUN_ONCE is set to zero. For all audio signals at a sampling rate of 40kHz, the LCD screen never blinks and a steady frequency spectrum of the input time domain signals can be read without any obstacles. This proves the real-time property of the system.
  • 26. C. Property of Symmetry Fig.TR.13. 2kHz square wave at full range. Fig.TR.14. 13kHz square wave at full range. The real part of FFT output exhibits even symmetry and imaginary part of FFT output exhibits odd symmetry. This results in the symmetry of frequency spectrum. That is, for N-point FFT products, point N/2+1 is the same as point N/2-1, point N/2+2 is the same as point N/2-2, etc. To illustrate this property, set the full range of the screen to 40kHz. Here are the results.
  • 27. REFERENCES [1] Edward W. Kanmen and Bonnie S. Heck, Fundamentals of Signals and Systems: Using the Web and MATLAB, 2nd ed. Pearson Education, 2002. [2] Julius O. Smith Ⅲ, Mathematics of the Discrete Fourier Transform (DFT) with Audio Applications, 2nd ed. http://ccrma.stanford.edu/~jos/mdft/ [3] Junli Zheng, Signals and systems, 2nd ed. Higher Education Press, 2000. [4] AN142 “FFT Routines for the C8051F12X Family”, Rev.1.1. Inc. ©Silicon Laboratories, 2003. [5] “FFT Library-Module user’s Guide C28x Foundation Software”. Inc. ©Texas Instruments, 2002.