• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » Questions about the IIR function (from C28xx_dsp_fixed_point_library) and eziii (matlab tool)
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Questions about the IIR function (from C28xx_dsp_fixed_point_library) and eziii (matlab tool)

    Questions about the IIR function (from C28xx_dsp_fixed_point_library) and eziii (matlab tool)

    This question is not answered
    Andrej Chukavin93807
    Posted by Andrej Chukavin93807
    on Jul 27 2012 07:07 AM
    Prodigy50 points

    I want to use the TMS320F28035+ADS1298 devices to detect ECG signals.To do this, processor should be HPS (0.005Hz), BSF (50 Hz), LPF (150Hz) filters. For this I use the function IIR5BIQ32 from C28x_DSP_fixed_point_library and EZIIR tool for filter design.

    The experimental conditions:

    1. hardware: ECG simulator, TMS320F28035+ADS1298+TFT to resistration and display ECG, XDS100 v2 debuger.

    2. software: CCS v4, C28x_DSP_fixed_point_library  (use IIR5BIQ32 function), Matlab 2006,  EZIIR tool.

    3. Sample frequecy 500, data from ADC 24bit,  investigated by various filters varinty (bat, cheb type 1, ceb type2, elep), bandstop supression 20-40 db, bandpass ripple 0.1 db.

    4. At TFT visually comparing the signal to the filter and after filter.

    At the moment, I have developed and tested LPF and BSF. It is work fine. But HPS not work. I experimented with the LPF and BSF and all worked well.

    Experiments with HPF showed that there is a dependence on the filter cutoff frequency:

    1. Fp=30Hz, Fs=10 - all types HPF work fine.

    2..Fp=10Hz, Fs=5Hz - Filter work (stop constant and low frequency part of signal), but bed. After filtering the signal noise appears.

    3. Fp=10Hz, Fs=1Hz (or every 1<Fs<Fp<10 Hz) - filter not work,  output everytime zero. (In matlab all normals)

    4. Fp=1Hz, Fs=0.1Hz,    or Fp=0.1 Fs=0,05,  or Fp=0.05 Fs=0,005(or 0.01) (it is my target)          (or every 0.01<Fs<Fp<1 Hz)  - filter not work, filter output of large-amplitude chaotic sgnal. I think the filter is not stable. (In matlab as before, all the normals)

    Questions:

    1. Data format.

    In documentation on the function IIR5BIQ32 of states: the format of input data Q31 and output data same Q31. So I have to make a shift to 8 my 24-bit signed number (ADC result), and I will get a number in the format of Q31. So I have to make the shift to the left to 8 bit my 24-bit signed number (ADC result), and I will get a number in the format of Q31. If the filter output in the format Q31, the number obtained after the filter I need shift to  right to 8 bit, that the number was in the original format. But if I do it (shift to the right of adding to the eight values ​​of the sign in the leftmost 8 bits, as usual), the amplitude of the signal after the filter 2 times less than before the filter (I can see it on the screen), although it should remain the same. Hence the output value of the filter should be shifted to the right by 7 bits, and the format of the output Q30 and not Q31. This was confirmed by my experiments on all types of filters.
    In the description of the functions IIR5BIQ32 there is an error? Am I right or wrong?

    2  HPF filter.

    I would like to know what the above described problem with the HPF filter. Function IIR5BIQ32 is working not correctly, or EZIIR program working not correctly.

    And most importantly - how do I filter (for example - fourth order chebishev type 2) with a cutoff frequency less than 10Hz (5, 1, 0.5, 0.1, 0.005, etc.), using the EZIIR tool and the IIR5BIQ32 function? Write a function IIR filter, I can `t own, use the FIR filter as there is no possibility of a large hardware requirements FIR filter (especially memory).

    Thanks in advance.

    Chukavin Andrej.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Vishal_Coelho
      Posted by Vishal_Coelho
      on Jul 30 2012 09:47 AM
      Expert5725 points

      Hi,

      Andrej Chukavin93807
      In the description of the functions IIR5BIQ32 there is an error? Am I right or wrong?

      The filter coefficients generated by the eziir routine have a scaling factor associated with it and it may be close to 0.5 in your case which is why you are seeing the discrepancy in the amplitudes. The examples in the eziir_matlab.pdf doc show a few examples of this. It isnt explicitly mentioned anywhere so ill make a note to put it in the guide on the next revision. So you can shift left 8, process, then shift right 8 but you will need to compensate for the scaling factor......

      Andrej Chukavin93807
      how do I filter (for example - fourth order chebishev type 2) with a cutoff frequency less than 10Hz

      Ill try to create a HPF based on the parameters in your post and get back to you with my findings

      Regards,

      Vishal

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Andrej Chukavin93807
      Posted by Andrej Chukavin93807
      on Jul 31 2012 06:13 AM
      Prodigy50 points

      Hello I do not quite understand what you said about scaling factor.

       Here is a sample calculation of the two filters:

      and second:

      Input scaling value first 0.5279, and second 0.0111. But the output value of both filters is twice the amplitude is less than the input (test signal - 2 Hz sine wave, both filters transmit it without distortion). After the filter, I multiply the signal by 2 (divide by 0.5), and the amplitude of the signal becomes an input. If I use these values ​​of the input scale (divide by 0.5279 for the first filter and 0.0111 for the second filter), the first course and runs second to none.

      it is my code:

      // chenal[4] - signed long, there is ADC 24 bit data

      chenal[4]=(chenal[4]<<8);  // format Q31

      iir.input=chenal[4];  // in filter

      iir.calc(&iir); // filter

      chenal[4]=iir.output32; // out filter

      chenal[4]= (chenal[4]&0x80000000)|((chenal[4]>>1)&(0x3FFFFFFF));  // format Q31->Q30

      chenal[4] = _IQ30div(chenal[4], _IQ30(0.5));  // use IQmath function for divide

      if ((chenal[4]&0x800000000)==0x800000000) // return to the original format of the data - signed long, 24 bit ADC result

      {  chenal[4]=(chenal[4]>>7);   chenal[4] = 0xFF800000|chenal[4];}

      else chenal[4]=(chenal[4]>>7);

      Question: How should I take a scaling factor of output signal from the filter. (In these examples, the value of 0.5 was obtained experimentally).


      Just to cite an example of high-pass filter does not work (This is for second question of this topic):

       

       

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Vishal_Coelho
      Posted by Vishal_Coelho
      on Aug 08 2012 15:27 PM
      Expert5725 points

      So i went through the example project in controlSUITE, the inverse scaling factor is fed into the IIR structure itself so you dont have to compensate for it. I tried the settings you described in the post and sure enough, there is a divide by 2 in the output. I compensated for it while storing the result....this doesnt cost you anything in terms of assembly instructions, the assembler will use a MOV with shift instruction.

      As for the HPF case, the problem is with the inverse scaling factor ISF = 8.5406e-6, which when scaled to the Q format for the design (QFMAT = 13 so scale by 2^13 = 8192) it will round to 0 and this is why your output is all zero. MATLAB wont have any issues as it works in double precision. If possible you might try relaxing the filter parameters

      Regards,

      Vishal

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use