Hi, guys

I'm developing some fixed-point algorithm that requires a relatively large size FFT and IFFT (like 2048 pts or more).

I tried the rfft_fr16 and ifft_fr16 functions and found that when the FFT size is large, the error got large too.

The picture attached here is the result of 2048 pts random input, do FFT, then IFFT, then compute the error between the output and the input. The maximum of error is about 1024 (N/2), which is unacceptable. (The code to reproduce this result is also attached.)

**Is there any way to reduce the error of large size FFT?** (But except using floating-point)

I'm thinking about increasing the bit length of fft_out might work. So **where can I get such FFT & IFFT functions which use 32-bit data to represent the frequency domain data?**

Best regards

Ben

Hi Ben,

The following changes will result in a much improved error count:

/* (11 for a 2048 point FFT or 5 if FFT Size = 32) */

#define FFT_POW2 11

void main(void)

{

int i, blk_exp_r, blk_exp_i;

twidfftrad2_fr16(twiddle, N_FFT);

rfft_fr16(in, fft_out, twiddle, 1, N_FFT, &blk_exp_r, DYNAMIC);

printf("FFT block exponent = %d\n", blk_exp_r);

ifft_fr16(fft_out, ifft_out, twiddle, 1, N_FFT, &blk_exp_i, DYNAMIC);

printf("IFFT block exponent = %d\n", blk_exp_i);

for (i = 0; i < N_FFT; ++i) {

out[i] = ifft_out[i].re;

err[i] = out[i] - (in[i] >> (blk_exp+r + blk_exp_i - FFT_POW2);

}

}

Computing the real forward FFT using dynamic scaling will preserve the maximum number of significant digits in the result while preventing overflow. For the inverse FFT, dynamic scaling is required to prevent overflow. When computing the error, the input signal needs to be shift corrected first as illustrated above.

In your example, the inverse FFT failed to produce the expected output because the frequency domain signal generated by the rfft function lacked sufficient information to do so (due to static scaling dividing intermediate results by 2 at every stage of the RFFT).

If wish to investigate matters using 32-bit fractional numbers, upgrading to Update 9 for VisualDSP++5.0 will provide you with equivalent fract32 library functions. This update will also give you access to Embedded C which adds fixed-point types as native types to the compiler.

Andreas