Fixed-point DSP algorithm design based on IQmath library

Publisher:二进制心灵Latest update time:2010-11-18 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

DSP digital signal processors are divided into two basic types: fixed-point and floating-point. The biggest difference between them is that floating-point DSP has more powerful computing power and a wider range of dynamic accuracy than fixed-point DSP. Floating-point DSP has a hardware unit that specifically supports floating-point operations. Data in floating-point format can be directly added to hardware operations through code, so the operation speed is very high. Fixed-point DSP does not have a fixed-point operation unit. It must use software to implement real numbers in floating-point format, which increases the instruction code and indirectly makes the fixed-point DSP operation speed lower than that of floating-point DSP. Typical floating-point processors, such as TI's C6000 series, and almost all embedded microcontrollers are fixed-point processors, such as TI's C2000 series. Because floating-point DSP is more expensive, fixed-point DSP still has its huge advantages. However, any algorithm requires floating-point operations, so how to improve the speed and accuracy of floating-point operations on fixed-point DSP has become a key issue that users must consider when developing. The IQmath library provided by TI for the fixed-point processor TMS320C2000 series provides a good implementation method for solving the above problems.

1 Number Scaling: Q Format

Fixed-point DSP cannot process decimals directly. There are three ways to process decimals when programming:
① Define the variable as float type. This method requires the least programming, but the compiled code is the largest.
② Enlarge the integer variable to represent the decimal. This is a method often used by many programmers who develop fixed-point DSPs, but the program is not portable.
③ Use integer calibration to determine the decimal, that is, use Q format to represent the decimal. For fixed-point processors, no matter what type of data is defined, integer data is ultimately used for specific operations.

The essence of integer calibration is to determine the precision of the decimal by determining where the decimal point is located, which is usually expressed in Q format. The Q format of a 32-bit signed fixed-point number is as follows:
a.JPG
Where S is the sign bit, I is the integer part, and f is the decimal part. The size of the fixed-point number is calculated as follows:
b.JPG
For example, the decimal point of the Q15 fixed-point number is located to the right of the 15th bit, and the decimal 0.25 is expressed as 2000H using Q15. This is a very simple way to express a decimal in an integer format. For a fixed-point DSP, processing decimals is exactly the same as processing integers. It should be noted that when using Q format data for algorithm design, overflow must be considered. The range and precision of various Q format data representations refer to the literature.

2 TMS320F2812 fixed-point DSP processor

As a typical product of TI's C2000 series DSP, the fixed-point processor TMS320F2812 has a high cost-effectiveness and is widely used in industrial control, especially in areas that require high processing speed and processing accuracy. TMS320F2812 integrates Flash memory, A/D converter, event manager, QEP and a variety of communication modules, and has powerful control and signal processing capabilities, making it easy for users to develop high-performance digital control systems. In particular, the IQmath library designed by TI for the C28xx core can realize accurate floating-point operations and complex control algorithms on fixed-point DSP processors.

3 IQmath library and its application

The IQmath library is a highly optimized and high-precision mathematical function library. The functions contained in the IQmath library all use Q-format fixed-point numbers as input/output, allowing programmers to design floating-point algorithms on fixed-point TMS320F281xx processors, thereby increasing the speed of calculations.

3.1 IQmath Library Composition

The IQmath library can be used in C/C++ programming and consists of 4 parts:

◆IQmath header file IQmathLib.h
◆Object file containing all functions and value tables IQmath.lib
◆Command link file IQmath.cmd
◆GEL file for debugging IQmath.gel

3.2 IQmath Library Functions

The IQmath library mainly includes the following functions (which users can call directly when designing and developing programs):

◆Format conversion functions IQ(), IQN(), IQtoF(), IQtoIQN(), etc.
◆Arithmetic operation functions IQmpy(), IQdiv(), etc.
◆Trigonometric operation functions IQsin(), IQcos(), IQatan2(), etc.
References to each function in the IQmath library and its meaning.

3.3 Application of IQmath library functions

The following describes how to use the IQmath library in a C program. First, you need to install the IQmath library, which can be downloaded for free from TI's website http://www.dspvillage.ti.com. Then create a new project and add IQmath.lib and IQmath.cmd to the project. At the same time, you must also add IQmath.gel to the project, because the transformation and adjustment of IQ variables are all achieved through the GEL function. After setting up according to the above steps, you can use the functions in the IQmath library in the C language program. It should be noted that IQmath.cmd must contain the following content:

c.JPG
d.JPG

4 Fixed-point implementation of PARK transform floating-point algorithm

In the field of modern AC motor control, the space vector control method (SVPWM) enables the control strategy of AC motors to be similar to the control strategy of DC motors, and can achieve separate control of torque current and flux, thus becoming the mainstream AC servo drive control strategy. Using the powerful computing power and signal processing capabilities of DSP, the current and flux control of SVPWM can be implemented by software. The TMS320F2812 processor has two event managers (EVA/EVB) and encoder circuits (QEP) specifically for motor control, making it one of the best choices for motion control. Figure 1 is
a system block diagram of the SVPWM control algorithm implemented using TMS320F2812.

e.JPG

As can be seen from Figure 1, PARK transformation is one of the most complex transformations in the SVPWM control algorithm. It is a transformation of a rotating vector is from a stationary two-phase coordinate system (α-β) to a synchronously rotating two-phase coordinate system (dq). The PARK transformation coordinate mapping is shown in Figure 2.

f.JPG


From Figure 2, we can get the equation of PARK transformation:
g.JPG

Because PARK transformation is a floating-point algorithm, it is very expensive to implement it using floating-point operations on the fixed-point processor TMS320F2812. Using floating-point types for programming will generate very large codes, and will inevitably affect the efficiency and performance of the system in loop calculations. The IQmath library can convert floating-point algorithms into fixed-point algorithms, so that the calculation speed can be significantly improved, which is very effective for the design of motion control systems with good real-time requirements. The program segment for implementing PARK transformation using the IQmath library is as follows:
h.JPG
Figure 3 is a waveform diagram of the SVPWM program written by the IQmath library using the Embedded Target for TI C2000 DSP integrated development tool to calculate the PWM duty cycle.

5-1.JPG

5 Conclusion

The IQmath library can be used to achieve seamless connection between floating-point algorithms and fixed-point algorithms on the 32-bit fixed-point processor TMS320F2812, which can greatly enhance the computing power of the fixed-point DSP; high-precision calculations can be achieved without sacrificing time cycles, and the conversion, implantation and execution of floating-point algorithms can be completed quickly; the calculation accuracy can also be adjusted accordingly according to the different requirements of the application system, which is more efficient than directly using the ANSI C language.

Reference address:Fixed-point DSP algorithm design based on IQmath library

Previous article:Transplantation of μC/OS-II on TMS320VC5402 Processor
Next article:Taxi safety monitoring system based on TMS320DM355 processor

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号