sme7000
Newbie level 6
i,m using pic16f877 to generate SPWM. sine wave that i build in half wave need to be invert because PIC cannot read in negative value. can anybody help me with this problem..this is what i write in c programming.
#include <stdio.h>
#include<math.h>
#include<float.h>
int main()
{
int Am=10;
float pi=3.1416;
float t=0.0005;
int n;
int Vm;
while(1); //infinite loop
{ for(n=0;n<=20;n++)
{
Vm= Am*sin(100*pi*n*t);
}
for(n=20;n<=0;n--)
{
Vm=Am*sin(100*pi*n*t);
}
}
}
#include <stdio.h>
#include<math.h>
#include<float.h>
int main()
{
int Am=10;
float pi=3.1416;
float t=0.0005;
int n;
int Vm;
while(1); //infinite loop
{ for(n=0;n<=20;n++)
{
Vm= Am*sin(100*pi*n*t);
}
for(n=20;n<=0;n--)
{
Vm=Am*sin(100*pi*n*t);
}
}
}