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.

TMS320F28027F FFT or Digital Filter

Other Parts Discussed in Thread: TMS320F28027F, TMS320F28027

I am using the TMS320F28027F processor. I am sampling a signal that contains 1Hz to 100Hz components. The main frequency I am interested in is a 10Hz signal. I would like to monitor the amplitude of this 10Hz signal without interference form the other frequencies. My sample rate is 1000 samples per second. I could do an FFT and acquire the amplitude of the 10 Hz signal or I could perform a digital bandpass filter with a center at 10Hz. Most of the other frequencies are 30 Hz and above and below 7Hz, so I think a digital filter would work well and would probably use les processor resources than an FFT. My experience with FFTs is practically null. I was looking for some expert guidance on what would be the best approach since all I need is to monitor the amplitude of the 1Hz signal. 

I am also running the InstaSpin FOC code to run a motor, so my processor is already using most of its MIPS to run the motor. If an FFT is best, what type FFT and what minimum size should I use? If the filter approach is best should I do an FIR or IIR filter to get the most accurate amplitude for the 10Hz signal? Or is there some other method I could use to acquire the amplitude of the 1 Hz signal with minimal processor overhead? 

It may be important to know that I am generating the 10 Hz signal with the PWM1 output. I filter the PWM1 output with a hardware sallen-key filter to generate a pseudo sine wave. This sinewave then drives part of my system which I then sample the output of at 1000sps. Most the other frequencies are from my system and the PWM1 square wave harmonics not completely filtered by the sallen-key filter. I am trying to keep the hardware and MIPS to a minimum in order to save cost. Any help or guidance would be appreciated.

  • After some web research, it seems the Goertzel algorithm would be an option. Is there any guadance on how to implement this for my system on a TMS320F28027. It mostly used for DTMF tone detection, but I guess that is exactly what I am doing. MAybe somone has done this on a C2000 chip.
  • Gary,

    yes have tried implementing it, unfortunately cannot share code but the above link is very close and what i kind of followed for my implementation,

    regards

    Manish 

  • Just one more piece of information, if it is magnitude detection this can be used but if it is phase detection then it may me more complicated, i was not able to implement the later using goertzel
  • I plan to give this a try. It will take me several days to get it going. I will report back the results. Thanks for the help.
  • Just wondering if I should declare my variable as the base IQ24 and then cast my ADC samples as IQ. I would then use _IQmpy(...) to do the Goertzel calculations.

    For example,

    _iq GoertCoeff = _IQ(1.996053);

    _iq Goert0;

    _iq Goert1;

    _iq Goert2;

    ....

    (_iq)ADC_readResult...

    OR should I declare everything float_t and do the math just like the examples in the link above. I am not experienced with the IQ math, but when looking at the Instaspin motor code I see they use it alot. Not sure which, if either, will give me the best result or the most efficient code. I need the calculation to be as quick as possible.

    Also is there any way to know the best sample size for N. I was going to start with 1000 and try smaller and bigger to determine what is the minimum I need to get a good result.

  • I was able to get the Goertzel Algorithm to work. This greatly reduces the complexity of doing a full FFT.

    I also used the following link to help.

    http://www.embedded.com/design/configurable-systems/4024443/The-Goertzel-Algorithm

    This allows me to detect the peak amplitude of just the frequency I am interested in and seems to reject all the other frequencies very well.

    I tried floats at first. I may try the IQ math later. I still need to properly scale the numbers since they get fairly large at the peaks. 

    For the below code I was actually detecting a 1Hz signal sampled at 100 samples per second. I used a N of 100.

     

    float_t   GoertCoeff = 1.996053457;

    float_t   Goert0 = 0;

    float_t   Goert1 = 0;

    float_t   Goert2 = 0;

    float_t   GoertMag = 0;

    float_t   GoertMag1 = 0;

    float_t   GoertMag2 = 0;

     

     

    //Calculate N samples

    // I subtract 2000 just to eleminate DC offset. I do not think this is needed.

    Goert0 = GoertCoeff * Goert1 - Goert2 + ((float_t)(gO2ADCvalue[0]) - 2000);

    Goert2 = Goert1;

    Goert1 = Goert0;

     

    //Find Magnitude after N samples

    //I broke out the amplitude calculations to help see the size of each multiply

    GoertMag = Goert1 * Goert1 + Goert2 * Goert2;

    GoertMag1 = Goert1 * Goert2 * GoertCoeff;

    GoertMag2 = GoertMag - GoertMag1;

    Goert2 = 0;

    Goert1 = 0;