Home > C/C++ > Codingforembeddedticalculator

Codingforembeddedticalculator

November 13th, 2009

Write code in Code Composer Studio 3.1 or Code Composer Studio 3.3.
http://focus.ti.com/docs/toolsw/folders/print/ccstudio.html
PROGRAMMING METHOD sinusoidal signals sum of two angles.

Purpose: to get acquainted with the various algorithms of formation of sinusoidal signals, the development and debugging of the generator of sinusoidal signals based on recursively-analytical method the sum of two angles to the processor TMS320VC5510 (laboratory model) TMS320VC5510 DSP Starter Kit (DSK).

THEORETICAL BACKGROUND
Formula sum of two angles.
There are several analytical (computational) methods for the formation of sinusoidal signals. One such method is based on formulas of the sum of two angles:

This method is applicable for serial sampling a sine wave generation, and allows you to calculate the next count functions such as sin (an) = sin (a (n-1) + a), a previous sin (a (n-1)).
Using a(n-1) as α and β as a and denoting S1 = sin (a), C1 = cos (a), Sn (n) = sin (an), Cn (n) = cos (an) obtain the following expressions for calculating the next value of sine and cosine:

Initial data for calculating the first harmonic (with the lowest possible frequency) are the following values: Sn (0) = 0, Cn (0) = 1 – sine and cosine values for zero arguments; N – length of sample (number of counts in the first harmonic); a = 2Π / N, – the minimum increment of the argument and S1 = sin (2Π / N), C1 = cos (2Π / N) – values of sine and cosine for the minimum of the argument.
Figure 1.1 shows an example of a sinewave with a period of 8 samples (N = 8).

Given that the initial values for the k-th harmonic are the initial angle β = ak, Sk = sin (ak) and Ck = cos (ak), for their calculation can use the same formula:

Initial data for calculation, as in the expression (1.2) are the values of Sk (0) = 0 and Ck (0) = 1
Putting the data in memory as follows Cn, Sn, Ck, Sk, C1, S1, you can use the same routine with the indirect addressing for the calculation of both the regular readings of harmonic Sn and Cn, and the initial values of Sk and Ck.
What initially set the pointer (the address in the auxiliary register) on Ck and calculate the next value Ck and Sk, and then on Cn and calculate the required number of readings regular harmonic Sn and Cn:

Notes for achieving a programming task:
When programming sinusoid this method should take into account the following observations:


Codingforembeddedticalculator

Categories: C/C++ Tags: , , , , , ,