Global Sources
EE Times-India
Stay in touch with EE Times India
EE Times-India > Embedded

Implement trigonometric functions in software with CORDIC

Posted: 23 Jul 2008     Print Version  Bookmark and Share

Keywords:CORDIC  algorithm 

Trigonometric functions are often used in embedded systems. Motor drive control applications such as the Park Transform, Clarke Transform, and PWM generation use trigonometric functions extensively. Various methods exist to compute the trigonometric functions. These include Taylor series, Curve fitting algorithms, and the Curve fitting algorithms, and the Coordinate Rotation Digital Computer (CORDIC) algorithm.

This tutorial describes software implementation of the following fixed point trigonometric routines using the CORDIC Algorithm on Infineon's XC164CS Microcontroller with MAC unit. The implementation of the algorithm is examined concerning accuracy and efficiency:
* Complex Magnitude
* Sine
* Cosine

Routines are provided for signed two's complement arithmetic. First a brief description of the theory behind the algorithm is presented. Then the theory is extended to the implementation of algorithm in XC164CS Processor after which the numerical errors that occur in the fixed point implementation is discussed.

CORDIC arithmetic technique
The CORDIC algorithm is an iterative technique proposed by Volder in 1956. This algorithm can be a very powerful tool in areas where arithmetic or trigonometric function evaluation is heavily utilized, such as digital signal processing, motor control.

The general vector rotational transform rotates a plane vector [X, Y] by an angle Θ to produce a new vector point [Xi+1, Yi+1] as in Equations (1) and(2). The CORDIC Rotation is achieved by the same principle. It rotates the point [X, Y] in series of steps, which are smaller than Θ.

This rotation may be in anti clockwise direction (increase in Θ) or clock wise direction (decrease in ). Suppose if we wish to achieve a total rotation of 35o, we may rotate our point 30o anticlockwise, followed by 10o anticlockwise, followed by 5o clockwise.

image name

The reason for this simplification is to break down the rotation (Θ) into many steps, each of decreasing size and has each step such that tan is the power of 2, where Θ is the rotational angle. The first seven steps of the set of rotations are shown in Table 1.

image name

Table 1: The first seven steps of the set of rotations.

This would allow us to implement the multiplication by tan Θ as a simple bit shift operation (2-i). Hence Equations (3) and (4) reduce to

image name

From Table 1, it is clear that the total rotation step is 99.88o. Since the rotation can be of clockwise or anticlockwise direction these steps are used to approximate angles between +99.88o to -99.88o. For mathematical simplicity the rotation angles are limited to "90o and +90o. For rotation angles greater than ±90o additional rotation is required. The cos Θ term (K) is a constant which approaches to 0.6073 after 'n' iterations. The angle Θ is accumulated in Zi+1

image name

1 • 2 • 3 • 4 Next Page Last Page

Comment on "Implement trigonometric functions in..."
*  You can enter [0] more charecters.
*Verify code:


Visit Asia Webinars to learn about the latest in technology and get practical design tips.


Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

Back to Top