Arduino and FFT

Your source for all things Atmel.

Moderator: phalanx

iq66
Posts: 3
Joined: Tue Jan 05, 2010 9:20 pm

Re: FFT code

Post by iq66 » Tue Jan 05, 2010 9:23 pm

Hi
What compiler do you use to compile it?

I cannot get it to work in arduino ide.
Please explain.

Thank you

ptaa32
Posts: 6
Joined: Mon Jan 11, 2010 3:54 am
Location: Bergen, Norway

Post by ptaa32 » Mon Jan 11, 2010 5:31 am

Is there an easy way to get the assembly part into the Arduino IDE?

I would like to try getting a spectrum display on the S65 Shield.

ptaa32
Posts: 6
Joined: Mon Jan 11, 2010 3:54 am
Location: Bergen, Norway

Post by ptaa32 » Mon Jan 11, 2010 5:40 am

As an afterthought:

Guess it would be unpractical with all that inline assy.
The ideal would be as an earlier poster asked for: make a stand-alone library for the FFT.

Hope, hope .... :D

stevech
Support Volunteer
Posts: 2907
Joined: Sat Jun 05, 2004 8:51 pm
Location: USA, California

Post by stevech » Tue Jan 12, 2010 9:57 am

It would be good to change this code that is now in the timer interrupt service routine:

Code: Select all

	
SIGNAL(SIG_OVERFLOW0) { 
...
fft_input(capture, bfly_buff);
fft_execute(bfly_buff);
fft_output(bfly_buff, spektrum);
print_FFT(spektrum, NUM_SAMPLES/2);
to run in the main() code. It's unwise/risky to do library calls like (printf, etc) and do extensive function calls from an ISR - due to reentrancy. Indeed, the butterfly FFT calcs are called from the ISR.

ptaa32
Posts: 6
Joined: Mon Jan 11, 2010 3:54 am
Location: Bergen, Norway

Post by ptaa32 » Thu Jan 14, 2010 8:28 am

Just got the FFT up and running on the Arduino by using AVR Studio.

iq66
Posts: 3
Joined: Tue Jan 05, 2010 9:20 pm

fft

Post by iq66 » Tue Feb 02, 2010 3:21 pm

how did you get the code to compile?
what type of cable do you use for it?

thanx

ptaa32
Posts: 6
Joined: Mon Jan 11, 2010 3:54 am
Location: Bergen, Norway

Re: fft

Post by ptaa32 » Wed Feb 03, 2010 1:21 am

iq66 wrote:how did you get the code to compile?
what type of cable do you use for it?

thanx
I used AVR Studio.

What cable are you referring to?
If it is the prgramming cable, I used Atmel AVR ISP MkII on the 6-pin Arduino ISP connector.

iq66
Posts: 3
Joined: Tue Jan 05, 2010 9:20 pm

fft

Post by iq66 » Wed Feb 03, 2010 6:18 pm

Hi I compiled the code with AVR studio but it gave me 3 compile error. However, they are included in "ffft.h" header file.

fft_input(capture, bfly_buff);
fft_execute(bfly_buff);
fft_output(bfly_buff, spectrum);

How do I get the fundamental frequency from the fft code? I basically need to see the output on the serial terminal. I do not have an lcd display.

Thanx.[/quote]

ptaa32
Posts: 6
Joined: Mon Jan 11, 2010 3:54 am
Location: Bergen, Norway

Re: fft

Post by ptaa32 » Fri Feb 05, 2010 2:08 am

iq66 wrote:Hi I compiled the code with AVR studio but it gave me 3 compile error. However, they are included in "ffft.h" header file.

fft_input(capture, bfly_buff);
fft_execute(bfly_buff);
fft_output(bfly_buff, spectrum);

How do I get the fundamental frequency from the fft code? I basically need to see the output on the serial terminal. I do not have an lcd display.

Thanx.
[/quote]

Maybe you forgot to include the FFFT.S file?

maokh
Posts: 143
Joined: Sat May 21, 2005 7:49 pm
Contact:

Post by maokh » Tue Feb 09, 2010 11:41 pm

An FFT could be quite useful for other things. There was an attempt about 5 years back to directly decode WWVB on a microcontroller (60KHz time standard in the US), which wasn't entirely successful...but the person didn't really indicate why or even what one he/she was using. There is a 75KHz similar operation in europe.

Id imagine you'd connect the ADC to a loop antenna (perhaps with an op amp on the front end, optional crystal filter if WWVB doesnt come in strong in your location), mix in a PWM near its frequency to get it low in the baseband, and decode it with a low frequency bucket, there might be some success possible.

Its just some 1 bps signal where they cut the power 17dB (ASK) to indicate the type of bit. 17dB should show up with even the crudest of FFT resolutions.

It would be really cool with some wound wire on the ADC line though wouldn't it? you could practically build in a RTC into anything for almost zero cost. You wouldn't really need to run it much either to make use of one of the many arduino software RTC's. Sync when you need to.

daled
Posts: 4
Joined: Wed Feb 10, 2010 6:32 pm

Post by daled » Wed Feb 10, 2010 6:44 pm

ptaa32 wrote:As an afterthought:

Guess it would be unpractical with all that inline assy.
The ideal would be as an earlier poster asked for: make a stand-alone library for the FFT.

Hope, hope .... :D
Did you ever find (or make) a version of this code that can be used as a library in the Arduino SDE?

KreAture
Posts: 158
Joined: Thu Apr 24, 2008 2:57 pm

Post by KreAture » Sun Feb 14, 2010 4:35 pm

So, how many FFT's/second did you finally manage?

On ATMega64 at 16 MHz I can do 128 FFT in 13ms with conversion to phase/magnitude taking 8ms.

On the MSP430 at 16 MHz I can do a 128 FFT in 11ms with conversion to phase/magnitude taking 6ms.

chipaudette
Posts: 1
Joined: Sun Sep 18, 2016 4:25 pm

Re: Arduino and FFT

Post by chipaudette » Sun Sep 18, 2016 4:28 pm

Just in case anyone else is looking for FFT code, I did some benchmarking tests of FFT on different flavors of Arduino, and on a Teensy. My write-up below shows the relative speeds of the different boards. It also has a link to my GitHub for the FFT and benchmarking code:

https://openaudio.blogspot.com/2016/09/ ... speed.html

My results show that the Arduino Uno is, predictably, very very slow in doing FFTs. The Teensy (especially the new K66-based Teensy 3.6) is way better for such computational tasks.

Chip

Post Reply