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.

IQMath Q Format

Hi,

I am in the process of developing some software on a TMS320 with Code Composer 3 and I have a question regarding the Q format, IQ Math and exactly what it all means;

I am struggling to understand what exactly it means in terms of the overall system and was hoping someone could explain it;

I have downloaded sprc990 and it does not really explain it to me; lets say for example, is there any reason why I would not set global q to 19; after all that is the range of the ADC.

Also, if someone can perhaps explain exactly what is going on in the attached xls spreadsheet it would be great - the kit I purchased came with sample code and scaling values but I cant figure out what all the equations on the lower half of the sheet are supposed to be doing.

Thanks for your time,

Seán.

 

 

Renewable-Calculations.xls
  • Hi Sean,

    IQmath is a library that implements fixed point math functions. The "Q" number that you encounter when working with it is the binary equivalent of the decimal point. For example, a number in q4 means there are 4 binary digits after the binary point. You may also see that as a resolution of 1 / (2^4).

    You can either use the global "Q" number and have all your IQmath variables be declared with the same "precision", or you can change it freely by calling the appropriate IQXX functions. Look up information about fixed point math for more details.

    One reason why you may want to use different q numbers in your program is that you may be working with large numbers (for example Converter_Power_W_q0 = 60000 (60kW)) and tiny numbers (for example an inductance of 20uH represented in H, for which you may want a high resolution, greater than q16).

    If we look at your ADC... Let's say you have a 12 bit ADC, and one channel that measures a voltage up to 400V (with scaling down to ADC range). You can work with a q12 per unit number between 0 and 1, or have a q4 number representing Volts. These two solutions are approximately equivalent and would give you a resolution matching that of the ADC.

    In the excel sheet, my guess is that your VoMax number is represented with a q9 precision, so in the DSP 32.94V would yield 16865.

    Regards,