Zoom FFT problem with frequency Shift

Started by yank...@abv.bg 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.

#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 [2048];//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 [2048];
complex_fract16 in[N_FFT];
complex_fract16 out_cfft [N_FFT];
complex_fract16 out_ifft[N_FFT];
double I [2048];

//areas for signals
double c [2048];
double s [4096];
double y [4096];
double x [2048];
double Re [2048];
double Im [2048];

//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;

/*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//
twidfftrad2_fr16(twiddle, FFT_size);
//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;

// 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 {

//populate twidd table
twidfftrad2_fr16(twiddle, N_FFT);
//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;
for (i=1;i<4096;i++)

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