This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi everyone.
I would need a confirm, a clarification about the library c28x_vcu2_library.lib.
1.) as I understand, array input to CFFT and ICFFT must be {imag0,real0, imag1,real1 .... imag(N-1),real(N-1)} ?
2.) for RCFFT
CFFT.run(handleCFFT); CFFT_unpack(handleCFFT);
output will be half fft and will be negative part (-f/2 .. 0), structure output {real,imag,real,imag...} ?
3.) the part that interests me most. controlSUITE don't has example for RIFFT.
to make RIFFT, I proceed in this way:
input array negative part (-f/2 .. 0) , structure {real,imag,real,imag...};
CFFT.pInBuffer = input_data;// (-f/2 .. 0) {real,imag,real,imag ....} CFFT.pOutBuffer = output_data; CFFT.init = (void (*)(void *))CFFT_init64Pt; CFFT.run = (void (*)(void *))ICFFT_run64Pt; CFFT.init(handleCFFT); CFFT_pack(handleCFFT); CFFT.run(handleCFFT);
the process is right?
output I have my signal, but phase-shifted by 22 degrees.
if process is right,what causes this phase-shift? if process is not right,where wrong?
I hope I was clear.
Thanks for your help.
Hi Marco,
marco zanardi said:1.) as I understand, array input to CFFT and ICFFT must be {imag0,real0, imag1,real1 .... imag(N-1),real(N-1)} ?
If you are using VCU2 code, its [real, imag, real, imag ....]
marco zanardi said:2.) for RCFFT
For real FFT, your 2N pt real sequence is treated as N-pt complex so, x(0) is real, x(1) is imaginary and so on; its run through an N point complex FFT, then "unpacked" (that may not be the official terminology but that is what we named the function)
marco zanardi said:3.) the part that interests me most. controlSUITE don't has example for RIFFT.
Yeah this is going to be on v2.10.00.00 which is in the internal review process now. Im trying to get it out for the march controlsuite release. The operation you have listed is essentially correct, although in the example i wrote its
I have attached the example for your reference. I believe the source functions i.e. pack, conjugate etc are already in the 2.00 release
2837x_vcu2_rifft_examples_150602.zip
If you unzip to the examples_ccsv5 folder, everything should work......hopefully
Hi Vishal,
Thanks for reply so fast.
Vishal_Coelho said:marco zanardi1.) as I understand, array input to CFFT and ICFFT must be {imag0,real0, imag1,real1 .... imag(N-1),real(N-1)} ?If you are using VCU2 code, its [real, imag, real, imag ....]
honestly, now I'm a little confused.
looking at the source vcu2_cfft_xx.asm , algorithm works with 32-bit and CPACK=1 [Lo:Hi] => [Real:Imag]
in my case {imag0,real0, (imag0 => 16-bit ,real0=> 16-bit)
[ HI , LO]
in your case [real , imag, real, imag ....]
mistake?
Hi Vishal,
thanks for example.I really appreciate your work.
I analyzed the code and for me something is wrong.
if I want to do RFFT -> switched pInBuffer and pOutBuffer -> RIFFT
I expect to have the same signal, but not so.
code: real data
CFFT.pInBuffer = input; CFFT.pOutBuffer = output; CFFT.init = (void (*)(void *))CFFT_init64Pt; CFFT.run = (void (*)(void *))CFFT_run64Pt; CFFT.init(handleCFFT); CFFT.run(handleCFFT); CFFT_unpack(handleCFFT); pTemp = CFFT.pInBuffer; CFFT.pInBuffer = CFFT.pOutBuffer; CFFT.pOutBuffer = pTemp; CFFT_pack(handleCFFT); CFFT.run(handleCFFT); CFFT_conjugate(handleCFFT->pOutBuffer, handleCFFT->nSamples);
how do you see the input and output does not coincide.
1943 cycles(pack+run+conjugate) for unfinished data, are so many.
the amplitude is 240 times smaller, does not fit, I expect 4 times smaller and no more.
I did not stop, I did go through with it.
the problem is that they are not well documented input and output structure.
1. the output of function CFFT_unpack has the structure =>
{real0,imag0 ... real(N-1),imag(N-1)} (-f/2 .. 0) [real0,imag0] -> 0, [real(N-1),imag(N-1)] -> -f/2 , [HI,LO]
2. CFFT_pack(handleCFFT)
the input of function has the structure => {imag0,real0...imag(N-1),real(N-1)} (0 .. f/2)
[imag0,real0] -> 0, [imag(N-1),real(N-1)] -> f/2 , [HI,LO]
the output of function gives Z(k) = Fe(k) + jFo(k) k = 0..N/2-1 ,
for information http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM
That said, just do
a.) pack
b.) runs inverse complex FFT
3. the output structure of RIFFT => data are inverted, CFFT.pOutBuffer[0] -> N,
[CFFT.pOutBuffer[1]..CFFT.pOutBuffer[N-1]] -> [0 .. N-1]
control code:
//RFFT CFFT.pInBuffer = input; CFFT.pOutBuffer = output; CFFT.init = (void (*)(void *))CFFT_init64Pt; CFFT.run = (void (*)(void *))CFFT_run64Pt; CFFT.init(handleCFFT); CFFT.run(handleCFFT); CFFT_unpack(handleCFFT); //adjust CFFT.pInBuffer /*for(i = 0; i < handleCFFT->nSamples; i+=2){ CFFT.pInBuffer[2*i] = CFFT.pOutBuffer[2*i+1]; CFFT.pInBuffer[2*i+1] = CFFT.pOutBuffer[2*i]; } */ for(i = 0; i < handleCFFT->nSamples*2; i+=2){ CFFT.pInBuffer[i+1] = CFFT.pOutBuffer[i]; CFFT.pInBuffer[i] = CFFT.pOutBuffer[i+1]; } CFFT_conjugate(handleCFFT->pInBuffer, handleCFFT->nSamples); //RIFFT CFFT.run = (void (*)(void *))ICFFT_run64Pt; CFFT_pack(handleCFFT); CFFT.run(handleCFFT);
how do you see, 1669 clk for finite data and the amplitude is 4 times smaller,as must be. that a good result.
//adjust RIFFT output, CFFT.pOutBuffer -> CFFT.pInBuffer CFFT.pInBuffer[handleCFFT->nSamples*2-1] = CFFT.pOutBuffer[0]*-1; for(i=0;i<handleCFFT->nSamples*2-1; i++) CFFT.pInBuffer[i] = CFFT.pOutBuffer[i+1]*-1;
this is my conclusion.
as you think? this procedure is right?
thanks.
update,
the analysis made above is valid only if real signal has data on even bins (odd bins without data).
seems algorithm of function CFFT_pack(handleCFFT) contains bug.
some help.
update,
sorry, my fault.
error in my code:
//adjust CFFT.pInBuffer for(i = 0; i < handleCFFT->nSamples; i+=2){ CFFT.pInBuffer[2*i] = CFFT.pOutBuffer[2*i+1]; CFFT.pInBuffer[2*i+1] = CFFT.pOutBuffer[2*i]; } CFFT_conjugate(handleCFFT->pInBuffer, handleCFFT->nSamples);
must be
//adjust CFFT.pInBuffer for(i = 0; i < handleCFFT->nSamples*2; i+=2){ CFFT.pInBuffer[i+1] = CFFT.pOutBuffer[i]; CFFT.pInBuffer[i] = CFFT.pOutBuffer[i+1]; } CFFT_conjugate(handleCFFT->pInBuffer, handleCFFT->nSamples);
now seems fully functional.
can someone test?
thanks.
Hi Marco,
Sorry, I forgot to give you the new pack routine - there was a bug in the old one:
Please rebuild the library and try with this function
Marco,
Sorry for the rather late reply. I finally got the example working - the output buffer needed to be aligned to a 2N word boundary as well as the input, since we switch them for the RIFFT, i.e. the output becomes the input for the RIFFT process. Anyway ive attached the example (which will also go out in v2.10.00.00).
The pack/unpack and FFT scale down the input, so the output will be <0.25x the original - I will try to quantify exactly what this factor is, but i cannot get rid of the divisions in each of the assembly routine as they are there to prevent overflows - so you might have to scale up the output of the unpack to get as close to the original - i tried scaling up by 4*sqrt(N) and it was 0.5x the original - scaling up further would saturate some values after the pack.