📄 readme.txt
字号:
10/31/2008
This is a demo of A/D conversion, Fast Fourier Transform (by Chan), and displaying the signal and
FFT result on LCD (128x64), developed with mega128 and WinAVR-20080610.
The FFT function (ffft.h, ffft.s) used here: Fixed-point FFT routines for megaAVRs, (C)ChaN, 2005
for more infomation, go to http://www.embedds.com/avr-audio-spectrum-monitor-on-graphical-lcd/
A short clip shows how it works: http://www.youtube.com/watch?v=GTb6RsJd2yc
=============================
file descriptions:
=============================
main.c the main function.
adc.c signal capturing (adc_capture) and call for FFT (ffft.h, ffft.s).
LCD.c driver for graphic LCD 128x64 (LG128643).
!! Change the definition of hardware connection in LCD.h to fit yours.
uart.c send out debug information via USART1 (print("something")). It is optional.
If USART0 is used instead, there are lots of messy outputs during ISP.
ffft.h, ffft.s the FFT routine.
Makefile "make" and "make clean"
"make isp" -- I use PONYPROG2000 and parallel port to ISP. Probably the ISPEXE needs to be changed accordingly.
=============================
Technological description
=============================
In this demo, the program runs in a loop which is composed of three steps: A/D conversion, Fourier transform, and displaying the signal and FFT result on the LCD.
1) The analog signal (0~5V) is input from the PF port of mega128. The ADC sample rate is set at its maximum: start conversion, query the state, read out and store the result (10-bit). The ADC clock is set to XTAL frequency/128 and "A normal conversion takes 13 ADC clock cycles", which means the sample rate is about 9.6 kHz. Considering the reading and storing operations between each conversion, the actual sample rate should be less. In the real test, it works well with sine wave signal of about 8.5 kHz.
After conversion, the analog signal (0 ~ 5V) is converted to -2.5 ~ +2.5V for Fourier transform and display.
Quantitative analysis may be necessary for more precise conversion results. The data sheet of ATmega128 offer some solutions for better conversion and higher ADC sample rate.
2) Chan developed this nice FFT routines for megaAVRs. Number of sample points (FFT_N) can be change in ffft.h.
3) The analog signal and its FFT results are first transfered to a "video ram", considering the forms they look like (curves, or spectrum bars). Then the "video ram" was written to the LCD, considering the mapping relation between the addresses of registers and the positions on the screen. Because the LCD is a low speed peripheral, most of the time is spent on looping to generate control signals. About 100 fps can be achieved with this method. Task switching can be used to take most out of the processing power of the microcontroller.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -