DSPRelated.com
Forums

Verifying FFT Result

Started by B S June 29, 2010
BS-

> I plotted the result of FFT Magnitude using graph option in CCS, for
> 1KHz signal peak appears at 32nd and 224th
> samples respectively and the magnitudes are 7e5 for both peaks :D
>
> How can I calculate the exact amplitude and map it to 1 KHz
> frequency as of real time signal ?

700,000 / 128 is about 5500. Is this the peak value you get from your AIC23 codec when you apply a 1V sine input?

-Jeff

> ________________________________
> From: varoonian .
> To: B S
> Cc: c...
> Sent: Thu, July 1, 2010 1:41:02 AM
> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>
> B S,
>
> I don't quite understand you.
>
> Did you include the starting address, Sampling Frequency, Window Type and Buffer Size in the graph Properties Dialog
> Box as per your requirements ?
>
> Regards,
> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>
>>
>> >
>>
>>>>[Attachment(s) from B S included below]
>>Varoonian,
>>
>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the result.
>>
>>There is one confusion about choosing FFT magnitude option for viewing graph. I used FFT magnitude option when I was
>> sampling real time Sine Wave and that option was showing me peak at 1 KHz without using any FFT algorithm. In my
>> understadning FFT magnitude option in graph is calculating FFT again, therefore, peak is not present at 1Khz.
>>
>>I am attaching a plot obtained by Code Composer Studio graph option.
>>
>>Waiting for your comments.
>>
>>>
> ________________________________
> From: varoonian .
>>To: B S
>>Cc: c...
>>Sent: Tue, June 29, 2010 7:51:25 PM
>>Subject: Re: [c6x] Verifying FFT Result
>>
>> >
>>>B S,
>>Why don't you plot your output array using View-->Graph in CCS and check you're getting the peak at 1 KHz.
>>Regards,
>>>
>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> >>
>>>
>>>>>
>>>
>>>>>
>>>
>>>Hi Guys,
>>>
>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure that FFT algorithm is working fine, I
>>> want to verify my result. Can you please tell me how can I do this.
>>>
>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>
>>>Waiting for your quick response.
>>>
>>>BR,
>>>BS
>>>
>>>
>>--
>>Varun
>>
> --
> Varun

_____________________________________
B.S.

I notice that the array x1[] has not been initialized.
so the first output sequence is trash.
your display parameters are only set up to only accept 1 sample set.
so the display is the trash from the first sample set and not actual data.
I would suggest:
--separate input buffer, so continuing interrupts do not corrupt the sample data
--separate output buffer, so processing does not corrupt the output data
--modify the logic so that a output buffer that does not contain valid data is
not output.
--currently, there is only the time interval between two samples (1/8000 second)
to process the data; this will result in data being overwritten by the ongoing
interrupt events.
by separating the input/output buffers, then the processing will have approx
1/32 second (8000/256) to operate, with much less chance of data corruption.

If I were coding this application, I would use a ping/pong buffer scheme for
both the input of data and the output of the results. Then there should never
be a worry that data/results are being corrupted/overwritten. This assumes
there is enough time during 1/32 second to perform all the data
copying/processing.

If I were coding this application, I would minimize the number of CPU cycles
being absorbed by the handling of interrupt events, by using EDMA/DMA for both
the input of data and the output of the results. As it is currently
implemented, the majority of the CPU cycles are being used to handle the
interrupts rather than being used to process the data. By using ping/pong
buffering for both the input and output and by using EDMA/DMA for all I/O, only
2 interrupts per each 1/32 second interval would need to be handled rather than
the current 256 interrupts.

The sample application DSK_APP shows a method of implementing the EDMA/DMA
processing and ping/pong buffering of inputs and outputs. (it will need to be
modified slightly as you are not using the BIOS).

May I inquire why you used 32000.0 for a negative spike, as that is a positive
number is 32bit float format?

Also, I do not know if the call to FFT() also performs the bit unscrambling, if
not, then you will need to add that to your processing.

R. Williams

---------- Original Message -----------
From: B S
To: "varoonian ."
Cc: c...
Sent: Thu, 1 Jul 2010 00:58:25 -0700 (PDT)
Subject: Re: [c6x] Verifying FFT Result [1 Attachment]

> Hi Varoonian,
>
> Here you can see the parameters I included.
>
> Display Type: Single Time
> Start Address: x1 (contain FFT magnitude)
> Acquisition Buffer Size: 256 as of FFT Points
> Display Data Size: 256
> DSP Data Type: 32-bit Floating Point- I am not quite sure which one to
> choose here, I chosen this option because the variable x1 that contain
> FFT magnitude is floating point. Sampling Rate: 8000
>
> In the last email, plot has been obtained using FFT Magnitude option
> but this time its Single Time and I am getting peaks but not at 1KHz.
> You can see the attached plot. I am also copying piece of code which I
> used.
>
> #include "dsk6713_aic23.h"
> Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
> #include
> #define PTS 256 //# of points for FFT
> #define PI 3.14159265358979
> typedef struct {float real,imag;} COMPLEX;
> void FFT(COMPLEX *Y, int n); //FFT prototype
> float iobuffer[PTS]; //as input and output buffer
> float x1[PTS]; //intermediate buffer
> short i; //general purpose index variable
> short buffercount = 0; //number of new
> samples in iobuffer short flag = 0; //set
> to 1 by ISR when iobuffer full COMPLEX w[PTS];
> //twiddle constants stored in w COMPLEX samples[PTS];
> //primary working buffer
>
> main()
> {
> for (i = 0 ; i > {
> w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants
> w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants
> }
> comm_intr(); //init DSK, codec, McBSP
>
> while(1) //infinite loop
> {
> while (flag == 0) ; //wait until iobuffer is full
> flag = 0; //reset flag
> for (i = 0 ; i < PTS ; i++) //swap buffers
> {
> samples[i].real=iobuffer[i]; //buffer with new data
> iobuffer[i] = x1[i]; //processed frame to iobuffer
> }
> for (i = 0 ; i < PTS ; i++)
> samples[i].imag = 0.0; //imag components = 0
>
> FFT(samples,PTS); //call function FFT.c
>
> for (i = 0 ; i < PTS ; i++) //compute magnitude
> {
> // set x1 to contain the magnitude 9scaled) of transformed (processed) data
> x1[i] = sqrt(samples[i].real*samples[i].real
> +
> samples[i].imag*samples[i].imag);
> }
> x1[0] = 32000.0; //negative spike for reference
> } //end of infinite loop
>} //end of main
>
> interrupt void c_int11() //ISR
> {
> output_sample((short)(iobuffer[buffercount])); //out from
> iobuffer
iobuffer[buffercount++]=(float)((short)input_sample());
> //input to iobuffer
if (buffercount >= PTS) //if iobuffer full
{ buffercount = 0; //reinit buffercount
> flag = 1; //set flag
}
}
>
> Waiting for your response.
>
> BR,
> BS
>
> ________________________________
> From: varoonian .
> To: B S
> Cc: c...
> Sent: Thu, July 1, 2010 1:41:02 AM
> Subject: Re: [c6x] Verifying FFT Result
>
> B S,
>
> I don't quite understand you.
>
> Did you include the starting address, Sampling Frequency, Window Type
> and Buffer Size in the graph Properties Dialog Box as per your
> requirements ?
>
> Regards,
>
> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > >
> >
> >>
> >
> >>
> > [Attachment(s) from B S included below] >
> >
> >Varoonian,
> >
> >I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot
the result.
> >
> >There is one confusion about choosing FFT magnitude option for viewing graph.
I used FFT magnitude option when I was sampling real time Sine Wave and that
option was showing me peak at 1 KHz without using any FFT algorithm. In my
understadning FFT magnitude option in graph is calculating FFT again, therefore,
peak is not present at 1Khz.
> >
> >I am attaching a plot obtained by Code Composer Studio graph option.
> >
> >Waiting for your comments.
> >
> >
> >
> >
> >
> >>
> ________________________________
> From: varoonian .
> >To: B S
> >Cc: c6x@yahoogroups. com
> >Sent: Tue, June 29, 2010 7:51:25 PM
> >Subject: Re: [c6x] Verifying FFT Result
> >
> > >
> >
> >
> >>
> >
> >B S,
> >
> >
> >Why don't you plot your output array using View-->Graph in CCS and check
you're getting the peak at 1 KHz.
> >
> >
> >Regards,
> >
> >
> >>
> >On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
> >
> >>>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> >>
> >>
> >>>>
> >>
> >>>>
> >>
> >>Hi Guys,
> >>
> >>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be
sure that FFT algorithm is working fine, I want to verify my result. Can you
please tell me how can I do this.
> >>
> >>Sampling frequency used is 8KHz and no. of FFT points are 256.
> >>
> >>Waiting for your quick response.
> >>
> >>BR,
> >>BS
> >>
> >>
> >
> >
> >--
> >Varun
> >
> > --
> Varun
------- End of Original Message -------

_____________________________________
Jeff,

Yes, I am getting the same value. I don't understand what does it mean.. can you please elaborate ?

BS

________________________________
From: Jeff Brower
To: BS
Cc: c...
Sent: Thu, July 1, 2010 7:42:23 PM
Subject: Re: [c6x] Verifying FFT Result

BS-

> I plotted the result of FFT Magnitude using graph option in CCS, for
> 1KHz signal peak appears at 32nd and 224th
> samples respectively and the magnitudes are 7e5 for both peaks :D
>
> How can I calculate the exact amplitude and map it to 1 KHz
> frequency as of real time signal ?

700,000 / 128 is about 5500. Is this the peak value you get from your AIC23 codec when you apply a 1V sine input?

-Jeff

> ________________________________
> From: varoonian .
> To: B S
> Cc: c...
> Sent: Thu, July 1, 2010 1:41:02 AM
> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>
> B S,
>
> I don't quite understand you.
>
> Did you include the starting address, Sampling Frequency, Window Type and Buffer Size in the graph Properties Dialog
> Box as per your requirements ?
>
> Regards,
> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>
>>
>> >
>>
>>>>[Attachment(s) from B S included below]
>>Varoonian,
>>
>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the result.
>>
>>There is one confusion about choosing FFT magnitude option for viewing graph. I used FFT magnitude option when I was
>> sampling real time Sine Wave and that option was showing me peak at 1 KHz without using any FFT algorithm. In my
>> understadning FFT magnitude option in graph is calculating FFT again, therefore, peak is not present at 1Khz.
>>
>>I am attaching a plot obtained by Code Composer Studio graph option.
>>
>>Waiting for your comments.
>>
>>>
> ________________________________
> From: varoonian .
>>To: B S
>>Cc: c...
>>Sent: Tue, June 29, 2010 7:51:25 PM
>>Subject: Re: [c6x] Verifying FFT Result
>>
>> >
>>>B S,
>>Why don't you plot your output array using View-->Graph in CCS and check you're getting the peak at 1 KHz.
>>Regards,
>>>
>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> >>
>>>
>>>>>
>>>
>>>>>
>>>
>>>Hi Guys,
>>>
>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure that FFT algorithm is working fine, I
>>> want to verify my result. Can you please tell me how can I do this.
>>>
>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>
>>>Waiting for your quick response.
>>>
>>>BR,
>>>BS
>>>
>>>
>>--
>>Varun
>>
> --
> Varun
R. Williams,

You are absolutelt right about advantages of using EDMA but at the moment I am more interested to see FFT algorithm working fine. Once this will be done, I ll try to switch to EDMA.

May I inquire why you used 32000.0 for a negative spike, as that is a positive number is 32bit float format?

Its just for referencing that helps to see the result on Oscilloscope.

FFT() performs bit unscrambling inside the FFT code.

BS

________________________________
From: Richard Williams
To: B S ; varoonian .
Cc: c...
Sent: Thu, July 1, 2010 8:32:34 PM
Subject: Re: [c6x] Verifying FFT Result

B.S.

I notice that the array x1[] has not been initialized.
so the first output sequence is trash.
your display parameters are only set up to only accept 1 sample set.
so the display is the trash from the first sample set and not actual data.
I would suggest:
--separate input buffer, so continuing interrupts do not corrupt the sample data
--separate output buffer, so processing does not corrupt the output data
--modify the logic so that a output buffer that does not contain valid data is
not output.
--currently, there is only the time interval between two samples (1/8000 second)
to process the data; this will result in data being overwritten by the ongoing
interrupt events.
by separating the input/output buffers, then the processing will have approx
1/32 second (8000/256) to operate, with much less chance of data corruption.

If I were coding this application, I would use a ping/pong buffer scheme for
both the input of data and the output of the results. Then there should never
be a worry that data/results are being corrupted/overwritten. This assumes
there is enough time during 1/32 second to perform all the data
copying/processing.

If I were coding this application, I would minimize the number of CPU cycles
being absorbed by the handling of interrupt events, by using EDMA/DMA for both
the input of data and the output of the results. As it is currently
implemented, the majority of the CPU cycles are being used to handle the
interrupts rather than being used to process the data. By using ping/pong
buffering for both the input and output and by using EDMA/DMA for all I/O, only
2 interrupts per each 1/32 second interval would need to be handled rather than
the current 256 interrupts.

The sample application DSK_APP shows a method of implementing the EDMA/DMA
processing and ping/pong buffering of inputs and outputs. (it will need to be
modified slightly as you are not using the BIOS).

May I inquire why you used 32000.0 for a negative spike, as that is a positive
number is 32bit float format?

Also, I do not know if the call to FFT() also performs the bit unscrambling, if
not, then you will need to add that to your processing.

R. Williams

---------- Original Message -----------
From: B S
To: "varoonian ."
Cc: c...
Sent: Thu, 1 Jul 2010 00:58:25 -0700 (PDT)
Subject: Re: [c6x] Verifying FFT Result [1 Attachment]

> Hi Varoonian,
>
> Here you can see the parameters I included.
>
> Display Type: Single Time
> Start Address: x1 (contain FFT magnitude)
> Acquisition Buffer Size: 256 as of FFT Points
> Display Data Size: 256
> DSP Data Type: 32-bit Floating Point- I am not quite sure which one to
> choose here, I chosen this option because the variable x1 that contain
> FFT magnitude is floating point. Sampling Rate: 8000
>
> In the last email, plot has been obtained using FFT Magnitude option
> but this time its Single Time and I am getting peaks but not at 1KHz.
> You can see the attached plot. I am also copying piece of code which I
> used.
>
> #include "dsk6713_aic23.h"
> Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;
> #include
> #define PTS 256 //# of points for FFT
> #define PI 3.14159265358979
> typedef struct {float real,imag;} COMPLEX;
> void FFT(COMPLEX *Y, int n); //FFT prototype
> float iobuffer[PTS]; //as input and output buffer
> float x1[PTS]; //intermediate buffer
> short i; //general purpose index variable
> short buffercount = 0; //number of new
> samples in iobuffer short flag = 0; //set
> to 1 by ISR when iobuffer full COMPLEX w[PTS];
> //twiddle constants stored in w COMPLEX samples[PTS];
> //primary working buffer
>
> main()
> {
> for (i = 0 ; i > {
> w[i].real = cos(2*PI*i/(PTS*2.0)); //Re component of twiddle constants
> w[i].imag =-sin(2*PI*i/(PTS*2.0)); //Im component of twiddle constants
> }
> comm_intr(); //init DSK, codec, McBSP
>
> while(1) //infinite loop
> {
> while (flag == 0) ; //wait until iobuffer is full
> flag = 0; //reset flag
> for (i = 0 ; i < PTS ; i++) //swap buffers
> {
> samples[i].real=iobuffer[i]; //buffer with new data
> iobuffer[i] = x1[i]; //processed frame to iobuffer
> }
> for (i = 0 ; i < PTS ; i++)
> samples[i].imag = 0.0; //imag components = 0
>
> FFT(samples,PTS); //call function FFT.c
>
> for (i = 0 ; i < PTS ; i++) //compute magnitude
> {
> // set x1 to contain the magnitude 9scaled) of transformed (processed) data
> x1[i] = sqrt(samples[i].real*samples[i].real
> +
> samples[i].imag*samples[i].imag);
> }
> x1[0] = 32000.0; //negative spike for reference
> } //end of infinite loop
>} //end of main
>
> interrupt void c_int11() //ISR
> {
> output_sample((short)(iobuffer[buffercount])); //out from
> iobuffer
iobuffer[buffercount++]=(float)((short)input_sample());
> //input to iobuffer
if (buffercount >= PTS) //if iobuffer full
{ buffercount = 0; //reinit buffercount
> flag = 1; //set flag
}
}
>
> Waiting for your response.
>
> BR,
> BS
>
> ________________________________
> From: varoonian .
> To: B S
> Cc: c...
> Sent: Thu, July 1, 2010 1:41:02 AM
> Subject: Re: [c6x] Verifying FFT Result
>
> B S,
>
> I don't quite understand you.
>
> Did you include the starting address, Sampling Frequency, Window Type
> and Buffer Size in the graph Properties Dialog Box as per your
> requirements ?
>
> Regards,
>
> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > >
> >
> >>
> >
> >>
> > [Attachment(s) from B S included below] >
> >
> >Varoonian,
> >
> >I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot
the result.
> >
> >There is one confusion about choosing FFT magnitude option for viewing graph.
I used FFT magnitude option when I was sampling real time Sine Wave and that
option was showing me peak at 1 KHz without using any FFT algorithm. In my
understadning FFT magnitude option in graph is calculating FFT again, therefore,
peak is not present at 1Khz.
> >
> >I am attaching a plot obtained by Code Composer Studio graph option.
> >
> >Waiting for your comments.
> >
> >
> >
> >
> >
> >>
> ________________________________
> From: varoonian .
> >To: B S
> >Cc: c6x@yahoogroups. com
> >Sent: Tue, June 29, 2010 7:51:25 PM
> >Subject: Re: [c6x] Verifying FFT Result
> >
> > >
> >
> >
> >>
> >
> >B S,
> >
> >
> >Why don't you plot your output array using View-->Graph in CCS and check
you're getting the peak at 1 KHz.
> >
> >
> >Regards,
> >
> >
> >>
> >On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
> >
> >>>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >> >>
> >>
> >>>>
> >>
> >>>>
> >>
> >>Hi Guys,
> >>
> >>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be
sure that FFT algorithm is working fine, I want to verify my result. Can you
please tell me how can I do this.
> >>
> >>Sampling frequency used is 8KHz and no. of FFT points are 256.
> >>
> >>Waiting for your quick response.
> >>
> >>BR,
> >>BS
> >>
> >>
> >
> >
> >--
> >Varun
> >
> > --
> Varun
------- End of Original Message -------
BS-

> Yes, I am getting the same value. I don't understand what
> does it mean.. can you please elaborate ?

I already explained this... I would refer to it but I see you have cut my previous text again.

I'll leave it to you to go back and find my previous post -- ask me if something doesn't make sense to you in my post
and you have a specific question.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BS
> Cc: c...
> Sent: Thu, July 1, 2010 7:42:23 PM
> Subject: Re: [c6x] Verifying FFT Result
>
> BS-
>
>> I plotted the result of FFT Magnitude using graph option in CCS, for
>> 1KHz signal peak appears at 32nd and 224th
>> samples respectively and the magnitudes are 7e5 for both peaks :D
>>
>> How can I calculate the exact amplitude and map it to 1 KHz
>> frequency as of real time signal ?
>
> 700,000 / 128 is about 5500. Is this the peak value you get from your AIC23 codec when you apply a 1V sine input?
>
> -Jeff
>
>> ________________________________
>> From: varoonian .
>> To: B S
>> Cc: c...
>> Sent: Thu, July 1, 2010 1:41:02 AM
>> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>>
>> B S,
>>
>> I don't quite understand you.
>>
>> Did you include the starting address, Sampling Frequency, Window Type and Buffer Size in the graph Properties Dialog
>> Box as per your requirements ?
>>
>> Regards,
>> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> >
>>>
>>>>
>>>
>>>>
>>>
>>>[Attachment(s) from B S included below]
>>>Varoonian,
>>>
>>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the result.
>>>
>>>There is one confusion about choosing FFT magnitude option for viewing graph. I used FFT magnitude option when I was
>>> sampling real time Sine Wave and that option was showing me peak at 1 KHz without using any FFT algorithm. In my
>>> understadning FFT magnitude option in graph is calculating FFT again, therefore, peak is not present at 1Khz.
>>>
>>>I am attaching a plot obtained by Code Composer Studio graph option.
>>>
>>>Waiting for your comments.
>>>
>>>
>>>
>>>
>>>
>>>>
>> ________________________________
>> From: varoonian .
>>>To: B S
>>>Cc: c...
>>>Sent: Tue, June 29, 2010 7:51:25 PM
>>>Subject: Re: [c6x] Verifying FFT Result
>>>
>>> >
>>>
>>>
>>>>
>>>
>>>B S,
>>>
>>>
>>>Why don't you plot your output array using View-->Graph in CCS and check you're getting the peak at 1 KHz.
>>>
>>>
>>>Regards,
>>>
>>>
>>>>
>>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> >>
>>>>
>>>>>>
>>>>
>>>>>>
>>>>
>>>>Hi Guys,
>>>>
>>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure that FFT algorithm is working fine,
>>>> I
>>>> want to verify my result. Can you please tell me how can I do this.
>>>>
>>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>>
>>>>Waiting for your quick response.
>>>>
>>>>BR,
>>>>BS
>>>>
>>>>
>>>
>>>
>>>--
>>>Varun
>>>
>>>
>>>
>> --
>> Varun

_____________________________________
> I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK,
> to be sure that FFT algorithm is working fine, I
> want to verify my result. Can you please tell me how can I do this.
>
> Sampling frequency used is 8KHz and no. of FFT points are 256.

If you're using no window (i.e. "rectangular window) and no zero-fill and
you have no pre- or post-FFT scaling, then
you can:

-calculate magnitude

-check bin 32 (1/8 of FFT size)

it
should be approx 128*V, where V is the the value you read from the AIC23 codec when you audio signal is 1 V.

In other words, since you have a pure sine wave, FFT
multiplies and adds should contribute to a sum at only one bin;
i.e.
your signal is a match to one of the sine waves the FFT throws at it. Of course
nothing in a real system is that
perfect, which is why I say your
amplitude value should be "approx".

-Jeff

Signal is sampled at 8 kHz and a 256-point FFT is performed, the result will consist of 256 data points (bins) each representing a frequency spectrum that is 31.25 Hz wide. In my case bin 32 represents 1 KHz signal, thats ok from frequency point of view but how amplitude of the real signal is computing (i.e. approx 128*V, as you advised), I didn't get this point.

This is how I am computing amplitude after FFT.
x1[i] = sqrt(samples[i].real*samples[i].real + samples[i].imag*samples[i].imag);

Moreover, there is one more peak at 224th bin having the same frequency and amplitude as of 32nd bin, that must be replica image, how can I discard this inorder to avoid confusion if real signal consists of more than one frequency ?

I am Obliged for your kind help.

BS

________________________________
From: Jeff Brower
To: BS
Cc: c...
Sent: Sun, July 4, 2010 10:33:14 PM
Subject: Re: [c6x] Verifying FFT Result

BS-

> Yes, I am getting the same value. I don't understand what
> does it mean.. can you please elaborate ?

I already explained this... I would refer to it but I see you have cut my previous text again.

I'll leave it to you to go back and find my previous post -- ask me if something doesn't make sense to you in my post
and you have a specific question.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BS
> Cc: c...
> Sent: Thu, July 1, 2010 7:42:23 PM
> Subject: Re: [c6x] Verifying FFT Result
>
> BS-
>
>> I plotted the result of FFT Magnitude using graph option in CCS, for
>> 1KHz signal peak appears at 32nd and 224th
>> samples respectively and the magnitudes are 7e5 for both peaks :D
>>
>> How can I calculate the exact amplitude and map it to 1 KHz
>> frequency as of real time signal ?
>
> 700,000 / 128 is about 5500. Is this the peak value you get from your AIC23 codec when you apply a 1V sine input?
>
> -Jeff
>
>> ________________________________
>> From: varoonian .
>> To: B S
>> Cc: c...
>> Sent: Thu, July 1, 2010 1:41:02 AM
>> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>>
>> B S,
>>
>> I don't quite understand you.
>>
>> Did you include the starting address, Sampling Frequency, Window Type and Buffer Size in the graph Properties Dialog
>> Box as per your requirements ?
>>
>> Regards,
>> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> >
>>>
>>>>
>>>
>>>>
>>>
>>>[Attachment(s) from B S included below]
>>>Varoonian,
>>>
>>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the result.
>>>
>>>There is one confusion about choosing FFT magnitude option for viewing graph. I used FFT magnitude option when I was
>>> sampling real time Sine Wave and that option was showing me peak at 1 KHz without using any FFT algorithm. In my
>>> understadning FFT magnitude option in graph is calculating FFT again, therefore, peak is not present at 1Khz.
>>>
>>>I am attaching a plot obtained by Code Composer Studio graph option.
>>>
>>>Waiting for your comments.
>>>
>>>
>>>
>>>
>>>
>>>>
>> ________________________________
>> From: varoonian .
>>>To: B S
>>>Cc: c...
>>>Sent: Tue, June 29, 2010 7:51:25 PM
>>>Subject: Re: [c6x] Verifying FFT Result
>>>
>>> >
>>>
>>>
>>>>
>>>
>>>B S,
>>>
>>>
>>>Why don't you plot your output array using View-->Graph in CCS and check you're getting the peak at 1 KHz.
>>>
>>>
>>>Regards,
>>>
>>>
>>>>
>>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> >>
>>>>
>>>>>>
>>>>
>>>>>>
>>>>
>>>>Hi Guys,
>>>>
>>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure that FFT algorithm is working fine,
>>>> I
>>>> want to verify my result. Can you please tell me how can I do this.
>>>>
>>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>>
>>>>Waiting for your quick response.
>>>>
>>>>BR,
>>>>BS
>>>>
>>>>
>>>
>>>
>>>--
>>>Varun
>>>
>>>
>>>
>> --
>> Varun
BS-

>> I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK,
>> to be sure that FFT algorithm is working fine, I
>> want to verify my result. Can you please tell me how can I do this.
>>
>> Sampling frequency used is 8KHz and no. of FFT points are 256.
>
> If you're using no window (i.e. "rectangular window) and no zero-fill and
> you have no pre- or post-FFT scaling, then
> you can:
> -calculate magnitude
>
> -check bin 32 (1/8 of FFT size)
>
> it
> should be approx 128*V, where V is the the value you read
> from the AIC23 codec when you audio signal is 1 V.
>
> In other words, since you have a pure sine wave, FFT
> multiplies and adds should contribute to a sum at only
> one bin; i.e. your signal is a match to one of the sine
> waves the FFT throws at it. Of course nothing in a
> real system is that perfect, which is why I say your
> amplitude value should be "approx".
>
> -Jeff
>
> Signal is sampled at 8 kHz and a 256-point FFT is performed,
> the result will consist of 256 data points (bins) each
> representing a frequency spectrum that is 31.25 Hz wide. In
> my case bin 32 represents 1 KHz signal, thats ok from
> frequency point of view but how amplitude of the real signal
> is computing (i.e. approx 128*V, as you advised), I
> didn't get this point.

To understand resulting amplitude, the main point is the second part of my explanation. First a simple thing: you
can look at the formulas for FFT and iFFT -- note the 1/N scaling. Second, you should gain a more in-depth
understanding of what an FFT actually does. One hint... it cross-correlates your input with N different sine waves...
so if you give a sine wave input, then how many matches will there be? And how does 1/N scaling apply in that case?

> This is how I am computing amplitude after FFT.
> x1[i] = sqrt(samples[i].real*samples[i].real +
> samples[i].imag*samples[i].imag);

Correct.

> Moreover, there is one more peak at 224th bin having the
> same frequency and amplitude as of 32nd bin, that must be
> replica image, how can I discard this inorder to avoid
> confusion if real signal consists of more than one frequency ?

You have real-only input (all imaginary values are zero), so (i) magnitude result is symmetric, and (ii) you can
discard the second half of magnitude (starting with point N/2+1). Think of it this way... you gave the FFT an input
that is half zero -- i.e. half "not-useful" -- so somewhere you would expect half not-useful output.

I'm only giving some general overview... nothing rigorous like you might get on comp.dsp. Again, you can get a better
understanding from studying in-depth about FFT.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BS
> Cc: c...
> Sent: Sun, July 4, 2010 10:33:14 PM
> Subject: Re: [c6x] Verifying FFT Result
>
> BS-
>
>> Yes, I am getting the same value. I don't understand what
>> does it mean.. can you please elaborate ?
>
> I already explained this... I would refer to it but I see you have cut my previous text again.
>
> I'll leave it to you to go back and find my previous post -- ask me if something doesn't make sense to you in my post
> and you have a specific question.
>
> -Jeff
>
>> ________________________________
>> From: Jeff Brower
>> To: BS
>> Cc: c...
>> Sent: Thu, July 1, 2010 7:42:23 PM
>> Subject: Re: [c6x] Verifying FFT Result
>>
>> BS-
>>
>>> I plotted the result of FFT Magnitude using graph option in CCS, for
>>> 1KHz signal peak appears at 32nd and 224th
>>> samples respectively and the magnitudes are 7e5 for both peaks :D
>>>
>>> How can I calculate the exact amplitude and map it to 1 KHz
>>> frequency as of real time signal ?
>>
>> 700,000 / 128 is about 5500. Is this the peak value you get from your AIC23 codec when you apply a 1V sine input?
>>
>> -Jeff
>>
>>> ________________________________
>>> From: varoonian .
>>> To: B S
>>> Cc: c...
>>> Sent: Thu, July 1, 2010 1:41:02 AM
>>> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>>>
>>> B S,
>>>
>>> I don't quite understand you.
>>>
>>> Did you include the starting address, Sampling Frequency, Window Type and Buffer Size in the graph Properties
>>> Dialog
>>> Box as per your requirements ?
>>>
>>> Regards,
>>>
>>>
>>> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> >
>>>>
>>>>>
>>>>
>>>>>
>>>>
>>>>[Attachment(s) from B S included below]
>>>>Varoonian,
>>>>
>>>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the result.
>>>>
>>>>There is one confusion about choosing FFT magnitude option for viewing graph. I used FFT magnitude option when I
>>>> was
>>>> sampling real time Sine Wave and that option was showing me peak at 1 KHz without using any FFT algorithm. In my
>>>> understadning FFT magnitude option in graph is calculating FFT again, therefore, peak is not present at 1Khz.
>>>>
>>>>I am attaching a plot obtained by Code Composer Studio graph option.
>>>>
>>>>Waiting for your comments.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>> ________________________________
>>> From: varoonian .
>>>>To: B S
>>>>Cc: c...
>>>>Sent: Tue, June 29, 2010 7:51:25 PM
>>>>Subject: Re: [c6x] Verifying FFT Result
>>>>
>>>> >
>>>>
>>>>
>>>>>
>>>>
>>>>B S,
>>>>
>>>>
>>>>Why don't you plot your output array using View-->Graph in CCS and check you're getting the peak at 1 KHz.
>>>>
>>>>
>>>>Regards,
>>>>
>>>>
>>>>>
>>>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> >>
>>>>>
>>>>>>>
>>>>>
>>>>>>>
>>>>>
>>>>>Hi Guys,
>>>>>
>>>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure that FFT algorithm is working fine,
>>>>> I
>>>>> want to verify my result. Can you please tell me how can I do this.
>>>>>
>>>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>>>
>>>>>Waiting for your quick response.
>>>>>
>>>>>BR,
>>>>>BS
>>>>>
>>>>>
>>>>
>>>>
>>>>--
>>>>Varun
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Varun
>>>
>>>
>>>
>>

_____________________________________
Jeff,

Thanks alot for your valuable suggestion and kind help.

-BS

________________________________
From: Jeff Brower
To: B S
Cc: c...
Sent: Tue, July 6, 2010 12:32:52 PM
Subject: Re: [c6x] Verifying FFT Result

BS-

>> I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK,
>> to be sure that FFT algorithm is working fine, I
>> want to verify my result. Can you please tell me how can I do this.
>>
>> Sampling frequency used is 8KHz and no. of FFT points are 256.
>
> If you're using no window (i.e. "rectangular window) and no zero-fill and
> you have no pre- or post-FFT scaling, then
> you can:
> -calculate magnitude
>
> -check bin 32 (1/8 of FFT size)
>
> it
> should be approx 128*V, where V is the the value you read
> from the AIC23 codec when you audio signal is 1 V.
>
> In other words, since you have a pure sine wave, FFT
> multiplies and adds should contribute to a sum at only
> one bin; i.e. your signal is a match to one of the sine
> waves the FFT throws at it. Of course nothing in a
> real system is that perfect, which is why I say your
> amplitude value should be "approx".
>
> -Jeff
>
> Signal is sampled at 8 kHz and a 256-point FFT is performed,
> the result will consist of 256 data points (bins) each
> representing a frequency spectrum that is 31.25 Hz wide. In
> my case bin 32 represents 1 KHz signal, thats ok from
> frequency point of view but how amplitude of the real signal
> is computing (i.e. approx 128*V, as you advised), I
> didn't get this point.

To understand resulting amplitude, the main point is the second part of my
explanation. First a simple thing: you
can look at the formulas for FFT and iFFT -- note the 1/N scaling. Second, you
should gain a more in-depth
understanding of what an FFT actually does. One hint... it cross-correlates
your input with N different sine waves...
so if you give a sine wave input, then how many matches will there be? And how
does 1/N scaling apply in that case?

> This is how I am computing amplitude after FFT.
> x1[i] = sqrt(samples[i].real*samples[i].real +
> samples[i].imag*samples[i].imag);

Correct.

> Moreover, there is one more peak at 224th bin having the
> same frequency and amplitude as of 32nd bin, that must be
> replica image, how can I discard this inorder to avoid
> confusion if real signal consists of more than one frequency ?

You have real-only input (all imaginary values are zero), so (i) magnitude
result is symmetric, and (ii) you can
discard the second half of magnitude (starting with point N/2+1). Think of it
this way... you gave the FFT an input
that is half zero -- i.e. half "not-useful" -- so somewhere you would expect
half not-useful output.

I'm only giving some general overview... nothing rigorous like you might get on
comp.dsp. Again, you can get a better
understanding from studying in-depth about FFT.

-Jeff

> ________________________________
> From: Jeff Brower
> To: BS
> Cc: c...
> Sent: Sun, July 4, 2010 10:33:14 PM
> Subject: Re: [c6x] Verifying FFT Result
>
> BS-
>
>> Yes, I am getting the same value. I don't understand what
>> does it mean.. can you please elaborate ?
>
> I already explained this... I would refer to it but I see you have cut my
>previous text again.
>
> I'll leave it to you to go back and find my previous post -- ask me if
>something doesn't make sense to you in my post
> and you have a specific question.
>
> -Jeff
>
>> ________________________________
>> From: Jeff Brower
>> To: BS
>> Cc: c...
>> Sent: Thu, July 1, 2010 7:42:23 PM
>> Subject: Re: [c6x] Verifying FFT Result
>>
>> BS-
>>
>>> I plotted the result of FFT Magnitude using graph option in CCS, for
>>> 1KHz signal peak appears at 32nd and 224th
>>> samples respectively and the magnitudes are 7e5 for both peaks :D
>>>
>>> How can I calculate the exact amplitude and map it to 1 KHz
>>> frequency as of real time signal ?
>>
>> 700,000 / 128 is about 5500. Is this the peak value you get from your AIC23
>>codec when you apply a 1V sine input?
>>
>> -Jeff
>>
>>> ________________________________
>>> From: varoonian .
>>> To: B S
>>> Cc: c...
>>> Sent: Thu, July 1, 2010 1:41:02 AM
>>> Subject: Re: [c6x] Verifying FFT Result [1 Attachment]
>>>
>>> B S,
>>>
>>> I don't quite understand you.
>>>
>>> Did you include the starting address, Sampling Frequency, Window Type and
>>>Buffer Size in the graph Properties
>>> Dialog
>>> Box as per your requirements ?
>>>
>>> Regards,
>>>
>>>
>>> On Wed, Jun 30, 2010 at 4:06 AM, B S wrote:
>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> >
>>>>
>>>>>
>>>>
>>>>>
>>>>
>>>>[Attachment(s) from B S included below]
>>>>Varoonian,
>>>>
>>>>I did try but there is no peak at 1 KHz, I used FFT magnitude option to plot the
>>>>result.
>>>>
>>>>There is one confusion about choosing FFT magnitude option for viewing graph. I
>>>>used FFT magnitude option when I
>>>> was
>>>> sampling real time Sine Wave and that option was showing me peak at 1 KHz
>>>>without using any FFT algorithm. In my
>>>> understadning FFT magnitude option in graph is calculating FFT again,
>>>>therefore, peak is not present at 1Khz.
>>>>
>>>>I am attaching a plot obtained by Code Composer Studio graph option.
>>>>
>>>>Waiting for your comments.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>
>>> ________________________________
>>> From: varoonian .
>>>>To: B S
>>>>Cc: c...
>>>>Sent: Tue, June 29, 2010 7:51:25 PM
>>>>Subject: Re: [c6x] Verifying FFT Result
>>>>
>>>> >
>>>>
>>>>
>>>>>
>>>>
>>>>B S,
>>>>
>>>>
>>>>Why don't you plot your output array using View-->Graph in CCS and check you're
>>>>getting the peak at 1 KHz.
>>>>
>>>>
>>>>Regards,
>>>>
>>>>
>>>>>
>>>>On Tue, Jun 29, 2010 at 4:54 AM, B S wrote:
>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> >>
>>>>>
>>>>>>>
>>>>>
>>>>>>>
>>>>>
>>>>>Hi Guys,
>>>>>
>>>>>I have computed FFT of 1 KHz sine wave with 1 Vp_p using C6713 DSK, to be sure
>>>>>that FFT algorithm is working fine,
>>>>> I
>>>>> want to verify my result. Can you please tell me how can I do this.
>>>>>
>>>>>Sampling frequency used is 8KHz and no. of FFT points are 256.
>>>>>
>>>>>Waiting for your quick response.
>>>>>
>>>>>BR,
>>>>>BS
>>>>>
>>>>>
>>>>
>>>>
>>>>--
>>>>Varun
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> Varun
>>>
>>>
>>>
>>
Hi,
I tried to compute FFT for real time signal using dsk_app.c project given in
C6713 example codes. As you know, in dsk_app.c project, input is taken from LINE
IN jack and same signal is throughing out using LINE OUT jack with out any
change.
I did input a simple sine wave of 1 Khz with 1 Vp_p but I am getting strange
kind of result. I'm basically converting both the ping and pong buffers into
real and imaginary parts and then using fft on those buffers. I processed the
sampled data in processBuffer(void) function in the following way.

float x1[BUFFSIZE]; // BUFFSIZE = 1024;
float y1[BUFFSIZE];
void processBuffer(void)
{
Uint32 pingPong;
Int16 i;

/* Get contents of mailbox posted by edmaHwi */
pingPong = SWI_getmbox();

/* Copy data from transmit to receive, could process audio here */
if (pingPong == PING) {

for (i = 0 ; i < BUFFSIZE ; i++) // Converting values into real and imm
part for FFT

{
samples[i].real= (float)gBufferRcvPing[i]; // changing RcvPing from int16
type to float type for FFT calculation
}

for (i = 0 ; i < BUFFSIZE ; i++)
samples[i].imag = 0.0; //imag components = 0

FFT(samples,BUFFSIZE); //call function FFT.c

for (i = 0 ; i < BUFFSIZE ; i++) //compute magnitude
{
x1[i] = sqrt(samples[i].real*samples[i].real +
samples[i].imag*samples[i].imag);
gBufferXmtPing[i] = (Int16)x1[i];// chaning back from float type to int16
type before transmitting

}

/* Copy receive PING buffer to transmit PING buffer */
copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);

} else {

for (i = 0 ; i < BUFFSIZE ; i++) // Converting values into real and imm
part for FFT

{
samples[i].real= (float)gBufferRcvPong[i]; //changing RcvPong from int16
type to float type for FFT calculation
}

for (i = 0 ; i < BUFFSIZE ; i++)
samples[i].imag = 0.0; //imag components = 0

FFT(samples,BUFFSIZE); //call function FFT.c

for (i = 0 ; i < BUFFSIZE ; i++) //compute magnitude
{
y1[i] = sqrt(samples[i].real*samples[i].real +
samples[i].imag*samples[i].imag);
gBufferXmtPong[i] = (Int16)y1[i]; // chaning back from float type to int16
type before transmitting
}
/* Copy receive PONG buffer to transmit PONG buffer */
copyData(gBufferRcvPong, gBufferXmtPong, BUFFSIZE);

}
}

Can any one please explain where I am missing some thing or what is wrong ?
Looking forward for your kind help.

Thanks and Regards.

BS
BS,

What is 'strange' about the output?

have you checked to assure that no interrupt times are being overrun?

using the same 'processing' samples[] buffer for both the PING and the PONG
processing is probably a bad idea as begin/end/overlap cases would corrupt the
values in the samples[] buffer.

using indexing 'samples[i]' for traversing the buffers is probably acceptable if
lots of optimization is used. However, a much better idea is to use only
pointers and increment the pointers rather than all the math involved in an un-
optimized samples[i] for traversing the buffers.

I would combine the setting of the 'real' portion with the setting of the 'imag'
portion to reduce the number of memory fetches/stores.

In the calculation of xi[] = sqrt(...),
I would make use of pointers, to eliminate the math instructions involved in the
samples[i].real and samples[i].imag offset calculations

The elimination of the excess math operations will greatly speed up the
processBuffer() function.

Since all the processing/copying is being performed during the processBuffer()
software interrupt handler function, there is no need for both x1[] and y1[]
buffers because the software interrupt handler function cannot interrupt itself.

Since an index can/does use a full 32 bit register value, and that value is
always positive, I would eliminate a lot of internal calculation/bit clearing by
changing "Int16 i;"
to "register unsigned int i;"
As a simple example, the following code:
for (i = 0 ; i < BUFFSIZE ; i++) // Converting values into real
> and imm part for FFT
>
> {
> samples[i].real= (float)gBufferRcvPing[i]; // changing RcvPing
> from int16 type to float type for FFT calculation }
>
> for (i = 0 ; i < BUFFSIZE ; i++)
> samples[i].imag = 0.0; //imag components = 0
>
> FFT(samples,BUFFSIZE); //call function FFT.c
>
could become:
Int16 * pRxData;
complex * pSample;
for (pRxData=gBufferRcvPing, // set ptr to source data
pSample=samples; // set ptr to dest data
pRxData < (const)&gBufferRcvPing[BUFFSIZE]; // check for end
pRxData++, pSample++) // update pointers
{
*(pSample->real) = *pRxData; // copy source to dest w/conversion
*(pSample->imag) = 0.0; // clear imaginary part
}

I suspect some data corruption is occurring, possibly because the software
interrupt handler processBuffer() is taking too long to execute, is why you are
seeing some strange output.

The calculation of the values in the x1[] buffer is actually a trig function to
calculate the hyp of a right triangle.
Therefore, I suspect (have not checked) that a trig function may be
significantly faster than the current method of:
multiplying and multiplying and adding and calculation of the square root.

I would place all the buffers into the L2 cache as data
I would reserve a area in the L2 cache as program instructions.

R. Williams
---------- Original Message -----------
From: B S
To: Richard Williams
Cc: c...
Sent: Wed, 7 Jul 2010 14:23:39 -0700 (PDT)
Subject: Re: [c6x] Verifying FFT Result with DSK_APP.c Project

> Hi,
>
> I tried to compute FFT for real time signal using dsk_app.c project
> given in C6713 example codes. As you know, in dsk_app.c project, input
> is taken from LINE IN jack and same signal is throughing out using
> LINE OUT jack with out any change.
>
> I did input a simple sine wave of 1 Khz with 1 Vp_p but I am getting
> strange kind of result. I'm basically converting both the ping and
> pong buffers into real and imaginary parts and then using fft on those
> buffers. I processed the sampled data in processBuffer(void) function
> in the following way.
>
> float x1[BUFFSIZE]; // BUFFSIZE = 1024;
> float y1[BUFFSIZE];
> void processBuffer(void)
> {
> Uint32 pingPong;
> Int16 i;
>
> /* Get contents of mailbox posted by edmaHwi */
> pingPong = SWI_getmbox();
>
> /* Copy data from transmit to receive, could process audio here */
> if (pingPong == PING) {
>
> for (i = 0 ; i < BUFFSIZE ; i++) // Converting values into real
> and imm part for FFT
>
> {
> samples[i].real= (float)gBufferRcvPing[i]; // changing RcvPing
> from int16 type to float type for FFT calculation }
>
> for (i = 0 ; i < BUFFSIZE ; i++)
> samples[i].imag = 0.0; //imag components = 0
>
> FFT(samples,BUFFSIZE); //call function FFT.c
>
> for (i = 0 ; i < BUFFSIZE ; i++) //compute magnitude
> {
> x1[i] = sqrt(samples[i].real*samples[i].real +
> samples[i].imag*samples[i].imag);
> gBufferXmtPing[i] = (Int16)x1[i];// chaning back from float type
> to int16 type before transmitting
>
> }
>
> /* Copy receive PING buffer to transmit PING buffer */
> copyData(gBufferRcvPing, gBufferXmtPing, BUFFSIZE);
>
> } else {
>
> for (i = 0 ; i < BUFFSIZE ; i++) // Converting values into real
> and imm part for FFT
>
> {
> samples[i].real= (float)gBufferRcvPong[i]; //changing RcvPong
> from int16 type to float type for FFT calculation }
>
> for (i = 0 ; i < BUFFSIZE ; i++)
> samples[i].imag = 0.0; //imag components = 0
>
> FFT(samples,BUFFSIZE); //call function FFT.c
>
> for (i = 0 ; i < BUFFSIZE ; i++) //compute magnitude
> {
> y1[i] = sqrt(samples[i].real*samples[i].real +
> samples[i].imag*samples[i].imag);
> gBufferXmtPong[i] = (Int16)y1[i]; // chaning back from float type
> to int16 type before transmitting } /* Copy receive PONG
> buffer to transmit PONG buffer */ copyData(gBufferRcvPong,
> gBufferXmtPong, BUFFSIZE);
>
> }
> }
>
> Can any one please explain where I am missing some thing or what is
> wrong ?
>
> Looking forward for your kind help.
>
> Thanks and Regards.
>
> BS
------- End of Original Message -------

_____________________________________