need help with FFT understanding

Go To Last Post
21 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Im not sure of your rules about live links, but over at this site: http://elm-chan.org/works/akilcd...

I found some audio spectrum monitor code for the LCD display.

Im not going to use an LCD though, im just going to output the bargraph data through the uart to a custom display controller that i'm making.

the issue is, im not sure how the "lvlbuff" SRAM is mapped out. If someone is experianced in this code, can someone explain this in some more detail?

"quote from ASM"

rfsh_bars: ;Draw spectrum bars
sbrc _Flags, 1 ;Skip refresh if in pause.
ret ;/
ldi DL, LCD_H-8+1 ; (This routine refreshes LCD with bar length
ldiw B, 0 ; list on the LvlBuf[64]. 1st value is DC
rcall lcd_setadr ; component, 2nd value is fundamental freq
rcall ds_hl ; and last value is highest freq)

"end quote"

it says that lvlbuff is a list of some sort, but im not really clear on how its mapped out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

lvlbuff is actually an array of bytes. the harmonics are stored in ascending order.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yea, but what does each byte represent? im assuming each byte represents each frequency. But what does the value of each byte mean? im not exactly certain.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well that web site itself says that the bars represet 128 steps of 75Hz. First bar is 0Hz, next 75Hz, next 150Hz... second last 9525Hz, last 9600Hz

The height of the bars is clearly the amount of that frequency component in the input signal though what the vertical scale actually is, is not so obvious.

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

well that answers my question about the frequency mapping.

im talking about the lvlbuff register.

which i THINK is RAM 0064.

So, ram 0064 would be 75Hz value. 0065 would be the 150Hz value and so on? but what IS that value? is it the hight of the bar? i dont know.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes it looked like it was the height of the bar but what "units" that is representing I don't know

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

??

JChristoff
Illinois

Last Edited: Thu. Jan 6, 2011 - 06:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The FFT library for avr-gcc (avrfft.zip) that the author provided contains:
- fft.c
- fft.S

What does the fft.S file do?

i included my fft.c into my source code

#include "fft.c"

but what about the .S file what should i do with that, is it automatically linked when i include fft.c?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There must be something wrong with my car. There's a horrible roaring noise coming from under the hood. I looked in there and there's a big hot greasy hunk of steel in there. What is that for?

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:lol:

--

"If it wasn't for bad luck I'd have no luck at all"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

michaelg wrote:
but what about the .S file what should i do with that, is it automatically linked when i include fft.c?

.S files are assembler source files for the avr-as assembler. If you have a project using a Makefile created using Mfile in WinAVR then you already have the .c files listed on the SRC= line. Just add any .S files to the ASRC= line to have them also assembled and linked into the final program. If you don't you'll probably have been seeing linker errors saying "unresolved external reference to ...."

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another article about FFT's I've found useful is http://pdfserv.maxim-ic.com/en/ej/EJ57.pdf. It's not aimed specfically at the AVR but it provides a few useful hints/tips.

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

@Bob

Quote:
There must be something wrong with my car. There's a horrible roaring noise coming from under the hood. I looked in there and there's a big hot greasy hunk of steel in there. What is that for?

Bob, Thats the beast that consumes your fuel. Pif it out and walk to save on fuel & stop the noise, LOL.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I removed it. Much quieter and WAY better mileage. :mrgreen:

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm - bit of detour - FFT to Electric Car - :roll: :wink:

Ben
-Using IAR (& ocasionally CodeVision)
0.7734
1101111011000000110111101101

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The irony is that the FFT routine in assembler was in the fft.s file. A guy that wants to do FFTs should at least include the fft source code in his program if he expects it to work.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
.S files are assembler source files for the avr-as assembler. If you have a project using a Makefile created using Mfile in WinAVR then you already have the .c files listed on the SRC= line. Just add any .S files to the ASRC= line to have them also assembled and linked into the final program. If you don't you'll probably have been seeing linker errors saying "unresolved external reference to ...."

perfect thanks Clawson now i know what .S files are. before, i kept getting errors exactly as you said when i tried to compile.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:
There must be something wrong with my car. There's a horrible roaring noise coming from under the hood. I looked in there and there's a big hot greasy hunk of steel in there. What is that for?

At least yours is steel. I got this aluminum peice of crud in the toyota thats locked up tighter than a mother f'r

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sgomes wrote:
I removed it. Much quieter and WAY better mileage. :mrgreen:

you might have to pull a freddie flintstone manouver to get it up a hill though. :wink:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Um, Look at my tag line...

Go electric!
Happy electric car owner / builder

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wait till you have to replace batteries when they go bad. :)