Go Down

Topic: 16-bit FFT on Arduino (Read 6 times) previous topic - next topic


Progmem store a data (sin table) to code memory space (flash), 32k
LUT is very convenient way to improve math performance on 8-bit controllers, I used progmem also for  Hamming and Bit-Reverse tables in other my projects ( N=512 FFT ).
For OP, actually, he doesn't need high speed math, for 1 sec using regular sin function code is just fine:
Code: [Select]

int sin_value  = 16383 *sin(( angle * frequecy *   2 * 3.1415926535  / FFT_SIZE)
int cos_value  = 16383 *cos(( angle * frequecy *   2 * 3.1415926535  / FFT_SIZE)


to be optimized to
Code: [Select]

float alpha = angle * frequecy *   2 * 3.1415926535  / FFT_SIZE;
int sin_value  = 16383 *sin(alpha);
int cos_value  = 16383 *cos(alpha);
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)


I've written the LUT in the program memory, the 16-bit code posted is the original. Also loaded the values from the LUT correctly.

Seems like the elm-chan has some LUT's for 256 points so I will use them to save space (no need for larger number of FFT points for now).

Magician, THANK YOU !
Your project was in my bookmarks but I never thought about looking at the code.

Will try it in the next few days and report back. It's weird that it doesn't do MULS_16x16_32 since it does 8x8_16...
Anyway, I don't need dramatic speed so if it works, it's good. Precision is what I need :)

Thank you again !


elm-chan's sine table is combination of sine / cos, so you will to have to edit it.
Other option would be generate table with excell / libreOffice or load your arduino with simple sketch and it'd print out on serial monitor for you.
Code: [Select]

    for(int i=0; i<192; i++) // <<<--- size
      printf("%+5d",(int)((16383 * sin(2*M_PI * i / 256))  ));
       if (i<192-1)     printf(",");
       if ((i+1)%8 == 0) printf("\n");


It's easier for me to write a C program to output the values in a file, thanks for the idea :)

I can't remember now what the LUT values are in elm-chan's file, it was late and I just glimpsed it. If they are mixed, cos just trails sin by 90* so it's not a big problem to extract the values.

Go Up