Hi,
I am currently completing a project that uses the TMS320F2808 processor to acquire two channels of data using 16-bit ADCs which is then processed using the Fixed Point DSP software library in order to determine frequency content from D.C. to about 5KHz
My setup is essentially working but I do not quite get the responses that I would have expected when using a test square wave. The test square wave has a frequency of 100.6Hz at its peak-to-peak magnitude is set to 0x7FFF0000 (approx. +1) to 0x80010000 (approx. -1) in Q31 format.
I am sampling at a frequency of 12877Hz and collect 1024 samples which are processed using an instance of rfft to generate real magnitude data.
The first four Q30 results is am getting are as follows.
bin magnitude
8 0x19F11CF9
24 0x02E31686
40 0x010AEDAF
56 0x0088D8CC
To get floating-point values, I then divide each Q30 result by 2^30 then multiply by 2. Leaving the values in RMS^2 form as follows.
8 0.810682714
24 0.0902206972
40 0.0325840376
56 0.0167049393
Taking the square root of each value produces the final result.
8 0.9
24 0.3
40 0.1895
56 0.1292
Since the input square wave has a maximum amplitude of approx. +/-1 I would have expected the magnitudes to have been 1, 1/3, 1/5 and 1/7.
If I change the input signal to a D.C. level of 0x7FFF0000 throughout, get a value in bin 0 of 0x3FFF0001 which when divided by 2^30 and then square rooted gives a value of 0.9999 as expected. There is no multiply by 2 for bin 0 as far as I can figure.
This is how I am interpreting the Q31 results, which may be where the problem lies somewhere.
For all bins I divide by 2^30 to get a floating-point value. Then for all bins except bin 0 I multiply this by 2. Then for all bins I find the square root to yield the final answer.
Would this be correct?
Should I be able to expect results that are more accurate than this?
Regards
FarmerJo