# Zoom FFT problem with frequency Shift

Started by June 18, 2009
Hi all
I' m new here and I need for advice and example for zoom FFT. I wrote C code for Zoom FFT for BF532 dsp processor, but doesn't work. I can find my wrongs and I have ground knowledges in C language. I can't make a frequency shift, in my algorithm I multiply my signal x with sin(2*pi*f) for imaginary part and cos(2*pi*f)for real part. Then I make complex FFT and for input signal I give real and imaginery parts. After CFFT I make IFFT, so I must see new shift signal but I don't see shifted sinwafe form.
This is my C code. I hope you can help me with advice and example.
#include
#include
#include
#include
#include

#define K 92.16 //frquency for sin waveform

#define Pi 3.1415
#define FFT_size 1024
#define N_FFT 1024

#define a0 0.756383879 //coefficient for low pass filter 500Hz
#define b1 0.24361612 // coeficient for low pass filter 500Hz

//#define a0 0.385888817 1kHz
//#define b1 0.614111182 1kHz

//#define a0 0.000630914
//#define b1 0.999369085

#define V1 2 //frquency one (left frequency)
#define V2 102.4
#define Fn 31.030
#define N 1000

//coefficients FFT
double F ;//masiv za FFT
fract16 input [FFT_size];
complex_fract16 out [FFT_size];
complex_fract16 twiddle [FFT_size/2];
int blk_exp;

//coefficients CFFT
double C ;
complex_fract16 in[N_FFT];
complex_fract16 out_cfft [N_FFT];
complex_fract16 out_ifft[N_FFT];
double I ;

//areas for signals
double c ;
double s ;
double y ;
double x ;
double Re ;
double Im ;

//void rfft_example (void);
void singen (void);
void filter (void);
void shift (void);
void shift1 (void);
void shift2 (void);
void CFFT (void);
//signal sin waveform
void singen (void)
{
int i;
for(i=0;i<2048;i++)
x[i]=(20*sin(2*Pi*K*i/2048));

}
/*void rfft_example (void)
{
int i;
//generirane na entry signal//
for (i=0;i {
input[i]=(10* sin(2*Pi*K*i/FFT_size));
}

//Zapalvane na tablicata//
//iz4islqvane na FFT//
rfft_fr16 (input, out, twiddle, 1, FFT_size, &blk_exp, 1);
for(i=0;i {
F[i]=(sqrt(out[i].re*out[i].re + out[i].im*out[i].im));
}
}*/
//multiplication signal x[i] with Real and Imaginery part
void signalshift (void)
{
int i;
for(i=0;i<4096;i++)
Re[i]=x[i]*cos(Pi*i*V1);
for(i=0;i<2048;i++)
Im[i]=x[i]*sin(Pi*i*V1);
}

// Re and Im, I execute CFFT for receiving of shift signal (shift on left)

void CFFT (void)
//void cfft_fr16 (const complex_fract16 *input, complex_fract16 *output,const complex_fract16 *twiddle_table, int twiddle_stride, int fft_size, int *block_exponent, int scale_method)
{
int i;
//Input signal for CFFT
for(i=0; i {

in[i].re=Re[i];
in[i].im=Im[i];
}
//populate twidd table
//compute Complex Fast Fourier Transform
cfft_fr16(in, out_cfft, twiddle, 1, N_FFT, &blk_exp, 0);

for(i=0; i {
C[i]=(sqrt(out_cfft[i].re*out_cfft[i].re - out_cfft[i].im*out_cfft[i].im));
}

ifft_fr16(out_cfft, out_ifft, twiddle, 1, N_FFT, &blk_exp, 0);

}

//this is my function for digital low pass filter from 1st order (RC prototype)
void filter (void)
{
int i;
y=0;
for (i=1;i<4096;i++)
y[i]=(a0*out_ifft[i]+b1*y[i-1]);
}

void main (void)
{
float b;
// rfft_example ();
singen ();
signalshift ();
CFFT ();
filter ();
while (1);
{
b++;
}

Regards!
Yanko
}