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.

IQ math use in calculation



Hi to all,

how can I perform a simple aritmethic mean on a DSP2812 application ?

In specific: I collect 200 int16 samples (read from ADC) and then calculate mean on this values. At the end, result must be saved into int16 value.

I want use IQmath value and functions for my division operation (to preserve time overhead), but it is not clear wich IQ format is correct to balance either range and resolution and how values may be manipulated 

Thank you for your suggests

  • Hi

     it is not clear wich IQ format is correct to balance either range and resolution and how values may be manipulated 

    please go through the below links for detail. This may help your query.

    http://processors.wiki.ti.com/index.php/IQmath_Library_for_C28x

    www.ti.com/.../sprc990.pdf

    Regards

    Aditya

  • Thanks for your tip, but I had already read these documents and my trouble isn't resolved ...

    At the momento I cast value to IQ1 type with one position left shift, divide for 200 costant and then recast to a long with 2 position right shift; it seems to work but I don't know if this is the best fit (especially for preserving precision and resolution ...) 

  • Thanks for your tip, but I had already read these documents and my trouble isn't resolved ...
    At the momento I cast value to IQ1 type with one position left shift, divide for 200 costant and then recast to a long with 2 position right shift; it seems to work but I don't know if this is the best fit (especially for preserving precision and resolution ...)
  • Hi,

    a divide by 200 means you lose about 7 bits of precision (closer to 8, 2^8=256). 1/200 is equivalent to 1.28*2^-8. So what you could do is multiply your input by _IQx(1.28) then right shift the result 8 bits to get the same effect. The IQ format you choose is entirely dependent on what range you want your ADC input to represent.

    So if i get a 12-bit ADC sample (unsigned range of 0 to 4095), and i decide that the input is to be in the range 0 to 1.0 I can left shift the input 4 bits and treat it as IQ15. I would then multiply by IQ15(1.28) and then right shift the result 8 bits to give the effect of multiplying by 1/200. I dont know if this is the best possible way to do it but you can try it out and see if it works.
  • Hi Vishal,

    thank you for your suggestion, it seems a good idea ...

    Before you post this, I follow a similar way: I use sum value of 200 sample in _IQ16div function (that is _IQ16div(<value>,200))

    and then I convert the result to a final integer value with the statement  _IQ16int(<div> << 16) (where div is the result of previous division ...).

    It seems work well, but I take into account your indications ...

    Many thanks !!