www.ti.com
2.1.2
Q Format and Preferred Global Q for DMC
Q Format is a way of representing a numeric value containing a sign, integer and fraction portion in a fixed
bit location field.
Figure
partitioned to represent the sign, integer, and fractional parts.
S I I I I I I I . F F F F F F F F F F F F F F F F F F F F F F F F
where
S: Sign Bit (1 bit)
I: Integer Bits (7 bits)
F: Fraction Bits (24 bits)
Thus, the fixed bit location acts as a virtual floating point. The IQ Math library makes use of such a
representation to compute the functions on a fixed-point device. The IQ Math library further allows the
user to select the appropriate numeric range and resolution by choosing where the decimal point is
located, i.e., how many bits of the binary represented number are integers and how many are the
quotient/fraction.
A value of a number represented in the format above can be interpreted as:
The number of fraction bits determines the Q format of the number. For a given word length (e.g., 32 bits),
the greater the number of fractional bits, the higher the resolution, and the smaller the dynamic range.
Table 1
shows some examples regarding the range and resolution of 32-bit, fixed-point numbers for
different Q format representations.
Table 1. Range and Resolution of 32-bit Fixed-point Number for Different Q-format Representation
GLOBAL_Q
28
24
20
A high resolution and large dynamic range is typically needed for precise control algorithm execution.
Motor control applications formats between Q31 to Q27 do not provide enough dynamic range, and
formats of Q18 or lower result in significant quantization errors, due to insufficient resolution. Therefore, a
format of Q24 is used by the TI motor control software because it provides enough high resolution and
enough dynamic range to tackle a wide variety of motor applications. Note that all the motor control
projects are implemented based on per unit (pu) system variables and the Q used by these variables is by
default, Q24. For floating-point devices, single-precision IEEE float is used. Also note that although the
default Q is 24, the DMC library can be made to use any other Q format by changing the GLOBAL_Q
value.
2.1.3
Summary of the IQ Math Functions
The routines included within the IQmath library can be classified as:
•
Arithmetic/math functions (addition, subtraction, multiply, divide, etc.)
•
Trigonometric functions (sine, cosine, tangent, etc.)
•
Format conversion utilities (scales numbers from one Q format to another)
•
Miscellaneous (saturation, absolute value, etc.)
Some of the IQmath library functions used often in motor control are shown in
SPRUGI6 – September 2010
Submit Documentation Feedback
1. The following image illustrates a 32-bit binary number where the bits are
Figure 1. Sign, Integer, Fractional Parts
I
I -1
1
2
+ 2
+ ... + 2
+ 2
Max Val
127.999 999 940
2047.999 999 046
Copyright © 2010, Texas Instruments Incorporated
0
-1
- 2
. 2
+ 2
+ ... + 2
Min Val
7.999 999 996
-8
-128
-2048
TMS320C2000 Motor Control Primer
Software Tools
-F
Resolution
0.000 000 004
0.000 000 060
0.000 000 954
Table
2.
3
Need help?
Do you have a question about the TMS320C2000 and is the answer not in the manual?
Questions and answers