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.

TMS320F28069: Why does we don't need to divide the ADC result by full range while using IQmath?

Part Number: TMS320F28069

_iq Result;
void main(void)
{
// Convert the ADC result into global IQ format valued between 0.0 and 1.0
Result = _IQ12toIQ( (_iq)AdcResult.ADCRESULT0 );

// Optional: scale by ADC full-scale range to get 0.0 to 3.3
// (if you prefer to think/scale in terms of voltage)
Result = _IQmpy( _iq(3.3), Result);
}

In floating point maths, we multiply ADCresult obtained by 3.3 and then divide by 4096. Why is this not applicable while using IQmath?

  • Mayuri,

    Think of it this way - assume that the ADC value is a value between 0.0 and 1.0. Then the 12-bit ADC provided value (0-4095) represents this floating-pt value, which makes the ADC provided value an IQ12 type value.

    So now you want to convert this IQ12 value to the Global Q value (e.g. 24). Hence the value is converted using _IQ12toIQ(). Assume the Global Q is 12, then the value remains unchanged.

    Now, the next line of the code shows what you commented about - if the value represented is not 0.0-1.0, but 0.0-3.3, then we need to scale accordingly, which is what is done with the multiply.

    What is not shown in the above code is the final step - now suppose you want to convert the IQ12 value back to a floating point value. That can be done using IQNint and IQNfrac (See IQMath_quickstart.pdf user guide). This is where the "division" by 4096 is done.

    Thanks,

    Sira