help required to generate smooth pwm sine wave with PIC16F73

Status
Not open for further replies.

Mithun_K_Das

Advanced Member level 3
Joined
Apr 24, 2010
Messages
899
Helped
24
Reputation
48
Reaction score
26
Trophy points
1,318
Location
Dhaka, Bangladesh, Bangladesh
Activity points
8,253
I was designing a sine wave inverter based on smps. other blocks are on, now I need to generate a pure sine wave output with pwm signal. I'm using PIC16F73. Can anyone help me in calculation to get 50Hz sine wave??? And also the filter designing part needs help.

my program is:

float teta;
unsigned char sample[15];
int i=0;
void main()
{
TRISC = 0x00;
PORTC = 0x00;
PWM1_Start();
PWM2_Start();
PWM1_Set_Duty(50000);
PWM2_Set_Duty(50000);
while(1)
{

for (i=0; i<15; i++)
{
teta = ( (float) i / 15 ) * 3.14159;
sample = (int) (255 * sin ( teta ));
PWM1_Set_Duty(sample);
}

for (i=0; i<15; i++)
{
teta = ( (float) i / 15 ) * 3.14159;
sample = (int) (255 * sin ( teta ));
PWM2_Set_Duty(sample);
}
}
}
 

Could you please post your result up to now?
 

Hello Mr. Mithun, To generate pure sine with 16F73 you must need a lookup table using calculated sine point. Because 16F series doesn't have enough speed to calculate Multiplication
for (i=0; i<15; i++)
{
teta = ( (float) i / 15 ) * 3.14159;
sample = (int) (255 * sin ( teta ));
PWM1_Set_Duty(sample);
}


Try this lookup table : 0,25,50,74,98,120,142,162,180,197,212,_
225,235,244,250,254,255,254,250,244,235,_
225,212,197,180,162,142,120,98,74,50,25

Periodically call them with timer interrupt for 180 degree of sine wave using ccp1 , and swap with other 180 by ccp2
 
Reactions: Mithun_K_Das

    Mithun_K_Das

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…