Go Down

Topic: DUE's more advanced FFT capabilities (Read 7 times) previous topic - next topic

DuaneB

I am sure there are good 32 bit fixed point libraries, have a look and let us know.

Duane B

UnaClocker

There's always the Teensy 3.0, which has the DSP extensions in it's core.
Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

raalst

#7
Dec 31, 2012, 04:56 pm Last Edit: Dec 31, 2012, 08:01 pm by raalst Reason: 1
lots of explaining can be found in hardware/arduino/sam/system/CMSIS/CMSIS/Documentation/DSP_Lib/html/index.html

as far as I can see now it is suposed to work , only not with hardware support (like in the M4).
it is even supposed to work on the M0 !

exciting !

... but on second thought, be aware that this stuff is covered by a licence.

I got the sketch to pass the errors mentioned above, but it seems to need to link with an .a file.
does anybody know how I should build these CMSIS files into a library and add that to the Arduino IDE ?

my sketch until now (based on one of the examples, but duly botched while trying to get it to compile) :
Code: [Select]
#define ARM_MATH_CM3 // this selects right environment for arm_math.h on DUE
#include <arm_math.h>

#define TEST_LENGTH_SAMPLES 2048

static q31_t testOutput[TEST_LENGTH_SAMPLES/2]; // all types changed from f32 to q31 just to see if it mattered

uint32_t M = 0;

/* ------------------------------------------------------------------
* Global variables for FFT Bin Example
* ------------------------------------------------------------------- */
uint32_t fftSize = 1024;
uint32_t ifftFlag = 0;
uint32_t doBitReverse = 1;

/* Reference index at which max energy of bin ocuurs */
uint32_t refIndex = 213, testIndex = 0;

/* ----------------------------------------------------------------------
Test Input signal contains 10KHz signal + Uniformly distributed white noise
** ------------------------------------------------------------------- */

q31_t testInput_f32_10khz[TEST_LENGTH_SAMPLES] =
{  
-0.865129623056441, 0.000000000000000, -2.655020678073846, 0.000000000000000, 0.600664612949661, 0.000000000000000, 0.080378093886515, 0.000000000000000,
-2.899160484012034, 0.000000000000000, 2.563004262857762, 0.000000000000000, 3.078328403304206, 0.000000000000000, 0.105906778385130, 0.000000000000000,
-1.620990298572947, 0.000000000000000, -1.085103073196045, 0.000000000000000, 0.738606361195386, 0.000000000000000,
-2.097831202853255, 0.000000000000000, 2.711952282071310, 0.000000000000000, 1.498539238246888, 0.000000000000000, 1.317457282535915, 0.000000000000000,
-0.302765938349717, 0.000000000000000, -0.044623707947201, 0.000000000000000, 2.337405215062395, 0.000000000000000, -3.980689173859100, 0.000000000000000,

};

void setup() {
 Serial.begin(19200);
}

void loop() {
     
   
      /** \example arm_fft_bin_example_f32.c
 */  

arm_status status;
arm_cfft_radix4_instance_q31 S;
q31_t maxValue;

status = ARM_MATH_SUCCESS;

/* Initialize the CFFT/CIFFT module */  
status = arm_cfft_radix4_init_q31(&S, fftSize, ifftFlag, doBitReverse);

/* Process the data through the CFFT/CIFFT module */
arm_cfft_radix4_q31(&S, testInput_f32_10khz);


/* Process the data through the Complex Magnitude Module for  
calculating the magnitude at each bin */
arm_cmplx_mag_q31(testInput_f32_10khz, testOutput, fftSize);  

/* Calculates maxValue and returns corresponding BIN value */
arm_max_q31(testOutput, fftSize, &maxValue, &testIndex);

if(testIndex !=  refIndex)
{
status = ARM_MATH_TEST_FAILURE;
}

/* ----------------------------------------------------------------------
** Loop here if the signals fail the PASS check.
** This denotes a test failure
** ------------------------------------------------------------------- */

if( status != ARM_MATH_SUCCESS)
{
while(1);
}

   while(1);                             /* main function does not return */
   
}


raalst


PakARD


lots of explaining can be found in hardware/arduino/sam/system/CMSIS/CMSIS/Documentation/DSP_Lib/html/index.html

as far as I can see now it is suposed to work , only not with hardware support (like in the M4).
it is even supposed to work on the M0 !

exciting !

... but on second thought, be aware that this stuff is covered by a licence.

I got the sketch to pass the errors mentioned above, but it seems to need to link with an .a file.
does anybody know how I should build these CMSIS files into a library and add that to the Arduino IDE ?

my sketch until now (based on one of the examples, but duly botched while trying to get it to compile) :
Code: [Select]
#define ARM_MATH_CM3 // this selects right environment for arm_math.h on DUE
#include <arm_math.h>

#define TEST_LENGTH_SAMPLES 2048

static q31_t testOutput[TEST_LENGTH_SAMPLES/2]; // all types changed from f32 to q31 just to see if it mattered

uint32_t M = 0;

/* ------------------------------------------------------------------
* Global variables for FFT Bin Example
* ------------------------------------------------------------------- */
uint32_t fftSize = 1024;
uint32_t ifftFlag = 0;
uint32_t doBitReverse = 1;

/* Reference index at which max energy of bin ocuurs */
uint32_t refIndex = 213, testIndex = 0;

/* ----------------------------------------------------------------------
Test Input signal contains 10KHz signal + Uniformly distributed white noise
** ------------------------------------------------------------------- */

q31_t testInput_f32_10khz[TEST_LENGTH_SAMPLES] =
{  
-0.865129623056441, 0.000000000000000, -2.655020678073846, 0.000000000000000, 0.600664612949661, 0.000000000000000, 0.080378093886515, 0.000000000000000,
-2.899160484012034, 0.000000000000000, 2.563004262857762, 0.000000000000000, 3.078328403304206, 0.000000000000000, 0.105906778385130, 0.000000000000000,
-1.620990298572947, 0.000000000000000, -1.085103073196045, 0.000000000000000, 0.738606361195386, 0.000000000000000,
-2.097831202853255, 0.000000000000000, 2.711952282071310, 0.000000000000000, 1.498539238246888, 0.000000000000000, 1.317457282535915, 0.000000000000000,
-0.302765938349717, 0.000000000000000, -0.044623707947201, 0.000000000000000, 2.337405215062395, 0.000000000000000, -3.980689173859100, 0.000000000000000,

};

void setup() {
 Serial.begin(19200);
}

void loop() {
     
   
      /** \example arm_fft_bin_example_f32.c
 */  

arm_status status;
arm_cfft_radix4_instance_q31 S;
q31_t maxValue;

status = ARM_MATH_SUCCESS;

/* Initialize the CFFT/CIFFT module */  
status = arm_cfft_radix4_init_q31(&S, fftSize, ifftFlag, doBitReverse);

/* Process the data through the CFFT/CIFFT module */
arm_cfft_radix4_q31(&S, testInput_f32_10khz);


/* Process the data through the Complex Magnitude Module for  
calculating the magnitude at each bin */
arm_cmplx_mag_q31(testInput_f32_10khz, testOutput, fftSize);  

/* Calculates maxValue and returns corresponding BIN value */
arm_max_q31(testOutput, fftSize, &maxValue, &testIndex);

if(testIndex !=  refIndex)
{
status = ARM_MATH_TEST_FAILURE;
}

/* ----------------------------------------------------------------------
** Loop here if the signals fail the PASS check.
** This denotes a test failure
** ------------------------------------------------------------------- */

if( status != ARM_MATH_SUCCESS)
{
while(1);
}

   while(1);                             /* main function does not return */
   
}




Could you finally get this library working under Q31? I can in Q15 and f32, but not under Q31!!!
Thank you

Go Up