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.

How resolve HWAFFT result ?

Hi~ Hi~

 

We development c5515 with ADS129x for bio signal measurement.

So, we call hwafft() function that convert ADS129x raw signal to FFT data.

But, we don't understand output of hwafft() because output of hwafft is Int32 format.

We need real type(double or float on C/C++) FFT data...

How resolve or  convert a hwafft's Int32 type result to real type data?

Thank a lot.

  • Hello,

    Have you read the descriptions of the array structures in the HWAFFT User's Guide?

    http://www.ti.com/lit/an/sprabb6a/sprabb6a.pdf

    Simply put, each 32-bit int contains 16-bits real part and 16-bits imaginary part, so you could read the array as a 16-bit int and skip every other word or read the array as a 32-bit int and mask the imaginary part out...

    Hope this helps,
    Mark

  • Thanks your answer.

    But, It is not satisfied our question. Evenly, Your focus miss...

    Of course, this situation is our responsibility and our language power leakage.. So we are sorry.

    Our expecting answer is the method that convert Integer type FFT result to a real number(double or float type).

    a example case:

       ADS129x input: -2V~2V, 10Hz  & -1V~1V, 2.5Hz sine wave complex.

       ADS Vref: 2.4V

       ADS sampling rate: 1000 SPS

       Then, hwafft result for this sampling raw data is what?

    In this case, We hope getting 10Hz, 2.5Hz data as hwafft result.

    But, hwafft output pure integer type data.

    Is we getting 10Hz & 2Hz result??

    If not, what shall we does for acquisition correcting result?

    thanks, for read.

  • Hello,

    The output of the HWAFFT is bins of frequencies. A bin has more amplitude if the signal contains that bin's assigned frequency. The amplitude or "energy" of each bin is represented as 16-bits real & 16-bits complex.

    The frequency step from one bin to the next bin is determined by the signal sampling frequency and the FFT length.

    For example, sampling rate: 1000 SPS (1000Hz) and FFT Length = 512 pts... then the FFT result is contained in 512 bins (the second 256 bins are a redundant mirror image of the first 256 bins). The frequency granularity between consecutive bins (bin width) is calculated as the sampling rate/ FFT Length = 1000 / 512 = 1.953Hz per bin.

    Bin 0 = 0Hz

    Bin 1 = 1.953Hz

    Bin 1 = 3.906Hz ...

    For more granularity, you can use a larger FFT Length... Try 1024 pts

    Fs = 1000Hz & FFT Length = 1024... Bin width = sampling rate/ FFT Length = 1000 / 1024 = .977Hz per bin

    Bin 0 = 0Hz

    Bin 1 = 0.977Hz

    Bin 1 = 1.953Hz ...

    For Fs = 1000Hz & FFT Length = 1024, a signal of 2.5Hz will have large amplitude or "energy" in bins 2 & 3 (between 1.953 Hz and 2.930 Hz)

    For Fs = 1000Hz & FFT Length = 1024, a signal of 10Hz will have large amplitude in bin 10 (9.766 Hz)

    If you have MATLAB, play with the code below to see the relationship between Fs, FFT Length, signal frequency, and the resulting FFT bin.

    close all;

    FFT_Len = 1024;                    % Choose FFT Length (power of 2: 8-1024)

    fs = 1000                          % sampling frequency
    N = 1000;                          % signal length
    sig = zeros(1,N);                  % create sig buffer
    n = 0:(N-1);                       

    %Create 10Hz tone
    fk = 10;                           % signal frequency
    A = 2/2.4;                         % peak amplitude
    sig = A * sin(2*pi*n*fk/fs);       % create sampled sine signal

    Create 2.5Hz tone
    fk = 2.5;                          % signal frequency
    A = 1/2.4;                         % peak amplitude
    sig = sig + A * sin(2*pi*n*fk/fs); % create sampled sine signal

    plot(sig);

    %FFT

    Y = fft(sig, FFT_Len);             % Calculate FFT
    Pyy =  Y.* conj(Y) / FFT_Len;      % Power of FFT

    figure;
    stem(0:FFT_Len/2,Y(1:FFT_Len/2+1)) %FFT_Len/2 because second half is mirror image
    title('Frequency of y')
    xlabel('FFT Bins')

    figure;
    stem(0:FFT_Len/2,Pyy(1:FFT_Len/2+1))
    title('Frequency Power of y')
    xlabel('FFT Bins')

    The plots looks like:

    Signal with 2.5Hz and 10Hz tones:

    FFT Result without redundant redundant second half:

    FFT Result zoomed in where 2.5Hz and 10Hz can be clearly seen:

    Hope this helps,
    Mark

  • Thanks for your detailed answer & explanation.

    So, we do not resolve our  curiosity & we have remained question.

    1. According to your answer, It does not exist the method that get amplitude of accuracy 10Hz & 2.5Hz.

    ex: 9.766Hz instead 10Hz, & (between 1.953 Hz and 2.930 Hz) instead 2.5Hz...

    But, clearly number of amplitude in 10Hz, 2Hz, 3Hz is displayed on your appending matlab's picture.

    We feel miracle about your picture. How is it possible? We guess existence that like equation in matlab inside.

    Please, give us a its equation or method that amplitude of integer Hz in case not integer bins width bound situation.

    2. Even now, we don't know the conversion method a FFT real part to double data type number.

    Likely your explain, FFT result is 16bit real part & 16bit complex part as concatenate 32bit

    But its 16bit real part is modeling express on "pure mathematics" side & a expression of it is "integer data type" on DSP side.

    We don't know that its integer value means.

    a more example case:

       ADS129x input: 1.75V, 10Hz  & 0.63V, 2Hz & 0.88V, 2.5Hz sine wave complex.

       ADS Vref: 2.4V

       ADS sampling rate: 1000 SPS, and attach 24 zero padding => 1024 sample data.

       And input FFT 1024pts.

       By your mention, point consist between SPS & pts. thus bin width is integer bound(1Hz, 2Hz, 3Hz, ..), we right?

       Then, real part of hwafft result for this sampling raw data is what? Maybe integer value, 1(10Hz), 0(2Hz) ?

       If not, What convert integer data value in real part of hwafft result    TO   double data value ???

     

    Thanks, thanks. a lot.

    Have nice a weekend.