I am trying to calculate the pulse waves for the PWM (Pulse Width Modulation) of a Pure Sine Wave with 60 Hz or 50 Hz.
Each pulse wave duration calculated, either to power on or power off, must be a whole number of 3 μs (microseconds) or greater. The challenge is to closely approximate a pure sine wave within the constraints specified above.
My best attempt is this:
p = power on microseconds (μs) as a whole number of 3 or greater.
n = no power (power off) (μs) as a whole number of 3 or greater.
h = Hz rate, which will be 60 or 50 Hz.
m = microseconds (μs) for a single sine wave cycle at h Hz
t = total microseconds (μs) for the previous pulse calculations
$$h = 60$$ $$m = \frac{1000000}{h} = 16667$$ $$\frac{p}{p+n} ≈ \sin(\frac{p+n+t}{m} \times \frac{\pi}{2})$$
I started with the assumption to turn power on at the minimum 3 μs and then calculated the first power off duration to be 178 μs.
Then I added 1 to the 3 μs to turn power on again for 4 μs and then calculated to have it turned off for 132 μs; I suspect that just adding 1 each time to the power on duration is not correct, but I don't know how to determine when I should increase that duration more rapidly. I want to calculate to sin(0.5) and then use these numbers backwards to zero, and then repeat the full cycle for the negative side of the sine wave.
I know my assumptions are wrong, the total μs exceeds 16667 μs for a single cycle, it came out to be 5676 x 4 = 22704 μs with 214 on-off pulse combinations. I'm close, but not quite there.
This problem has humbled me, I'm absolutely stuck and will appreciate any help. Thank you.