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.

sine funtion

hi,

i m trying spwm program modyfuing asymmetric pwm code in control suite. i used sin(x) funtion in the code.

the compilation doestnt throw any error but show a warning of implicit funtion used and the result of this funtion is not correct.

Is there any inbuilt header that i should use or please suggest any solution

 

cheers,

suriya

  • hi i forgot to mention the device

    i  use picollo f28069

     

    please give me some solution

    cheers

    suriya

  • what about including "math.h"?

  • i just tried spwm with the concept of increasing the pulse width and then decreasing it.

    the triangular frequency is 20khz. therefore i had given period to be

    #define period 2000

    and took an array s[20] to be as given below with 20 samples with 10 samples for positive cycle and gave 10 samples as 0 for negative cycle.

       s[0]=0;
        s[1]=100;
        s[2]=200;
        s[3]=300;
        s[4]=400;
        s[5]=500;
        s[6]=400;
        s[7]=300;
        s[8]=200;
        s[9]=100;
        s[10]=0;
        for(i=11;i<=20;i++)
        s[i]=0;
      //=================================
      //    Forever LOOP
      //=================================
      // Just sit and loop forever:
      // No interrups needed in this example.
      // PWM pins can be observed with a scope.    

          for(;;)
        {
            for(j=0;j<20;j++)
             {
                 duty_cycle_A=s[j];
                for(i=0;i<20;i++)
               {
                 EPwm2Regs.CMPA.half.CMPA = duty_cycle_A;      // Add duty_cycle_A to watch window
                   }
              }                                     
        }

    }

    the required sine frequency is 50 hz which is 20 msec

    20 * 20= 400 samples. since the period is 1/20k=50 mu sec 50 mu *400 = 20 m sec

    i expect (20m/50mu)=400 pulses per sample. for one particular sample the 400 pulses would have same width but the next 400 pulses would have a different pulse width

    but i m not getting the required output

    can anyone say what is the problem and say whether my understanding is right?