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.

TMS320F28069M: Error in Duty cycle values

Part Number: TMS320F28069M


Dear Sir/Madam,

Code:

#define pi 3.1415926

#define M 0.4 

double theta = 0;

theta= 100 * pi * (period_count / 10000.0);

//*************sector1*************//
if(theta>=0 && theta<(pi/6)||theta>=(11*pi/6) && theta<=(2*pi))
{
D1 = 1/3+(2/pi)*M * cos(theta);
D3 = 1/3+(2/pi)*M * cos(theta+(2*pi/3));
D5 = 1/3+(2/pi)*M * cos(theta-(2*pi/3));

For the above lines of code, my expected output is 

D1 value decreases from 0.587 to 0.553 when theta is 0 to 30 degrees, whereas 0.553 to 0.587 when theta is 330 to 360 degrees

D3 value varies between 0.2060 to 0.1128 when theta is 0 to 30 degrees, whereas 0.333 to 0.206 when theta is 330 to 360 degrees

D5 value varies between 0.206 to 0.3333 when theta is 0 to 30 degrees, whereas 0.333 to 0.206 when theta is 330 to 360 degrees

But I am getting the following values in the watch window

D1 is varying between 0.2546 to 0.2231 (theta is 0 to 30 degrees)

D3 is varying between -0.1273 to -0.2178 (theta is 0 to 30 degrees)

D5 is varying  between -0.1273 to -0.0053 (theta is 0 to 30 degrees)

Please help me in sorting out this issue