EN0
Member
That was my point. He really needs to work on terms. He may understand the concept but he's not conveying it.
In his new graphic for example, point 'C' should be 100% duty cycle and point 'H' should be 0% duty cycle. And without a reference on the X axis one might assume his transitions are occurring at regular intervals which would produce a sawtooth wave instead of a sine wave, that is if you can imply that "pwm increment" is actually "duty cycle".
Shoddy terms followed up with a shoddy graphic which includes more shoddy terms.
Mike, point H should be -5V; this is a sine wave after all.
All you are doing is gradually setting your PWM output level higher until you reach the maximum 5V value, then you're decrementing down in your PWM output level till you get to 0V; this is your positive peak cycle. Then, you decrement to 0V until -5V, then back to 0V again; this is your negative peak cycle. If you connect the dots, your making a sine wave, and 1% increments will make a more pure sine wave then 10%, etc.
In code in algorithm form would be similar to this:
Code:
while(1)
{
// POSITIVE CYCLE (0° = 0V, 90° = 5V, 180° = 0V)
for(i=0;i<100;i++) // Rising edge in percentage
{
PWM_Output_Positive(i, freq);
}
for(i=100;i>0;i--) // Falling edge in percentage
{
PWM_Output_Positive(i, freq);
}
//****************
//NEGATIVE CYCLE, (180° = 0V, 270° = -5V, 360° = 0V)
for(i=0;i>-100;i--) // Falling edge in percentage
{
PWM_Output_Negative(i, freq); // Negative falling edge of sine wave
}
for(i=-100;i<0;i++) // Rising edge in percentage
{
PWM_Output_Negative(i, freq); // Negative rising edge of sine wave
}
}
Last edited: